polen 0.11.0-next.25 → 0.11.0-next.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/config/input.d.ts +183 -0
- package/build/api/config/input.d.ts.map +1 -1
- package/build/api/config/input.js +2 -0
- package/build/api/config/input.js.map +1 -1
- package/build/api/config/normalized.d.ts +297 -0
- package/build/api/config/normalized.d.ts.map +1 -1
- package/build/api/config/normalized.js +47 -0
- package/build/api/config/normalized.js.map +1 -1
- package/build/api/config-template/template.d.ts +81 -0
- package/build/api/config-template/template.d.ts.map +1 -1
- package/build/api/config-template/template.js +18 -1
- package/build/api/config-template/template.js.map +1 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +11 -0
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/schemas/catalog.d.ts +36 -0
- package/build/api/examples/schemas/catalog.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.d.ts +37 -0
- package/build/api/examples/schemas/example/example.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.js +5 -0
- package/build/api/examples/schemas/example/example.js.map +1 -1
- package/build/api/reference/$.d.ts +4 -0
- package/build/api/reference/$.d.ts.map +1 -0
- package/build/api/reference/$.js +4 -0
- package/build/api/reference/$.js.map +1 -0
- package/build/api/reference/catalog.d.ts +69 -0
- package/build/api/reference/catalog.d.ts.map +1 -0
- package/build/api/reference/catalog.js +44 -0
- package/build/api/reference/catalog.js.map +1 -0
- package/build/api/reference/config.d.ts +616 -0
- package/build/api/reference/config.d.ts.map +1 -0
- package/build/api/reference/config.js +162 -0
- package/build/api/reference/config.js.map +1 -0
- package/build/api/reference/scanner.d.ts +26 -0
- package/build/api/reference/scanner.d.ts.map +1 -0
- package/build/api/reference/scanner.js +27 -0
- package/build/api/reference/scanner.js.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts +11 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.js +20 -0
- package/build/lib/grafaid/schema/format-default-value.js.map +1 -0
- package/build/lib/grafaid/schema/schema.d.ts +1 -0
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -0
- package/build/lib/grafaid/schema/schema.js.map +1 -1
- package/build/template/components/ArgumentAnnotation.d.ts +2 -1
- package/build/template/components/ArgumentAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentAnnotation.js +14 -4
- package/build/template/components/ArgumentAnnotation.js.map +1 -1
- package/build/template/components/ArgumentListAnnotation.d.ts +1 -0
- package/build/template/components/ArgumentListAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentListAnnotation.js +21 -8
- package/build/template/components/ArgumentListAnnotation.js.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.d.ts.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.js +0 -1
- package/build/template/components/Changelog/groups/FieldArgument.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -1
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/Description.js +1 -1
- package/build/template/components/Description.js.map +1 -1
- package/build/template/components/ExampleLink.d.ts.map +1 -1
- package/build/template/components/ExampleLink.js +2 -1
- package/build/template/components/ExampleLink.js.map +1 -1
- package/build/template/components/Field.d.ts +2 -0
- package/build/template/components/Field.d.ts.map +1 -1
- package/build/template/components/Field.js +42 -4
- package/build/template/components/Field.js.map +1 -1
- package/build/template/components/FieldList.d.ts +2 -1
- package/build/template/components/FieldList.d.ts.map +1 -1
- package/build/template/components/FieldList.js +14 -3
- package/build/template/components/FieldList.js.map +1 -1
- package/build/template/components/FieldListSection.d.ts.map +1 -1
- package/build/template/components/FieldListSection.js +6 -1
- package/build/template/components/FieldListSection.js.map +1 -1
- package/build/template/components/GraphQLDocument.d.ts.map +1 -1
- package/build/template/components/GraphQLDocument.js +2 -1
- package/build/template/components/GraphQLDocument.js.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts +2 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js +4 -3
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts +2 -2
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +17 -12
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/IAPIndicator.d.ts +12 -0
- package/build/template/components/IAPIndicator.d.ts.map +1 -0
- package/build/template/components/IAPIndicator.js +21 -0
- package/build/template/components/IAPIndicator.js.map +1 -0
- package/build/template/components/Link.d.ts +1 -2
- package/build/template/components/Link.d.ts.map +1 -1
- package/build/template/components/Link.js +5 -2
- package/build/template/components/Link.js.map +1 -1
- package/build/template/components/NamedType.d.ts.map +1 -1
- package/build/template/components/NamedType.js +9 -5
- package/build/template/components/NamedType.js.map +1 -1
- package/build/template/components/ReferenceLink.d.ts +2 -2
- package/build/template/components/ReferenceLink.d.ts.map +1 -1
- package/build/template/components/ReferenceLink.js +5 -3
- package/build/template/components/ReferenceLink.js.map +1 -1
- package/build/template/components/TypeAnnotation.d.ts +2 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +4 -4
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/ViewModeToggle.d.ts +3 -0
- package/build/template/components/ViewModeToggle.d.ts.map +1 -0
- package/build/template/components/ViewModeToggle.js +9 -0
- package/build/template/components/ViewModeToggle.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts +2 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +15 -3
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/components/home/PlaygroundPreview.d.ts.map +1 -1
- package/build/template/components/home/PlaygroundPreview.js +3 -2
- package/build/template/components/home/PlaygroundPreview.js.map +1 -1
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.js +18 -5
- package/build/template/components/sidebar/SidebarItem.js.map +1 -1
- package/build/template/contexts/ReferenceConfigContext.d.ts +16 -0
- package/build/template/contexts/ReferenceConfigContext.d.ts.map +1 -0
- package/build/template/contexts/ReferenceConfigContext.js +14 -0
- package/build/template/contexts/ReferenceConfigContext.js.map +1 -0
- package/build/template/contexts/ViewModeContext.d.ts +14 -0
- package/build/template/contexts/ViewModeContext.d.ts.map +1 -0
- package/build/template/contexts/ViewModeContext.js +40 -0
- package/build/template/contexts/ViewModeContext.js.map +1 -0
- package/build/template/hooks/use-examples.d.ts +3 -0
- package/build/template/hooks/use-examples.d.ts.map +1 -1
- package/build/template/hooks/useAlignedColumns.d.ts +10 -0
- package/build/template/hooks/useAlignedColumns.d.ts.map +1 -0
- package/build/template/hooks/useAlignedColumns.js +17 -0
- package/build/template/hooks/useAlignedColumns.js.map +1 -0
- package/build/template/routes/examples/_.d.ts +9 -0
- package/build/template/routes/examples/_.d.ts.map +1 -1
- package/build/template/routes/examples/_index.d.ts +6 -0
- package/build/template/routes/examples/_index.d.ts.map +1 -1
- package/build/template/routes/examples/name.d.ts +9 -0
- package/build/template/routes/examples/name.d.ts.map +1 -1
- package/build/template/routes/examples/name.js +6 -2
- package/build/template/routes/examples/name.js.map +1 -1
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +37 -10
- package/build/template/routes/reference.js.map +1 -1
- package/build/vite/plugins/core.d.ts.map +1 -1
- package/build/vite/plugins/core.js +6 -0
- package/build/vite/plugins/core.js.map +1 -1
- package/build/vite/plugins/examples.d.ts.map +1 -1
- package/build/vite/plugins/examples.js +10 -1
- package/build/vite/plugins/examples.js.map +1 -1
- package/build/vite/plugins/index.d.ts +1 -0
- package/build/vite/plugins/index.d.ts.map +1 -1
- package/build/vite/plugins/index.js +1 -0
- package/build/vite/plugins/index.js.map +1 -1
- package/build/vite/plugins/navbar.d.ts.map +1 -1
- package/build/vite/plugins/navbar.js +3 -1
- package/build/vite/plugins/navbar.js.map +1 -1
- package/build/vite/plugins/reference.d.ts +19 -0
- package/build/vite/plugins/reference.d.ts.map +1 -0
- package/build/vite/plugins/reference.js +96 -0
- package/build/vite/plugins/reference.js.map +1 -0
- package/package.json +1 -1
- package/src/api/config/input.ts +2 -0
- package/src/api/config/normalized.ts +54 -0
- package/src/api/config-template/template.ts +18 -1
- package/src/api/examples/scanner.ts +14 -0
- package/src/api/examples/schemas/example/example.ts +6 -0
- package/src/api/reference/$.ts +3 -0
- package/src/api/reference/catalog.ts +55 -0
- package/src/api/reference/config.ts +193 -0
- package/src/api/reference/scanner.ts +53 -0
- package/src/lib/grafaid/schema/format-default-value.ts +22 -0
- package/src/lib/grafaid/schema/schema.ts +2 -0
- package/src/template/components/ArgumentAnnotation.tsx +58 -9
- package/src/template/components/ArgumentListAnnotation.tsx +50 -17
- package/src/template/components/Changelog/groups/FieldArgument.tsx +0 -1
- package/src/template/components/CodeBlock.tsx +1 -0
- package/src/template/components/Description.tsx +1 -1
- package/src/template/components/ExampleLink.tsx +2 -1
- package/src/template/components/Field.tsx +148 -20
- package/src/template/components/FieldList.tsx +28 -13
- package/src/template/components/FieldListSection.tsx +12 -2
- package/src/template/components/GraphQLDocument.tsx +2 -0
- package/src/template/components/GraphQLInteractive/GraphQLInteractive.tsx +6 -1
- package/src/template/components/GraphQLInteractive/lib/parser.ts +16 -3
- package/src/template/components/IAPIndicator.tsx +73 -0
- package/src/template/components/Link.tsx +9 -3
- package/src/template/components/NamedType.tsx +54 -28
- package/src/template/components/ReferenceLink.tsx +16 -10
- package/src/template/components/TypeAnnotation.tsx +17 -5
- package/src/template/components/ViewModeToggle.tsx +27 -0
- package/src/template/components/graphql/type-link.tsx +34 -3
- package/src/template/components/home/PlaygroundPreview.tsx +3 -0
- package/src/template/components/sidebar/SidebarItem.tsx +21 -5
- package/src/template/contexts/ReferenceConfigContext.tsx +37 -0
- package/src/template/contexts/ViewModeContext.tsx +64 -0
- package/src/template/hooks/useAlignedColumns.ts +19 -0
- package/src/template/routes/examples/name.tsx +13 -1
- package/src/template/routes/reference.tsx +67 -23
- package/src/types/virtual-modules.d.ts +5 -0
- package/src/vite/plugins/core.ts +6 -0
- package/src/vite/plugins/examples.ts +12 -0
- package/src/vite/plugins/index.ts +1 -0
- package/src/vite/plugins/navbar.ts +4 -1
- package/src/vite/plugins/reference.ts +130 -0
- package/build/template/components/ArgumentList.d.ts +0 -6
- package/build/template/components/ArgumentList.d.ts.map +0 -1
- package/build/template/components/ArgumentList.js +0 -9
- package/build/template/components/ArgumentList.js.map +0 -1
- package/src/template/components/ArgumentList.tsx +0 -22
@@ -1,34 +1,67 @@
|
|
1
|
+
import { Grafaid } from '#lib/grafaid'
|
1
2
|
import { GrafaidOld } from '#lib/grafaid-old'
|
2
|
-
import { Box,
|
3
|
-
import type { GraphQLField } from 'graphql'
|
3
|
+
import { Box, Flex } from '@radix-ui/themes'
|
4
|
+
import type { GraphQLArgument, GraphQLField } from 'graphql'
|
4
5
|
import type { FC } from 'react'
|
6
|
+
import { useAlignedColumns } from '../hooks/useAlignedColumns.js'
|
5
7
|
import { ArgumentAnnotation } from './ArgumentAnnotation.js'
|
6
|
-
import {
|
8
|
+
import { IAPIndicator } from './IAPIndicator.js'
|
7
9
|
|
8
10
|
export interface Props {
|
9
11
|
field: GraphQLField<any, any>
|
12
|
+
argumentNameWidth?: number
|
10
13
|
}
|
11
14
|
|
12
|
-
export const ArgumentListAnnotation: FC<Props> = ({ field }) => {
|
15
|
+
export const ArgumentListAnnotation: FC<Props> = ({ field, argumentNameWidth }) => {
|
13
16
|
if (field.args.length === 0) return null
|
14
17
|
|
15
18
|
const inputObject = GrafaidOld.getIAP(field)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
|
20
|
+
// If it's IAP, show indicator and input object's fields directly
|
21
|
+
if (inputObject) {
|
22
|
+
const inputFields = Grafaid.Schema.NodesLike.getFields(inputObject)
|
23
|
+
const nameWidth = argumentNameWidth ?? useAlignedColumns(inputFields, field => field.name)
|
24
|
+
|
25
|
+
return (
|
26
|
+
<Box>
|
27
|
+
<Flex direction='column' gap='2'>
|
28
|
+
{/* Small IAP indicator */}
|
29
|
+
<Box ml='3'>
|
30
|
+
<IAPIndicator inputObject={inputObject} />
|
31
|
+
</Box>
|
32
|
+
|
33
|
+
{/* Show input object fields directly without header */}
|
34
|
+
{inputFields.map(field => (
|
35
|
+
<Box key={field.name} ml='3'>
|
36
|
+
<ArgumentAnnotation
|
37
|
+
data={{
|
38
|
+
name: field.name,
|
39
|
+
type: field.type,
|
40
|
+
description: field.description,
|
41
|
+
defaultValue: (field as any).defaultValue,
|
42
|
+
deprecationReason: (field as any).deprecationReason,
|
43
|
+
} as GraphQLArgument}
|
44
|
+
nameWidth={nameWidth}
|
45
|
+
/>
|
46
|
+
</Box>
|
47
|
+
))}
|
48
|
+
</Flex>
|
20
49
|
</Box>
|
21
50
|
)
|
22
|
-
|
51
|
+
}
|
52
|
+
|
53
|
+
// Regular non-IAP arguments
|
54
|
+
const nameWidth = argumentNameWidth ?? useAlignedColumns([...field.args], arg => arg.name)
|
23
55
|
|
24
56
|
return (
|
25
|
-
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
57
|
+
<Box>
|
58
|
+
<Flex direction='column' gap='2'>
|
59
|
+
{field.args.map(arg => (
|
60
|
+
<Box key={arg.name} ml='3'>
|
61
|
+
<ArgumentAnnotation data={arg} nameWidth={nameWidth} />
|
62
|
+
</Box>
|
63
|
+
))}
|
64
|
+
</Flex>
|
65
|
+
</Box>
|
33
66
|
)
|
34
67
|
}
|
@@ -25,6 +25,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({ codeblock, schema }) => {
|
|
25
25
|
codeblock={codeblock}
|
26
26
|
schema={schema}
|
27
27
|
showWarningIfNoSchema={templateConfig.warnings.interactiveWithoutSchema.enabled}
|
28
|
+
referenceEnabled={templateConfig.reference.enabled}
|
28
29
|
/>
|
29
30
|
)
|
30
31
|
}
|
@@ -9,7 +9,7 @@ export const Description: React.FC<{ data: GraphQLNamedType | GrafaidOld.GraphQL
|
|
9
9
|
if (!data.description) return null
|
10
10
|
|
11
11
|
return (
|
12
|
-
<Text as='div' color='gray'>
|
12
|
+
<Text as='div' size='2' color='gray' style={{ lineHeight: '1.5' }}>
|
13
13
|
<Markdown>{data.description}</Markdown>
|
14
14
|
</Text>
|
15
15
|
)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { ExampleReference } from '#api/examples/schemas/type-usage-index'
|
2
2
|
import { Version } from '#lib/version/$'
|
3
3
|
import { Badge, Link } from '@radix-ui/themes'
|
4
|
+
import { Str } from '@wollybeard/kit'
|
4
5
|
import type { FC } from 'react'
|
5
6
|
|
6
7
|
export interface Props {
|
@@ -20,7 +21,7 @@ export const ExampleLink: FC<Props> = ({ exampleRef }) => {
|
|
20
21
|
return (
|
21
22
|
<Link href={href} style={{ textDecoration: 'none' }}>
|
22
23
|
<Badge variant='soft' size='2' style={{ cursor: 'pointer' }}>
|
23
|
-
{exampleRef.name}
|
24
|
+
{Str.titlizeSlug(exampleRef.name)}
|
24
25
|
</Badge>
|
25
26
|
</Link>
|
26
27
|
)
|
@@ -3,8 +3,11 @@ import type { React } from '#dep/react/index'
|
|
3
3
|
import { GrafaidOld } from '#lib/grafaid-old'
|
4
4
|
import { Lifecycles } from '#lib/lifecycles/$'
|
5
5
|
import type { BoxProps } from '@radix-ui/themes'
|
6
|
-
import { Badge, Box, Text } from '@radix-ui/themes'
|
6
|
+
import { Badge, Box, Card, Flex, HoverCard, Link, Text } from '@radix-ui/themes'
|
7
|
+
import { isNonNullType } from 'graphql'
|
7
8
|
import { useSchema } from '../contexts/GraphqlLifecycleContext.js'
|
9
|
+
import { useReferenceConfig } from '../contexts/ReferenceConfigContext.js'
|
10
|
+
import { useViewMode } from '../contexts/ViewModeContext.js'
|
8
11
|
import { ArgumentListAnnotation } from './ArgumentListAnnotation.js'
|
9
12
|
import { DeprecationReason } from './DeprecationReason.js'
|
10
13
|
import { Description } from './Description.js'
|
@@ -15,14 +18,23 @@ export const Field: React.FC<
|
|
15
18
|
BoxProps & {
|
16
19
|
data: GrafaidOld.GraphQLField
|
17
20
|
parentTypeName?: string
|
21
|
+
fieldNameWidth?: number
|
22
|
+
argumentNameWidth?: number
|
18
23
|
}
|
19
|
-
> = ({ data, parentTypeName, ...boxProps }) => {
|
24
|
+
> = ({ data, parentTypeName, fieldNameWidth, argumentNameWidth, ...boxProps }) => {
|
20
25
|
const { schema, lifecycles } = useSchema()
|
26
|
+
const { viewMode } = useViewMode()
|
27
|
+
const referenceConfig = useReferenceConfig()
|
21
28
|
|
22
29
|
const argumentList = GrafaidOld.isOutputField(data)
|
23
|
-
?
|
30
|
+
? argumentNameWidth !== undefined
|
31
|
+
? <ArgumentListAnnotation field={data} argumentNameWidth={argumentNameWidth} />
|
32
|
+
: <ArgumentListAnnotation field={data} />
|
24
33
|
: null
|
25
34
|
|
35
|
+
// Check if the field is nullable (for questionMark mode)
|
36
|
+
const isFieldNullable = !isNonNullType(data.type)
|
37
|
+
|
26
38
|
// Get field lifecycle information if available
|
27
39
|
const since = parentTypeName
|
28
40
|
? Lifecycles.getFieldSince(lifecycles, parentTypeName, data.name, schema)
|
@@ -31,24 +43,140 @@ export const Field: React.FC<
|
|
31
43
|
? Lifecycles.getFieldRemovedDate(lifecycles, parentTypeName, data.name, schema)
|
32
44
|
: null
|
33
45
|
|
46
|
+
// Only show since badge if it's NOT the initial version
|
47
|
+
const showSinceBadge = since && since._tag !== 'initial'
|
48
|
+
|
34
49
|
return (
|
35
|
-
<
|
36
|
-
|
50
|
+
<Card
|
51
|
+
{...boxProps}
|
52
|
+
variant='ghost'
|
53
|
+
id={data.name}
|
54
|
+
style={{ overflow: 'visible' }}
|
55
|
+
>
|
56
|
+
{/* Field name and return type with aligned columns */}
|
57
|
+
<style>
|
58
|
+
{`
|
59
|
+
.field-name-anchor {
|
60
|
+
position: absolute;
|
61
|
+
left: 0;
|
62
|
+
top: 50%;
|
63
|
+
transform: translateY(-50%) translateX(0);
|
64
|
+
opacity: 0;
|
65
|
+
transition: all 0.2s ease-in-out;
|
66
|
+
pointer-events: none;
|
67
|
+
z-index: 10;
|
68
|
+
}
|
69
|
+
|
70
|
+
.field-name-wrapper:hover .field-name-anchor {
|
71
|
+
transform: translateY(-50%) translateX(-24px);
|
72
|
+
opacity: 1;
|
73
|
+
pointer-events: auto;
|
74
|
+
}
|
75
|
+
`}
|
76
|
+
</style>
|
77
|
+
<Flex align='baseline' mb='2' gap='2'>
|
78
|
+
<Box
|
79
|
+
className='field-name-wrapper'
|
80
|
+
style={{
|
81
|
+
minWidth: fieldNameWidth ? `${fieldNameWidth}ch` : 'auto',
|
82
|
+
flexShrink: 0,
|
83
|
+
position: 'relative',
|
84
|
+
}}
|
85
|
+
>
|
86
|
+
{/* Anchor icon that slides left on hover */}
|
87
|
+
<Link
|
88
|
+
className='field-name-anchor'
|
89
|
+
href={`#${data.name}`}
|
90
|
+
color='gray'
|
91
|
+
style={{
|
92
|
+
textDecoration: 'none',
|
93
|
+
display: 'inline-flex',
|
94
|
+
alignItems: 'center',
|
95
|
+
}}
|
96
|
+
>
|
97
|
+
<Text size='3' color='gray'>
|
98
|
+
#
|
99
|
+
</Text>
|
100
|
+
</Link>
|
101
|
+
{viewMode === 'compact' && data.description
|
102
|
+
? (
|
103
|
+
<HoverCard.Root>
|
104
|
+
<HoverCard.Trigger>
|
105
|
+
<Link
|
106
|
+
href={`#${data.name}`}
|
107
|
+
color='gray'
|
108
|
+
underline='hover'
|
109
|
+
style={{ textDecoration: 'none', display: 'inline-block' }}
|
110
|
+
>
|
111
|
+
<Text size='3' weight='bold'>
|
112
|
+
{data.name}
|
113
|
+
{referenceConfig.nullabilityRendering === 'questionMark' && isFieldNullable && '?'}
|
114
|
+
</Text>
|
115
|
+
</Link>
|
116
|
+
</HoverCard.Trigger>
|
117
|
+
<HoverCard.Content
|
118
|
+
size='2'
|
119
|
+
maxWidth='400px'
|
120
|
+
side='top'
|
121
|
+
align='center'
|
122
|
+
>
|
123
|
+
<Text size='2' color='gray'>
|
124
|
+
<Description data={data} />
|
125
|
+
</Text>
|
126
|
+
</HoverCard.Content>
|
127
|
+
</HoverCard.Root>
|
128
|
+
)
|
129
|
+
: (
|
130
|
+
<Link
|
131
|
+
href={`#${data.name}`}
|
132
|
+
color='gray'
|
133
|
+
underline='hover'
|
134
|
+
style={{ textDecoration: 'none', display: 'inline-block' }}
|
135
|
+
>
|
136
|
+
<Text size='3' weight='bold'>
|
137
|
+
{data.name}
|
138
|
+
{referenceConfig.nullabilityRendering === 'questionMark' && isFieldNullable && '?'}
|
139
|
+
</Text>
|
140
|
+
</Link>
|
141
|
+
)}
|
142
|
+
</Box>
|
143
|
+
<TypeAnnotation
|
144
|
+
type={data.type}
|
145
|
+
showDescription={true}
|
146
|
+
nullabilityRendering={referenceConfig.nullabilityRendering}
|
147
|
+
/>
|
148
|
+
</Flex>
|
149
|
+
|
150
|
+
{/* Badges below the header line */}
|
151
|
+
{(showSinceBadge || removedDate) && (
|
152
|
+
<Flex gap='2' mb='2'>
|
153
|
+
{showSinceBadge && <SinceBadge since={since} />}
|
154
|
+
{removedDate && (
|
155
|
+
<Badge color='red' variant='soft' size='1'>
|
156
|
+
Removed {Api.Schema.dateToVersionString(removedDate)}
|
157
|
+
</Badge>
|
158
|
+
)}
|
159
|
+
</Flex>
|
160
|
+
)}
|
161
|
+
|
162
|
+
{/* Description below title (only in expanded mode) */}
|
163
|
+
{data.description && viewMode === 'expanded' && (
|
164
|
+
<Box mb='2'>
|
165
|
+
<Text size='2' color='gray' style={{ lineHeight: '1.5' }}>
|
166
|
+
<Description data={data} />
|
167
|
+
</Text>
|
168
|
+
</Box>
|
169
|
+
)}
|
170
|
+
|
171
|
+
{/* Deprecation reason if exists */}
|
37
172
|
<DeprecationReason data={data} />
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
</Box>
|
47
|
-
<Text>
|
48
|
-
{argumentList}
|
49
|
-
:{` `}
|
50
|
-
<TypeAnnotation type={data.type} />
|
51
|
-
</Text>
|
52
|
-
</Box>
|
173
|
+
|
174
|
+
{/* Arguments section below, with left border - only show if field has arguments */}
|
175
|
+
{argumentList && GrafaidOld.isOutputField(data) && data.args.length > 0 && (
|
176
|
+
<Box mt='2' ml='3' pl='3' style={{ borderLeft: '2px solid var(--gray-4)' }}>
|
177
|
+
{argumentList}
|
178
|
+
</Box>
|
179
|
+
)}
|
180
|
+
</Card>
|
53
181
|
)
|
54
182
|
}
|
@@ -1,29 +1,44 @@
|
|
1
1
|
import { Grafaid } from '#lib/grafaid'
|
2
|
-
import {
|
3
|
-
import
|
2
|
+
import { GrafaidOld } from '#lib/grafaid-old'
|
3
|
+
import { Box, Flex } from '@radix-ui/themes'
|
4
|
+
import { type FC } from 'react'
|
5
|
+
import { useAlignedColumns } from '../hooks/useAlignedColumns.js'
|
4
6
|
import { Field } from './Field.js'
|
5
7
|
|
6
8
|
export interface Props {
|
7
9
|
data: Grafaid.Schema.TypesLike.Named
|
8
10
|
parentTypeName?: string
|
11
|
+
argumentNameWidth?: number
|
9
12
|
}
|
10
13
|
|
11
|
-
export const FieldList: FC<Props> = ({ data, parentTypeName }) => {
|
14
|
+
export const FieldList: FC<Props> = ({ data, parentTypeName, argumentNameWidth }) => {
|
12
15
|
if (!Grafaid.Schema.TypesLike.isFielded(data)) return null
|
13
16
|
|
14
17
|
const fields = Grafaid.Schema.NodesLike.getFields(data)
|
15
18
|
if (fields.length === 0) return null
|
16
19
|
|
20
|
+
// Calculate the maximum field name length for alignment using shared hook
|
21
|
+
const fieldNameWidth = useAlignedColumns(fields, field => field.name)
|
22
|
+
|
17
23
|
return (
|
18
|
-
<
|
19
|
-
{fields.map(field =>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
<Flex direction='column'>
|
25
|
+
{fields.map((field, index) => {
|
26
|
+
// Check if this field has arguments
|
27
|
+
const hasArguments = GrafaidOld.isOutputField(field) && field.args.length > 0
|
28
|
+
// Add extra spacing after fields with arguments
|
29
|
+
const marginBottom = hasArguments ? '5' : '3'
|
30
|
+
|
31
|
+
return (
|
32
|
+
<Box key={field.name} mb={index < fields.length - 1 ? marginBottom : '0'}>
|
33
|
+
<Field
|
34
|
+
data={field}
|
35
|
+
parentTypeName={parentTypeName ?? data.name}
|
36
|
+
fieldNameWidth={fieldNameWidth}
|
37
|
+
{...(argumentNameWidth !== undefined ? { argumentNameWidth } : {})}
|
38
|
+
/>
|
39
|
+
</Box>
|
40
|
+
)
|
41
|
+
})}
|
42
|
+
</Flex>
|
28
43
|
)
|
29
44
|
}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import type { React } from '#dep/react/index'
|
2
2
|
import { Grafaid } from '#lib/grafaid'
|
3
|
+
import { GrafaidOld } from '#lib/grafaid-old'
|
3
4
|
import { Box, Heading } from '@radix-ui/themes'
|
4
5
|
import type { GraphQLNamedType } from 'graphql'
|
6
|
+
import { useAlignedColumns } from '../hooks/useAlignedColumns.js'
|
5
7
|
import { FieldList } from './FieldList.js'
|
6
8
|
|
7
9
|
export const FieldListSection: React.FC<{ data: GraphQLNamedType }> = ({ data }) => {
|
@@ -10,10 +12,18 @@ export const FieldListSection: React.FC<{ data: GraphQLNamedType }> = ({ data })
|
|
10
12
|
const fields = Grafaid.Schema.NodesLike.getFields(data)
|
11
13
|
if (fields.length === 0) return null
|
12
14
|
|
15
|
+
// Calculate the maximum argument name width across ALL fields of this type
|
16
|
+
const allArguments = fields.flatMap(field => GrafaidOld.isOutputField(field) ? field.args : [])
|
17
|
+
const argumentNameWidth = useAlignedColumns(allArguments, arg => arg.name)
|
18
|
+
|
13
19
|
return (
|
14
20
|
<Box>
|
15
|
-
<Heading>Fields</Heading>
|
16
|
-
<FieldList
|
21
|
+
<Heading size='5' mb='4' weight='medium'>Fields</Heading>
|
22
|
+
<FieldList
|
23
|
+
data={data}
|
24
|
+
parentTypeName={data.name}
|
25
|
+
argumentNameWidth={argumentNameWidth}
|
26
|
+
/>
|
17
27
|
</Box>
|
18
28
|
)
|
19
29
|
}
|
@@ -3,6 +3,7 @@ import { Document } from '#lib/document/$'
|
|
3
3
|
import { VersionCoverage } from '#lib/version-coverage'
|
4
4
|
import { Either, Option } from 'effect'
|
5
5
|
import * as React from 'react'
|
6
|
+
import { templateConfig } from 'virtual:polen/project/config'
|
6
7
|
import { useHighlighted } from '../hooks/use-highlighted.js'
|
7
8
|
import { GraphQLInteractive } from './GraphQLInteractive/GraphQLInteractive.js'
|
8
9
|
import { VersionCoveragePicker } from './VersionCoveragePicker.js'
|
@@ -72,6 +73,7 @@ export const GraphQLDocument: React.FC<GraphQLDocumentProps> = ({
|
|
72
73
|
<GraphQLInteractive
|
73
74
|
codeblock={highlightedCode}
|
74
75
|
schema={schema?.definition}
|
76
|
+
referenceEnabled={templateConfig.reference.enabled}
|
75
77
|
style={style}
|
76
78
|
toolbar={() => (
|
77
79
|
showVersionCoveragePicker && selectedVersionCoverage && (
|
@@ -29,6 +29,9 @@ interface GraphQLInteractiveProps {
|
|
29
29
|
/** Whether to show a warning indicator when schema is missing */
|
30
30
|
showWarningIfNoSchema?: boolean | undefined
|
31
31
|
|
32
|
+
/** Whether reference documentation is enabled (controls if types link to reference) */
|
33
|
+
referenceEnabled?: boolean | undefined
|
34
|
+
|
32
35
|
/** Optional toolbar component to render (e.g., version picker) */
|
33
36
|
toolbar?: () => React.ReactNode
|
34
37
|
|
@@ -53,6 +56,7 @@ const GraphQLInteractiveImpl: React.FC<GraphQLInteractiveProps> = ({
|
|
53
56
|
codeblock,
|
54
57
|
schema,
|
55
58
|
showWarningIfNoSchema = true,
|
59
|
+
referenceEnabled = true,
|
56
60
|
toolbar,
|
57
61
|
style,
|
58
62
|
}) => {
|
@@ -86,6 +90,7 @@ const GraphQLInteractiveImpl: React.FC<GraphQLInteractiveProps> = ({
|
|
86
90
|
codeblock.code,
|
87
91
|
codeblock.annotations,
|
88
92
|
schema, // Pass the schema for semantic analysis
|
93
|
+
referenceEnabled, // Pass reference enabled flag for link generation
|
89
94
|
)
|
90
95
|
|
91
96
|
setTokens(parsedTokens)
|
@@ -98,7 +103,7 @@ const GraphQLInteractiveImpl: React.FC<GraphQLInteractiveProps> = ({
|
|
98
103
|
} finally {
|
99
104
|
setIsLoading(false)
|
100
105
|
}
|
101
|
-
}, [codeblock.code, codeblock.annotations, schema])
|
106
|
+
}, [codeblock.code, codeblock.annotations, schema, referenceEnabled])
|
102
107
|
|
103
108
|
// Retry function for users
|
104
109
|
const handleRetry = ReactHooks.useCallback(() => {
|
@@ -109,11 +109,13 @@ class UnifiedToken implements GraphQLToken {
|
|
109
109
|
private _start: number
|
110
110
|
private _end: number
|
111
111
|
private _nodeType: TreeSitterGraphQLNodeType
|
112
|
+
private _referenceEnabled: boolean
|
112
113
|
|
113
114
|
constructor(
|
114
115
|
public treeSitterNode: WebTreeSitter.Node,
|
115
116
|
public semantic: SemanticNode | undefined,
|
116
117
|
annotations: CodeAnnotation[],
|
118
|
+
referenceEnabled = true,
|
117
119
|
) {
|
118
120
|
// Cache the values immediately to avoid WASM access issues later
|
119
121
|
// This works for both real WebTreeSitter nodes and synthetic nodes
|
@@ -121,6 +123,7 @@ class UnifiedToken implements GraphQLToken {
|
|
121
123
|
this._start = treeSitterNode.startIndex
|
122
124
|
this._end = treeSitterNode.endIndex
|
123
125
|
this._nodeType = treeSitterNode.type as TreeSitterGraphQLNodeType
|
126
|
+
this._referenceEnabled = referenceEnabled
|
124
127
|
|
125
128
|
this.codeHike = { annotations }
|
126
129
|
|
@@ -255,6 +258,8 @@ class UnifiedToken implements GraphQLToken {
|
|
255
258
|
}
|
256
259
|
|
257
260
|
private _getReferenceUrl(): string | null {
|
261
|
+
// If reference is disabled, don't generate URLs
|
262
|
+
if (!this._referenceEnabled) return null
|
258
263
|
if (!this.semantic) return null
|
259
264
|
|
260
265
|
// Arguments - use #<field>__<argument> pattern
|
@@ -536,6 +541,7 @@ export async function parseGraphQLWithTreeSitterEither(
|
|
536
541
|
code: string,
|
537
542
|
annotations: CodeAnnotation[] = [],
|
538
543
|
schema?: GraphQLSchema,
|
544
|
+
referenceEnabled = true,
|
539
545
|
): Promise<Either.Either<GraphQLToken[], ParseError>> {
|
540
546
|
// Validate input
|
541
547
|
if (!code || typeof code !== 'string') {
|
@@ -566,10 +572,10 @@ export async function parseGraphQLWithTreeSitterEither(
|
|
566
572
|
|
567
573
|
try {
|
568
574
|
// Step 2: Walk tree and attach semantics
|
569
|
-
const tokens = collectTokensWithSemantics(tree, code, schema, annotations)
|
575
|
+
const tokens = collectTokensWithSemantics(tree, code, schema, annotations, referenceEnabled)
|
570
576
|
|
571
577
|
// Step 3: Add error hint tokens after invalid fields
|
572
|
-
const tokensWithHints = addErrorHintTokens(tokens, code, annotations)
|
578
|
+
const tokensWithHints = addErrorHintTokens(tokens, code, annotations, referenceEnabled)
|
573
579
|
|
574
580
|
return Either.right(tokensWithHints)
|
575
581
|
} catch (error) {
|
@@ -595,8 +601,9 @@ export async function parseGraphQLWithTreeSitter(
|
|
595
601
|
code: string,
|
596
602
|
annotations: CodeAnnotation[] = [],
|
597
603
|
schema?: GraphQLSchema,
|
604
|
+
referenceEnabled = true,
|
598
605
|
): Promise<GraphQLToken[]> {
|
599
|
-
const result = await parseGraphQLWithTreeSitterEither(code, annotations, schema)
|
606
|
+
const result = await parseGraphQLWithTreeSitterEither(code, annotations, schema, referenceEnabled)
|
600
607
|
|
601
608
|
if (Either.isLeft(result)) {
|
602
609
|
const error = result.left
|
@@ -714,6 +721,7 @@ function addErrorHintTokens(
|
|
714
721
|
tokens: GraphQLToken[],
|
715
722
|
code: string,
|
716
723
|
annotations: CodeAnnotation[],
|
724
|
+
referenceEnabled = true,
|
717
725
|
): GraphQLToken[] {
|
718
726
|
const tokensWithHints: GraphQLToken[] = []
|
719
727
|
const processedIndices = new Set<number>()
|
@@ -792,6 +800,7 @@ function addErrorHintTokens(
|
|
792
800
|
),
|
793
801
|
undefined,
|
794
802
|
annotations,
|
803
|
+
referenceEnabled,
|
795
804
|
)
|
796
805
|
tokensWithHints.push(hintToken)
|
797
806
|
}
|
@@ -808,6 +817,7 @@ function collectTokensWithSemantics(
|
|
808
817
|
code: string,
|
809
818
|
schema: GraphQLSchema | undefined,
|
810
819
|
annotations: CodeAnnotation[],
|
820
|
+
referenceEnabled = true,
|
811
821
|
): GraphQLToken[] {
|
812
822
|
const tokens: GraphQLToken[] = []
|
813
823
|
const cursor = tree.walk()
|
@@ -861,6 +871,7 @@ function collectTokensWithSemantics(
|
|
861
871
|
createWhitespaceNode(whitespace, lastEnd, node.startIndex),
|
862
872
|
undefined,
|
863
873
|
annotations,
|
874
|
+
referenceEnabled,
|
864
875
|
),
|
865
876
|
)
|
866
877
|
}
|
@@ -1009,6 +1020,7 @@ function collectTokensWithSemantics(
|
|
1009
1020
|
node,
|
1010
1021
|
semantic,
|
1011
1022
|
annotations,
|
1023
|
+
referenceEnabled,
|
1012
1024
|
)
|
1013
1025
|
|
1014
1026
|
tokens.push(token)
|
@@ -1050,6 +1062,7 @@ function collectTokensWithSemantics(
|
|
1050
1062
|
createWhitespaceNode(remaining, lastEnd, code.length),
|
1051
1063
|
undefined,
|
1052
1064
|
annotations,
|
1065
|
+
referenceEnabled,
|
1053
1066
|
),
|
1054
1067
|
)
|
1055
1068
|
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { InfoCircledIcon } from '@radix-ui/react-icons'
|
2
|
+
import { Box, Flex, HoverCard, Separator, Text } from '@radix-ui/themes'
|
3
|
+
import type { GraphQLInputObjectType } from 'graphql'
|
4
|
+
import type { FC } from 'react'
|
5
|
+
import { TypeLink } from './graphql/type-link.js'
|
6
|
+
|
7
|
+
interface Props {
|
8
|
+
inputObject: GraphQLInputObjectType
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Indicator for Input Argument Pattern (IAP) - shows when a field
|
13
|
+
* has a single 'input' argument with an Input Object type
|
14
|
+
*/
|
15
|
+
export const IAPIndicator: FC<Props> = ({ inputObject }) => {
|
16
|
+
return (
|
17
|
+
<HoverCard.Root>
|
18
|
+
<HoverCard.Trigger>
|
19
|
+
<Flex
|
20
|
+
align='center'
|
21
|
+
gap='1'
|
22
|
+
style={{
|
23
|
+
cursor: 'pointer',
|
24
|
+
opacity: 0.7,
|
25
|
+
display: 'inline-flex',
|
26
|
+
}}
|
27
|
+
>
|
28
|
+
<InfoCircledIcon style={{ width: 12, height: 12 }} />
|
29
|
+
<Text size='1' color='gray'>input</Text>
|
30
|
+
</Flex>
|
31
|
+
</HoverCard.Trigger>
|
32
|
+
<HoverCard.Content size='2' maxWidth='400px'>
|
33
|
+
<Flex direction='column' gap='3'>
|
34
|
+
<Flex direction='column' gap='2'>
|
35
|
+
<Box>
|
36
|
+
<TypeLink type={inputObject} />
|
37
|
+
</Box>
|
38
|
+
{inputObject.description && (
|
39
|
+
<Text size='2' color='gray' style={{ lineHeight: '1.5' }}>
|
40
|
+
{inputObject.description}
|
41
|
+
</Text>
|
42
|
+
)}
|
43
|
+
</Flex>
|
44
|
+
{inputObject.description && <Separator size='4' />}
|
45
|
+
<Flex direction='column' gap='2'>
|
46
|
+
<Text size='2' color='gray'>
|
47
|
+
This field uses an input-only argument pattern. The fields shown below belong to the input object, not
|
48
|
+
direct field arguments.
|
49
|
+
</Text>
|
50
|
+
<Box>
|
51
|
+
<Text size='1' color='gray' weight='medium'>
|
52
|
+
Example usage:
|
53
|
+
</Text>
|
54
|
+
<Box
|
55
|
+
mt='1'
|
56
|
+
style={{
|
57
|
+
padding: '8px',
|
58
|
+
backgroundColor: 'var(--gray-2)',
|
59
|
+
borderRadius: '4px',
|
60
|
+
fontFamily: 'var(--code-font-family)',
|
61
|
+
}}
|
62
|
+
>
|
63
|
+
<Text size='1' style={{ whiteSpace: 'pre' }}>
|
64
|
+
{`mutation {\n fieldName(input: { a: 1, b: "value", ... }) {\n ...\n }\n}`}
|
65
|
+
</Text>
|
66
|
+
</Box>
|
67
|
+
</Box>
|
68
|
+
</Flex>
|
69
|
+
</Flex>
|
70
|
+
</HoverCard.Content>
|
71
|
+
</HoverCard.Root>
|
72
|
+
)
|
73
|
+
}
|