Admin API Graphql shema endpoint

Highlighted
Excursionist
38 1 8

Hi all,

Thank you for your time reading this.

I'm using graphql codegen to fetch and generate the shopify graphql schema in JavaScript format 

    "@graphql-codegen/cli": "^1.17.7",
    "@graphql-codegen/fragment-matcher": "^1.13.2",

I'm using the generated JavaScript schema for my ApolloClient configuration:

const cache = new InMemoryCache({
  fragmentMatcher: new IntrospectionFragmentMatcher({
    introspectionQueryResultData:
    introspectionResult,
  }),
});

const client = new ApolloClient({
  fetchOptions: {
    credentials: 'include',
  },
  cache,
});

I do this so I can make GraphQL queries with fragments:

 const query = JSON.stringify({
    query: `{
      node(id: "${fullMid}") {
        ... on MediaImage {
          id
          image {
            id
          }
        }
      }
    }`,
  });

I used to fetch the shopify admin api graphql schema from this url https://xxx.myshopify.com/admin/api/2020-04/graphql.json . The last time I did this was 2 months ago.

Today I tries to fetch it and regenerate my local schema, but I got an error

image.png

 

 

 

What is the url where I can GET the Admin API graphql schema?

https://apps.shopify.com/picamaze
Animated watermarks for product images and ads
0 Likes
Highlighted
Shopify Partner
530 38 109

One way you can do this is issue an introspection query to the standard GraphQL API endpoint. And the response will be the basis of what you are looking for. See below.

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
        }
      }
    }
  }

 

0 Likes