Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Query __schema to list all types defined in the schema and get details about each:

    Code Block
    query {
      __schema {
        types {
          name
          kind
          description
          fields {
            name
          }
        }
      }
    }
    
  • Query __type to get details about any type:

    Code Block
    query {
      __type(name: "User") {
        name
        kind
        description
        fields {
          name
        }
      }
    }
    
  • You can also run an introspection query of the schema via a GET request:

    Code Block
    $ curl -HX "POST"Authorization: Token token" https://cms.scopear.com/api/v3/graphql" \
         -H 'Authorization: Token token=<user auth token>' \
         -H 'PrivateAccessCode: Token token=PersonalAccessToken' \
         -H 'Content-Type: application/json; charset=utf-8' \
         -d $'{
    	"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}}}}}}}}",
    	"variables": {}
    }'

    The results are in JSON, so we recommend pretty-printing them for easier reading and searching. You can use a command-line tool like jq or pipe the results into python -m json.tool for this purpose.

    Note: The introspection query is probably the only GET request you'll run in GraphQL. If you're passing a body, the GraphQL request method is POST, whether it's a query or a mutation.

...