Skip to content

The result of getIntrospectionQuery does not match IntrospectionQuery type #3409

Closed
@Woodz

Description

@Woodz

getIntrospectionQuery only requests the name field from the root queryType object
(https://github.com/graphql/graphql-js/blob/6e48d16f92b9a6df8638b1486354c6be2537033b/src/utilities/getIntrospectionQuery.ts)

queryType { name }

yet the IntrospectionQuery datatype defines queryType as IntrospectionNamedTypeRef (https://github.com/graphql/graphql-js/blob/main/src/utilities/getIntrospectionQuery.ts#L167) which requires kind as well

export interface IntrospectionNamedTypeRef<
  T extends IntrospectionType = IntrospectionType,
> {
  readonly kind: T['kind'];
  readonly name: string;
}

This means that copying the result of the querying a GQL API with the introspection query as JSON and trying to assign to IntrospectionQuery will fail with:

The types of '__schema.queryType' are incompatible between these types.
Property 'kind' is missing in type '{ name: string; }' but required in type 'IntrospectionNamedTypeRef'.

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