Re: Possible to import Shopify's GraphQL Schema SDL into Postman?

Solved

Possible to import Shopify's GraphQL Schema SDL into Postman?

Rusty-Dev
Tourist
8 0 5

I'd like to load the schema into Postman in order to take advantage of autocomplete. Is it available to download?

 

https://learning.getpostman.com/docs/postman/sending_api_requests/graphql/

Accepted Solution (1)

Busfox
Shopify Staff (Retired)
628 49 110

This is an accepted solution.

Hi @Rusty-Dev,

 

The fact that Postman doesn't handle introspection automatically is why I personally use Insomnia for GraphQL queries. Hopefully they add it soon!

 

If you want to import the schema into Postman, you would need to fetch the schema yourself. I found what should be the query you need, but it's from a fairly old GIST so you may need to update it if there's information missing. Many coding languages have libraries that will do this for you as well.

 

Cheers,

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 6 (6)

Busfox
Shopify Staff (Retired)
628 49 110

This is an accepted solution.

Hi @Rusty-Dev,

 

The fact that Postman doesn't handle introspection automatically is why I personally use Insomnia for GraphQL queries. Hopefully they add it soon!

 

If you want to import the schema into Postman, you would need to fetch the schema yourself. I found what should be the query you need, but it's from a fairly old GIST so you may need to update it if there's information missing. Many coding languages have libraries that will do this for you as well.

 

Cheers,

To learn more visit the Shopify Help Center or the Community Blog.

Rusty-Dev
Tourist
8 0 5

Thank you for the tips. I ended up switching to Insomnia and it's definitely easier to work with the GraphQL API.

weotch
Shopify Partner
24 0 12

Do you have any tips on getting the Shopify Storefront API Schema working with Insomnia?  When I use `https://handle.myshopify.com/api/2021-07/graphql` as the URL, I get a "Got status 415 fetching schema from ..." error in Insomnia.

Never mind, I just needed to add a `Accept:  application/json` to the headers in Insomnia

sandip001
Shopify Partner
5 0 7

where can i get Shopify's GraphQL Schema SDL ?

Busfox
Shopify Staff (Retired)
628 49 110

Hi @sandip001,

 

We don't expose it anywhere, but you can take a look at my above response for an example query that allows you to import our GQL schema. You'd fetch it by POSTing to /admin/api/the_version_you_want/graphql.json

 

Cheers

To learn more visit the Shopify Help Center or the Community Blog.

Rusty-Dev
Tourist
8 0 5

I did get introspection to work by modifying the query:

 

  query IntrospectionQuery {
    __schema {
      queryType { name }
      mutationType { name }
      subscriptionType { name }
      types {
        ...FullType
      }
      directives {
        name
        description
        args {
          ...InputValue
        }
        locations
      }
    }
  }

  fragment FullType on __Type {
    kind
    name
    description
    fields(includeDeprecated: true) {
      name
      description
      args {
        ...InputValue
      }
      type {
        ...TypeRef
      }
      isDeprecated
      deprecationReason
    }
    inputFields {
      ...InputValue
    }
    interfaces {
      ...TypeRef
    }
    enumValues(includeDeprecated: true) {
      name
      description
      isDeprecated
      deprecationReason
    }
    possibleTypes {
      ...TypeRef
    }
  }

  fragment InputValue on __InputValue {
    name
    description
    type { ...TypeRef }
    defaultValue
  }

  fragment TypeRef on __Type {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
        }
      }
    }
  }

 

Then I converted the response to SDL using this and imported into Postman:

https://www.npmjs.com/package/graphql-introspection-json-to-sdl