Is there a publicly available schema for the Admin GraphQL API?

Solved

Is there a publicly available schema for the Admin GraphQL API?

IstohG
Shopify Partner
3 0 4

Does anyone know if there's a publicly-available schema of the Admin API? Or can you only access it via a store's authenticated endpoint (e.g https://<STORE>.myshopify.com/admin/api/<VERSION>/graphql.json)? 

 

I'm in a situation where my continuous integration system needs the schema to generate a client-side library at build time, and the specifics of the CI make it such that I can't pass an environment variable without making it public. Because the authentication header requires a secret key, I obviously don't want to do this. I'm wondering if this info is exposed via a public API, since Shopify exposes a publicly-browsable version of the API in the online documentation.

Accepted Solution (1)

thekwoka
Shopify Partner
12 1 4

This is an accepted solution.

ADMIN GRAPHQL SCHEMA: https://shopify.dev/admin-graphql-direct-proxy/2024-10
STOREFRONT GRAPHQL SCHEMA: https://shopify.dev/storefront-graphql-direct-proxy/2024-10

Is the latest, naturally just change the version number.

I got this from this documentation https://shopify.dev/docs/api/shopify-app-remix/v2/guide-graphql-types


View solution in original post

Replies 16 (16)

sinejoe
Shopify Partner
66 0 18

Bumping this good question for some kind of Shopify response. Many GraphQL client packages support downloading schema json and code-generating typed libraries. It sucks as part of CI to have to embed a store specific URL and auth token to download the non-secret schema. Anyone at Shopify have any insight to offer here?

bretto36
Shopify Partner
5 0 2

How are you passing the authentication to get the json? In what format and how are you getting the key?

I'm setting out to change my REST calls to graphql and it's confusing the heck out of me. 

IstohG
Shopify Partner
3 0 4

Hi @bretto36, for REST calls, you have to use the "X-Shopify-Access-Token" header in your request to pass the secret key, which you can find in your custom app's configuration page via the Shopify admin. You can reference the documentation here for an example of how to make an authenticated call. 

 

Please note, however, this question is intended to see if there's a way to retrieve the GraphQL schema without having to pass this header, so please do not mark this as an accepted solution.

thekwoka
Shopify Partner
12 1 4

This is an accepted solution.

ADMIN GRAPHQL SCHEMA: https://shopify.dev/admin-graphql-direct-proxy/2024-10
STOREFRONT GRAPHQL SCHEMA: https://shopify.dev/storefront-graphql-direct-proxy/2024-10

Is the latest, naturally just change the version number.

I got this from this documentation https://shopify.dev/docs/api/shopify-app-remix/v2/guide-graphql-types


TicoScout
Visitor
1 0 1

404 for me now

 

thekwoka
Shopify Partner
12 1 4

So, they 404 when just clicking on them. But tools that use schema introspection can read them (like `typed-graphql-builder` for typescript). A strange decision but basically Shopify doesn't accept direct navigation. 

joebow
Visitor
2 0 2

Also 404 for me. How is Shopify so bad at documentation? Deprecating the REST API, but the GraphQL API is not properly documented.

Yoon133
Shopify Partner
2 0 1

Yeah i mean most of services are easy to understand their json response or they make package or something but they seems they update endpoint quite often and regularly by the date!?!. I dont think they are making it for developers. Shopify is just for the people who want  bootstrap app.

Yoon133
Shopify Partner
2 0 1

Thinking about using different platform

thekwoka
Shopify Partner
12 1 4

So, they 404 when just clicking on them (anymore). But tools that use schema introspection can read them (like `typed-graphql-builder` for typescript). A strange decision but basically Shopify doesn't accept direct navigation. 

florentbo
Visitor
2 0 0

apollo client:download-schema types/download.graphql --endpoint=https://<your-shop>.myshopify.com/admin/api/2025-01/graphql.json --header="X-Shopify-Access-Token: <admin-access-token>"

or 

rover graph introspect https://<your-shop>.myshopify.com/admin/api/2025-01/graphql.json --header "X-Shopify-Access-Token: <your-token>" > schema.graphql
will do the job

sinejoe
Shopify Partner
66 0 18

TicoScout & Joebow: You cannot just click the link in a browser or make a simple GET request. The endpoint is a GraphQL endpoint that supports introspection queries. You might try various tools, such as https://hoppscotch.io/graphql to assist. Make sure to turn the proxy setting on for tools like Hoppscotch or the connections will likely be blocked by CORS policies.

SCR-20241226-nsln-2.png

Shailesh_-_Aten
Shopify Partner
24 0 5

These URLs worked perfectly for me in PhpStorm using the JetBrains GraphQL plugin.  Now I have autocomplete, type information, and field descriptions in my *.graphql files.

Google Shopping, Facebook, and Bing Shopping Feeds by Aten Software LLC
thekwoka
Shopify Partner
12 1 4

Some things have changed and these URLs do work, but do not work directly in the browser or with curl. Many schema introspection tools should be able to use it, like `typed-graphql-builder` for typescript

Shailesh_-_Aten
Shopify Partner
24 0 5

The reason the "URL does not work" and returns a 404 response in a normal web browser is because the URL is a GraphQL endpoint, not a static schema file (as I thought initially).  It should be called a "Schema Endpoint", not a "Schema", to avoid the confusion.

 

"Introspection - A GraphQL service supports introspection over its schema. This schema is queried using GraphQL itself, creating a powerful platform for tool-building."

Source: https://spec.graphql.org/draft/#sec-Introspection

 

I ran the command below in a terminal and it gave the expected results, which is a list of every available query in the schema:

 

curl 'https://shopify.dev/admin-graphql-direct-proxy/2024-10' -H 'Content-Type: application/json' -H 'Accept: application/json' --compressed --data-binary '{"query":"{\n\t__schema{\n queryType {\n fields{\n name\n }\n }\n }\n}"}'

 

I couldn't link directly to the source for this command, but you can find it in these search results:

https://www.google.com/search?q=How+to+Retrieve+a+GraphQL+Schema

 

Happy schema querying!

Google Shopping, Facebook, and Bing Shopping Feeds by Aten Software LLC
IstohG
Shopify Partner
3 0 4

This is perfect, thank you. For those concerned about the 404 they're seeing in the browser, please see @Shailesh_-_Aten comment below—the posted link is a GraphQL endpoint and not intended for web browsing. 

 

If you need to browse via the web, you can always go to the official documentation for the storefront: https://shopify.dev/docs/api/storefront