diff --git a/.changeset/afraid-papayas-confess.md b/.changeset/afraid-papayas-confess.md new file mode 100644 index 00000000000..7c73bf4a6d6 --- /dev/null +++ b/.changeset/afraid-papayas-confess.md @@ -0,0 +1,5 @@ +--- +'@graphiql/react': patch +--- + +show all schema types in explorer diff --git a/packages/graphiql-react/src/explorer/components/schema-documentation.tsx b/packages/graphiql-react/src/explorer/components/schema-documentation.tsx index 481dc87cf67..f4eced066fc 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,26 @@ export function SchemaDocumentation(props: SchemaDocumentationProps) { )} + + {typeMap && ( +
+ {Object.values(typeMap).map(type => { + if ( + ignoreTypesInAllSchema.includes(type.name) || + type.name.startsWith('__') + ) { + 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, };