Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

@dhoerl
Copy link

dhoerl commented Apr 28, 2020

Excellent! Thanks!

@iambumblehead
Copy link

iambumblehead commented Mar 27, 2021

agreed :) excellent

@benrowe-chuffed
Copy link

benrowe-chuffed commented Apr 13, 2021

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

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