Search code examples
graphqlshopifygraphiql

Graphql query works in installed app but not in GraphiQL


very new to shopify and graphql i created a sample shopify shop and installed shopify graphQL app in it.

when i run this query in the installed app i get results

enter image description here

when i run the same query from the C# code or GraphiQL

i get this error

enter image description here

"Field 'inventoryItems' doesn't exist on type 'QueryRoot'"

i have headers set like this.

enter image description here


Solution

  • The GraphiQL app uses the Admin GraphQL and you are trying the StoreFront GraphQL.

    The Admin and StoreFront GraphQL are very different from one another. The admin GraphQL is used for creating/updating/deleting/outputing items from your store, but the StoreFront GraphQL is mainly used for outputting data since it's public and it will be huge security issue if could modify your store.

    Because of that both APIs have different access to different methods and there are methods that are available only for the Admin GraphQL and the other way around, there are methods only available to the StoreFront GraphQL as well.


    TL;DR inventoryItems method is not available for the Storefront GraphQL, you can access it from the Admin GraphQL.