Olá, Pessoal. Estou tentando consumir dados via graphql, mas sem sucesso!
No IDE eu obtenho sucesso, mas passando no front e recebo erro 500.
“message”: “Invalid GraphQL query. “shipping” was not found in the current schema. Maybe you forgot to list some app dependency for this in pitstop.store-theme@7.2.24’s manifest.json?”
getShippingEstimate.gql
query getShippingEstimates(
$items: [ShippingItem]
$postalCode: String!
$country: String!
) {
shipping(items: $items, postalCode: $postalCode, country: $country)
@context(provider: "vtex.search-graphql") {
logisticsInfo {
itemIndex
slas {
id
friendlyName
price
shippingEstimate
shippingEstimateDate
}
}
}
}
type ShippingItem {
id: String!
quantity: String!
seller: String!
}
UseShipping/index.tsx
import React from 'react'
import { useQuery } from 'react-apollo'
import getShippingEstimates from '../../graphql/type/getShippingEstimate.gql'
type ISla = {
id: String,
friendlyName: String,
price: Number,
shippingEstimate: String,
shippingEstimateDate: any
}
interface logisticsInfo {
itemIndex: Number,
slas : ISla
}
export const UseGqlMvp = () => {
const { data, loading } = useQuery<logisticsInfo>(getShippingEstimates, {
variables: {
items: [
{
id: "161421",
quantity: "1",
seller: "1"
}
],
postalCode: "08562500",
country: "BRA"
}
})
const item = data?.slas?.friendlyName
console.log('SHIPPING', data)
return <>SHIPPING</>
}