Error 500 GraphQl #pdp

Hello, everyone. I’m trying to consume data via GraphQL, but without success!

In the IDE I get it working, but when passing it through the front end I get a 500 error.

„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</>
}

@viniciusgarciaalarco Hi, how are you?

I noticed that you are setting the provider as vtex.search-graphql, and after checking I noticed that there is no “shipping” query in that app. You may have gotten confused — try switching to vtex.store-graphql and see if that works.

I hope this helped.

If this answer helped you, mark it as a solution to help others in the community.