Field 'themes' doesn't exist on type 'QueryRoot'

Hi, my app has read_themes acces. Based on this documentation shopify.dev/docs/api/admin-graphql/unstable/queries/themes?language=Remix&example=Get+first+theme you should be able to retrieve theme using graphql.

but when i query themes (simplies query from docs example) i am receiving error:
“message”: “Field ‘themes’ doesn’t exist on type ‘QueryRoot’”. That should not happen.

I also checked shopify.dev/graphiql/storefront-graphiql - there is no such query arg as themes, since then it is not found .

So how should i fetch themes ? Thanks in advance

Example of usage of themes in graphql :
Solved: graphQL: Detecting app blocks and app embed blocks ? - Shopify Community

Can you confirm you’re using the 2024-10 API version?

themes is not available in earlier versions.

Yes. now kinda works on 2024-10 . There are 2 minor problems

  1. this preview is not updated shopify.dev/graphiql/storefront-graphiql so it is missleading that themes doesnt work there but works in code
  2. wen i retrieve the information (i have read themes accesss) i am getting full response with all arguments that i need BUT i am also getting error at the end but there is no errir in query.

query

const response = await admin.graphql(#graphql query GetStoreThemes { themes(first: 10) { edges { node { files(filenames: ["config/settings_data.json"]) { edges { node { body { ... on OnlineStoreThemeFileBodyText { content } } } } } } } } })
const jsonData = await response.json()


Returnes value that has properly filled data . but also an unexpected error that has no influence on work of a query

     "headers": {},
     "errors": {
       "networkStatusCode": 200,
       "message": "GraphQL Client: An error occurred while fetching from the API. Review 'graphQLErrors'
       "graphQLErrors": [
         {
           "message": "Access denied",
           "locations": [
             {
               "line": 6,
               "column": 11
             }
           ],
           "path": [
             "themes",
             "edges",
             1,
             "node",
             "files"
           ]
         }
       ],
       "response": {}

}

an error at the end .

WHy error occures ? should it ocure ?

So to start with, the files is not available directly in the themes query so you need two queries, one to grab the first 10 themes from your store. Then you store the response with the ID’s locally, then for each ID, you grab the files that you need with the query below:

query GetThemeFileContent {
  theme(id: "gid://shopify/Theme/123456789") { # Replace with your theme ID
    id
    name
    role
    file(filename: "config/settings_data.json") {
      body {
        ... on OnlineStoreThemeFileBodyText {
          content
        }
      }
    }
  }
}

Hope this helps mate

Shopify provides multiple APIs. The URL mentioned focuses on the Storefront API, but the request you are making goes against the Admin GraphQL API. Being different APIs for different audiences, they have different features.

I am facing the same error when using direct_api_mode and sending the query through fetch to shopify:admin/api/graphql.json.

It works correctly when I run this on the server, but using direct api mode in my embedded app returns Field 'themes' doesn't exist on type 'QueryRoot'

When using shopify:admin/api/graphql.json, it currently goes against the oldest supported API version (2024-01). This API version does not have the functionality you are looking to use. You can follow this workaround to specify the API version directly:

- fetch('shopify:admin/api/graphql.json')
+ fetch('shopify:admin/api/2024-10/graphql.json')
1 Like