From 5d396526af581162a7b1d4e6352a998fc2685f21 Mon Sep 17 00:00:00 2001 From: Jakub Kwiatek Date: Sat, 4 Mar 2023 13:32:27 +0100 Subject: [PATCH] feat: add all schema types in schema documentation --- .../components/schema-documentation.tsx | 23 +++++++++++++++++++ .../src/explorer/components/section.tsx | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/graphiql-react/src/explorer/components/schema-documentation.tsx b/packages/graphiql-react/src/explorer/components/schema-documentation.tsx index 481dc87cf67..f7c4da5ebdc 100644 --- a/packages/graphiql-react/src/explorer/components/schema-documentation.tsx +++ b/packages/graphiql-react/src/explorer/components/schema-documentation.tsx @@ -17,6 +17,12 @@ export function SchemaDocumentation(props: SchemaDocumentationProps) { const queryType = props.schema.getQueryType(); const mutationType = props.schema.getMutationType?.(); const subscriptionType = props.schema.getSubscriptionType?.(); + const typeMap = props.schema.getTypeMap(); + const ignoreTypesInAllSchema = [ + queryType?.name, + mutationType?.name, + subscriptionType?.name, + ]; return ( <> @@ -49,6 +55,23 @@ export function SchemaDocumentation(props: SchemaDocumentationProps) { )} + + {typeMap && ( +
+ {Object.values(typeMap).map(type => { + if (ignoreTypesInAllSchema.includes(type.name)) { + return null; + } + + return ( +
+ +
+ ); + })} +
+ )} +
); } diff --git a/packages/graphiql-react/src/explorer/components/section.tsx b/packages/graphiql-react/src/explorer/components/section.tsx index 4071889a2a1..4204d528f6f 100644 --- a/packages/graphiql-react/src/explorer/components/section.tsx +++ b/packages/graphiql-react/src/explorer/components/section.tsx @@ -33,7 +33,8 @@ type ExplorerSectionProps = { | 'Possible Types' | 'Enum Values' | 'Deprecated Enum Values' - | 'Directives'; + | 'Directives' + | 'All Schema Types'; }; export function ExplorerSection(props: ExplorerSectionProps) { @@ -64,4 +65,5 @@ const TYPE_TO_ICON: Record = { 'Possible Types': TypeIcon, 'Root Types': RootTypeIcon, Type: TypeIcon, + 'All Schema Types': TypeIcon, };