diff --git a/.changeset/smooth-elephants-eat.md b/.changeset/smooth-elephants-eat.md new file mode 100644 index 00000000000..4dab718c11c --- /dev/null +++ b/.changeset/smooth-elephants-eat.md @@ -0,0 +1,5 @@ +--- +'graphiql': patch +--- + +Include schema description in DocExplorer for schema introspection requests. Enables the `schemaDescription` option for `getIntrospectionQuery()`. diff --git a/packages/graphiql/src/components/__tests__/DocExplorer.spec.tsx b/packages/graphiql/src/components/__tests__/DocExplorer.spec.tsx index 9317fec6603..37deba6e610 100644 --- a/packages/graphiql/src/components/__tests__/DocExplorer.spec.tsx +++ b/packages/graphiql/src/components/__tests__/DocExplorer.spec.tsx @@ -26,5 +26,8 @@ describe('DocExplorer', () => { const { container } = render(); const error = container.querySelectorAll('.error-container'); expect(error).toHaveLength(0); + expect(container.querySelector('.doc-type-description')).toHaveTextContent( + 'GraphQL Schema for testing', + ); }); }); diff --git a/packages/graphiql/src/components/__tests__/ExampleSchema.ts b/packages/graphiql/src/components/__tests__/ExampleSchema.ts index cad815b41d0..0d0d75a05ff 100644 --- a/packages/graphiql/src/components/__tests__/ExampleSchema.ts +++ b/packages/graphiql/src/components/__tests__/ExampleSchema.ts @@ -93,4 +93,5 @@ export const ExampleQuery = new GraphQLObjectType({ export const ExampleSchema = new GraphQLSchema({ query: ExampleQuery, + description: 'GraphQL Schema for testing', }); diff --git a/packages/graphiql/src/utility/introspectionQueries.ts b/packages/graphiql/src/utility/introspectionQueries.ts index 66c78b77788..ac5095c0de9 100644 --- a/packages/graphiql/src/utility/introspectionQueries.ts +++ b/packages/graphiql/src/utility/introspectionQueries.ts @@ -7,7 +7,9 @@ import { getIntrospectionQuery } from 'graphql'; -export const introspectionQuery = getIntrospectionQuery(); +export const introspectionQuery = getIntrospectionQuery({ + schemaDescription: true, +}); export const staticName = 'IntrospectionQuery'; diff --git a/packages/graphiql/test/schema.js b/packages/graphiql/test/schema.js index caa41a03c4d..0fa7a0f24dd 100644 --- a/packages/graphiql/test/schema.js +++ b/packages/graphiql/test/schema.js @@ -347,6 +347,7 @@ const myTestSchema = new GraphQLSchema({ query: TestType, mutation: TestMutationType, subscription: TestSubscriptionType, + description: 'This is a test schema for GraphiQL', }); module.exports = myTestSchema;