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

Solved
Tourist
8 0 1

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/

0 Likes

Success.

Shopify Staff
Shopify Staff
618 45 84

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,

1 Like
Shopify Partner
5 0 2

where can i get Shopify's GraphQL Schema SDL ?

0 Likes
Shopify Staff
Shopify Staff
618 45 84

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

1 Like
Tourist
8 0 1

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

0 Likes
Highlighted
Tourist
8 0 1

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

1 Like