Repository: graphql/graphql-js (TypeScript)

Issue:
The result of `getIntrospectionQuery` does not match `IntrospectionQuery` type
`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<IntrospectionObjectType>'.
getIntrospectionQuery result does not match the IntrospectionQuery type
https://github.com/graphql/graphql-js/blob/04e948bbc4972ddeb61443fab540e03fdff457b4/src/utilities/getIntrospectionQuery.ts#L70-L72

The query needs to select `kind` for each of these in order for the result to match the defined `IntrospectionQuery` type

https://github.com/graphql/graphql-js/blob/04e948bbc4972ddeb61443fab540e03fdff457b4/src/utilities/getIntrospectionQuery.ts#L172-L178


https://github.com/graphql/graphql-js/blob/04e948bbc4972ddeb61443fab540e03fdff457b4/src/utilities/getIntrospectionQuery.ts#L293-L298


Discussion:
Bumping this.
Still seeing this issue. At the moment, chucking in a `@ts-ignore` but would be nice to have a firmer fix.

Exact same situation, passing an introspection in JSON into `buildClientSchema`. Using the very latest `graphql` at `16.4.0`.

```javascript
import * as introspectionResult from "../../../graphql.schema.json";

const schema = buildClientSchema(introspectionResult);
```

Produces the following error:
```
Argument of type '{ __schema: { queryType: { name: string; }; mutationType: { name: string; }; subscriptionType: null; types: ({ kind: string; name: string; description: string; fields: null; inputFields: null; interfaces: null; enumValues: null; possibleTypes: null; } | ... 9 more ... | { ...; })[]; directives: ({ ...; } | { ...; })...' is not assignable to parameter of type 'IntrospectionQuery'.
  The types of '__schema.queryType' are incompatible between these types.
    Property 'kind' is missing in type '{ name: string; }' but required in type 'IntrospectionNamedTypeRef<IntrospectionObjectType>'
 ```
 
 Other issues downstream in users of this library:
- https://github.com/apollographql/apollo-tooling/issues/1491
- https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34649 - this contains an incorrect fix, as it is still broken in the latest version.
Wondered if making kind option would be enough, and it creates further problems upstream.

```javascript
export interface IntrospectionNamedTypeRef<
  T extends IntrospectionType = IntrospectionType,
> {
  readonly kind?: T['kind'];
  readonly name: string;
}
```
@IvanGoncharov is it simply a matter of fixing `getIntrospectionQuery` to include `kind` as hinted at above?
Or is that silly because the kind is obvious for root types? And we need a new introspection type for root types?





Patch:
diff --git a/src/utilities/getIntrospectionQuery.ts b/src/utilities/getIntrospectionQuery.ts
index c502f0f7b4..373b474ed5 100644
--- a/src/utilities/getIntrospectionQuery.ts
+++ b/src/utilities/getIntrospectionQuery.ts
@@ -75,9 +75,9 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
     query IntrospectionQuery {
       __schema {
         ${schemaDescription}
-        queryType { name }
-        mutationType { name }
-        subscriptionType { name }
+        queryType { name kind }
+        mutationType { name kind }
+        subscriptionType { name kind }
         types {
           ...FullType
         }


Test patch:
diff --git a/src/type/__tests__/introspection-test.ts b/src/type/__tests__/introspection-test.ts
index 29994c76ed..8c5cacba0d 100644
--- a/src/type/__tests__/introspection-test.ts
+++ b/src/type/__tests__/introspection-test.ts
@@ -32,7 +32,7 @@ describe('Introspection', () => {
     expect(result).to.deep.equal({
       data: {
         __schema: {
-          queryType: { name: 'SomeObject' },
+          queryType: { name: 'SomeObject', kind: 'OBJECT' },
           mutationType: null,
           subscriptionType: null,
           types: [
diff --git a/src/utilities/__tests__/buildClientSchema-test.ts b/src/utilities/__tests__/buildClientSchema-test.ts
index d106d63a38..e8cf046921 100644
--- a/src/utilities/__tests__/buildClientSchema-test.ts
+++ b/src/utilities/__tests__/buildClientSchema-test.ts
@@ -695,7 +695,7 @@ describe('Type System: build schema from introspection', () => {
       delete introspection.__schema.queryType.name;
 
       expect(() => buildClientSchema(introspection)).to.throw(
-        'Unknown type reference: {}.',
+        'Unknown type reference: { kind: "OBJECT" }.',
       );
     });