Skip to content

getIntrospectionQuery produces invalid query when all options are enabled #4353

@chris-ramon

Description

@chris-ramon

Actual

Currently when executing the function getIntrospectionQuery with all the options enabled to true, it does produce the following query that is invalid due the following errors: Cannot query field and Unknown argument.

const source = getIntrospectionQuery({
	descriptions: true,
	specifiedByUrl: true,
	directiveIsRepeatable: true,
	schemaDescription: true,
	inputValueDeprecation: true,
	oneOf: true,
});

The introspection query and errors result are shown above.

Expected

When executing the function getIntrospectionQuery with all options enabled to true it does produce a valid introspection query that can be used for checking all the current type system schema.

Motivation

Currently I'm building a set of CLI libraries that allows to do validations from any implementation against the GraphQL standard:

And found this issue while working in the following library: https://github.com/graphql-go/compatibility-standard-definitions

Query

query IntrospectionQuery {
      __schema {
        description
        queryType { name kind }
        mutationType { name kind }
        subscriptionType { name kind }
        types {
          ...FullType
        }
        directives {
          name
          description
          isRepeatable
          locations
          args(includeDeprecated: true) {
            ...InputValue
          }
        }
      }
    }

    fragment FullType on __Type {
      kind
      name
      description
      specifiedByURL
      isOneOf
      fields(includeDeprecated: true) {
        name
        description
        args(includeDeprecated: true) {
          ...InputValue
        }
        type {
          ...TypeRef
        }
        isDeprecated
        deprecationReason
      }
      inputFields(includeDeprecated: true) {
        ...InputValue
      }
      interfaces {
        ...TypeRef
      }
      enumValues(includeDeprecated: true) {
        name
        description
        isDeprecated
        deprecationReason
      }
      possibleTypes {
        ...TypeRef
      }
    }

    fragment InputValue on __InputValue {
      name
      description
      type { ...TypeRef }
      defaultValue
      isDeprecated
      deprecationReason
    }

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

Errors

{
  "errors": [
    {
      "message": "Cannot query field \"description\" on type \"__Schema\". Did you mean \"subscriptionType\"?",
      "locations": [
        {
          "line": 3,
          "column": 9
        }
      ]
    },
    {
      "message": "Cannot query field \"isRepeatable\" on type \"__Directive\".",
      "locations": [
        {
          "line": 13,
          "column": 11
        }
      ]
    },
    {
      "message": "Unknown argument \"includeDeprecated\" on field \"args\" of type \"__Directive\".",
      "locations": [
        {
          "line": 15,
          "column": 16
        }
      ]
    },
    {
      "message": "Cannot query field \"specifiedByURL\" on type \"__Type\".",
      "locations": [
        {
          "line": 26,
          "column": 7
        }
      ]
    },
    {
      "message": "Cannot query field \"isOneOf\" on type \"__Type\".",
      "locations": [
        {
          "line": 27,
          "column": 7
        }
      ]
    },
    {
      "message": "Unknown argument \"includeDeprecated\" on field \"args\" of type \"__Field\".",
      "locations": [
        {
          "line": 31,
          "column": 14
        }
      ]
    },
    {
      "message": "Unknown argument \"includeDeprecated\" on field \"inputFields\" of type \"__Type\".",
      "locations": [
        {
          "line": 40,
          "column": 19
        }
      ]
    },
    {
      "message": "Cannot query field \"isDeprecated\" on type \"__InputValue\".",
      "locations": [
        {
          "line": 62,
          "column": 7
        }
      ]
    },
    {
      "message": "Cannot query field \"deprecationReason\" on type \"__InputValue\".",
      "locations": [
        {
          "line": 63,
          "column": 7
        }
      ]
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions