Skip to content

Instantly share code, notes, and snippets.

@martinheld
Last active April 16, 2024 16:26
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save martinheld/9fe32b7e2c8fd932599d36e921a2a825 to your computer and use it in GitHub Desktop.
Save martinheld/9fe32b7e2c8fd932599d36e921a2a825 to your computer and use it in GitHub Desktop.
GraphQL introspection query via curl

GraphQL introspection query via curl

cat introspection_query.json

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

    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
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                  }
                }
              }
            }
          }
        }
      }
    }"
}

curl -i -X POST http://localhost:8080/graphql -H "Content-Type: application/json" -d @introspection_query.json

@iambumblehead
Copy link

agreed :) excellent

@benrowe-chuffed
Copy link

thanks!

@gajus
Copy link

gajus commented Aug 30, 2021

Is there a visual way to inspect the output?

@thorayi
Copy link

thorayi commented Aug 16, 2022

I use Visual Studio code with prettify JSON extension

@ls-pierre-charbel
Copy link

BRILLIANT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment