From 7a11da42afefc3f16702dc22c6c4c548ff572ec3 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 7 Jul 2025 13:52:54 -0700 Subject: [PATCH] Some fixes --- src-web/components/GraphQLDocsExplorer.tsx | 113 ++++++++++++++------- src-web/components/Markdown.tsx | 9 +- 2 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src-web/components/GraphQLDocsExplorer.tsx b/src-web/components/GraphQLDocsExplorer.tsx index 4f4daa0a..ccc63b93 100644 --- a/src-web/components/GraphQLDocsExplorer.tsx +++ b/src-web/components/GraphQLDocsExplorer.tsx @@ -4,14 +4,14 @@ import classNames from 'classnames'; import type { GraphQLField, GraphQLInputField, GraphQLType } from 'graphql'; import { getNamedType, + isEnumType, isInputObjectType, + isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, - isEnumType, isUnionType, - isInterfaceType, } from 'graphql'; import { useAtomValue } from 'jotai'; import { ReactNode, useState } from 'react'; @@ -45,27 +45,40 @@ export function GraphQLDocsExplorer() { return (
{activeItem == null ? ( -
- Root Types - - +
+ Root Types + + All Schema Types - {Object.keys(allTypes).map((typeName) => { - const t = allTypes[typeName]!; - return ( - - ); - })} + {graphqlSchema.description ?? null} +
+ {Object.keys(allTypes).map((typeName) => { + const t = allTypes[typeName]!; + return ( + + ); + })} +
) : (
@@ -113,7 +126,7 @@ function GqlTypeInfo({ const heading = (

{name}

- {description ?? 'No description'} + {description || 'No description'}
); @@ -133,7 +146,11 @@ function GqlTypeInfo({ const fieldItem: ExplorerItem = { kind: 'field', type: field, from: item }; return (
- +
); })} @@ -182,7 +199,7 @@ function GqlTypeInfo({ {values.map((v) => (
{v.value} - {v.description ?? ''} + {v.description ?? null}
))}
@@ -204,7 +221,7 @@ function GqlTypeInfo({ {item.type.args.map((a) => (
@@ -231,7 +248,11 @@ function GqlTypeInfo({ }; return (
- +
); })} @@ -254,7 +275,11 @@ function GqlTypeInfo({ }; return (
- +
); })} @@ -274,7 +299,11 @@ function GqlTypeInfo({ const fieldItem: ExplorerItem = { kind: 'field', type: field, from: item }; return (
- +
); })} @@ -295,7 +324,7 @@ function GqlTypeRow({ hideDescription, }: { item: ExplorerItem; - name?: string; + name?: { value: string; color: Color }; description?: string | null; setItem: (t: ExplorerItem) => void; className?: string; @@ -309,12 +338,26 @@ function GqlTypeRow({ child = ( <>
- {name && {name}:}{' '} + {name && ( + + {name.value}: + + )}{' '}
{!hideDescription && ( - {(description === undefined ? getNamedType(item.type).description : description) ?? ''} + {(description === undefined ? getNamedType(item.type).description : description) ?? + null} )} @@ -329,7 +372,7 @@ function GqlTypeRow({
- {name} + {name?.value} {item.type.args.length > 0 && ( <> @@ -353,21 +396,17 @@ function GqlTypeRow({ :{' '}
- {item.type.description && ( - {item.type.description} - )} + {item.type.description ?? null}
); } else if (item.kind === 'input_field') { child = ( <>
- {name && {name}:}{' '} + {name && {name.value}:}{' '}
- {item.type.description && ( - {item.type.description} - )} + {item.type.description ?? null} ); } @@ -443,3 +482,7 @@ function GqlTypeLabel({ item, children }: { item: ExplorerItem; children?: strin function Subheading({ children }: { children: ReactNode }) { return

{children}

; } + +function Heading({ children }: { children: ReactNode }) { + return

{children}

; +} diff --git a/src-web/components/Markdown.tsx b/src-web/components/Markdown.tsx index 52d2bd00..89e9b188 100644 --- a/src-web/components/Markdown.tsx +++ b/src-web/components/Markdown.tsx @@ -3,7 +3,14 @@ import remarkGfm from 'remark-gfm'; import { ErrorBoundary } from './ErrorBoundary'; import { Prose } from './Prose'; -export function Markdown({ children, className }: { children: string; className?: string }) { +interface Props { + children: string | null; + className?: string; +} + +export function Markdown({ children, className }: Props) { + if (children == null) return null; + return (