Skip to content

Commit

Permalink
feat: add all schema types in schema documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zolwiastyl committed Mar 4, 2023
1 parent da75d9e commit 5d39652
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
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,23 @@ export function SchemaDocumentation(props: SchemaDocumentationProps) {
</div>
)}
</ExplorerSection>
<ExplorerSection title="All Schema Types">
{typeMap && (
<div>
{Object.values(typeMap).map(type => {
if (ignoreTypesInAllSchema.includes(type.name)) {
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 5d39652

Please sign in to comment.