Skip to content

Commit

Permalink
feat: add all schema types in classic schema documentation (graphql#3077
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Zolwiastyl authored and Yahkob committed May 10, 2023
1 parent 50da362 commit 8683a41
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/afraid-papayas-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': patch
---

show all schema types in explorer
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -49,6 +55,26 @@ export function SchemaDocumentation(props: SchemaDocumentationProps) {
</div>
)}
</ExplorerSection>
<ExplorerSection title="All Schema Types">
{typeMap && (
<div>
{Object.values(typeMap).map(type => {
if (
ignoreTypesInAllSchema.includes(type.name) ||
type.name.startsWith('__')
) {
return null;
}

return (
<div key={type.name}>
<TypeLink type={type} />
</div>
);
})}
</div>
)}
</ExplorerSection>
</>
);
}
4 changes: 3 additions & 1 deletion packages/graphiql-react/src/explorer/components/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type ExplorerSectionProps = {
| 'Possible Types'
| 'Enum Values'
| 'Deprecated Enum Values'
| 'Directives';
| 'Directives'
| 'All Schema Types';
};

export function ExplorerSection(props: ExplorerSectionProps) {
Expand Down Expand Up @@ -64,4 +65,5 @@ const TYPE_TO_ICON: Record<ExplorerSectionProps['title'], ComponentType> = {
'Possible Types': TypeIcon,
'Root Types': RootTypeIcon,
Type: TypeIcon,
'All Schema Types': TypeIcon,
};

0 comments on commit 8683a41

Please sign in to comment.