polen 0.10.0 → 0.11.0-next.2
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/api.d.ts +1 -0
- package/build/api/api.d.ts.map +1 -1
- package/build/api/api.js +1 -0
- package/build/api/api.js.map +1 -1
- package/build/api/config/configurator.d.ts +20 -22
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +27 -9
- package/build/api/config/configurator.js.map +1 -1
- package/build/api/config/merge.d.ts.map +1 -1
- package/build/api/config/merge.js +0 -11
- package/build/api/config/merge.js.map +1 -1
- package/build/api/content/metadata.d.ts +8 -2
- package/build/api/content/metadata.d.ts.map +1 -1
- package/build/api/content/metadata.js +1 -1
- package/build/api/content/metadata.js.map +1 -1
- package/build/api/schema/data-sources/memory/memory.d.ts +2 -2
- package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
- package/build/api/schema/data-sources/memory/memory.js +1 -3
- package/build/api/schema/data-sources/memory/memory.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
- package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
- package/build/api/schema/metadata.d.ts +16 -0
- package/build/api/schema/metadata.d.ts.map +1 -0
- package/build/api/schema/metadata.js +19 -0
- package/build/api/schema/metadata.js.map +1 -0
- package/build/api/schema/read.d.ts +3 -3
- package/build/api/schema/read.d.ts.map +1 -1
- package/build/api/schema/read.js.map +1 -1
- package/build/api/schema/schema.d.ts +33 -2
- package/build/api/schema/schema.d.ts.map +1 -1
- package/build/api/schema/schema.js +42 -0
- package/build/api/schema/schema.js.map +1 -1
- package/build/api/schema-source/index.d.ts +2 -0
- package/build/api/schema-source/index.d.ts.map +1 -0
- package/build/api/schema-source/index.js +2 -0
- package/build/api/schema-source/index.js.map +1 -0
- package/build/api/schema-source/schema-source.d.ts +33 -0
- package/build/api/schema-source/schema-source.d.ts.map +1 -0
- package/build/api/schema-source/schema-source.js +137 -0
- package/build/api/schema-source/schema-source.js.map +1 -0
- package/build/api/static/manifest.d.ts +1 -2
- package/build/api/static/manifest.d.ts.map +1 -1
- package/build/api/static/manifest.js +1 -1
- package/build/api/static/manifest.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts +1 -0
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +21 -18
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/api/vite/plugins/main.d.ts.map +1 -1
- package/build/api/vite/plugins/main.js +1 -8
- package/build/api/vite/plugins/main.js.map +1 -1
- package/build/api/vite/plugins/schema-assets.d.ts +22 -0
- package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
- package/build/api/vite/plugins/schema-assets.js +269 -0
- package/build/api/vite/plugins/schema-assets.js.map +1 -0
- package/build/api/vite/plugins/serve.d.ts.map +1 -1
- package/build/api/vite/plugins/serve.js +11 -0
- package/build/api/vite/plugins/serve.js.map +1 -1
- package/build/lib/graphql-change/change-groups.d.ts +2 -0
- package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
- package/build/lib/graphql-change/change-groups.js +54 -0
- package/build/lib/graphql-change/change-groups.js.map +1 -1
- package/build/lib/kit-temp.d.ts +9 -0
- package/build/lib/kit-temp.d.ts.map +1 -1
- package/build/lib/kit-temp.js +12 -0
- package/build/lib/kit-temp.js.map +1 -1
- package/build/lib/path-map/path-map.d.ts.map +1 -1
- package/build/lib/path-map/path-map.js +3 -1
- package/build/lib/path-map/path-map.js.map +1 -1
- package/build/project-data.d.ts +3 -11
- package/build/project-data.d.ts.map +1 -1
- package/build/template/components/Changelog.d.ts +3 -3
- package/build/template/components/Changelog.d.ts.map +1 -1
- package/build/template/components/Changelog.js +8 -84
- package/build/template/components/Changelog.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts +2 -0
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -4
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/ComponentDispatch.d.ts +34 -0
- package/build/template/components/ComponentDispatch.d.ts.map +1 -0
- package/build/template/components/ComponentDispatch.js +33 -0
- package/build/template/components/ComponentDispatch.js.map +1 -0
- package/build/template/components/ReferenceLink.d.ts +19 -0
- package/build/template/components/ReferenceLink.d.ts.map +1 -0
- package/build/template/components/ReferenceLink.js +19 -0
- package/build/template/components/ReferenceLink.js.map +1 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +3 -3
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
- package/build/template/components/TypeFieldsLinkList.js +4 -4
- package/build/template/components/TypeFieldsLinkList.js.map +1 -1
- package/build/template/components/TypeIndex.js +2 -2
- package/build/template/components/TypeIndex.js.map +1 -1
- package/build/template/components/VersionSelector.d.ts +7 -0
- package/build/template/components/VersionSelector.d.ts.map +1 -0
- package/build/template/components/VersionSelector.js +30 -0
- package/build/template/components/VersionSelector.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +2 -2
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/hooks/useVersionPath.d.ts +6 -0
- package/build/template/hooks/useVersionPath.d.ts.map +1 -0
- package/build/template/hooks/useVersionPath.js +10 -0
- package/build/template/hooks/useVersionPath.js.map +1 -0
- package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
- package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
- package/build/template/layouts/ChangelogLayout.js.map +1 -0
- package/build/template/layouts/index.d.ts +1 -0
- package/build/template/layouts/index.d.ts.map +1 -1
- package/build/template/layouts/index.js +1 -0
- package/build/template/layouts/index.js.map +1 -1
- package/build/template/lib/fetch-text.d.ts +8 -0
- package/build/template/lib/fetch-text.d.ts.map +1 -0
- package/build/template/lib/fetch-text.js +14 -0
- package/build/template/lib/fetch-text.js.map +1 -0
- package/build/template/lib/polen-url.d.ts +14 -0
- package/build/template/lib/polen-url.d.ts.map +1 -1
- package/build/template/lib/polen-url.js +16 -0
- package/build/template/lib/polen-url.js.map +1 -1
- package/build/template/lib/schema-utils/constants.d.ts +5 -0
- package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
- package/build/template/lib/schema-utils/constants.js +5 -0
- package/build/template/lib/schema-utils/constants.js.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.js +37 -0
- package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
- package/build/template/routes/changelog.d.ts +4 -3
- package/build/template/routes/changelog.d.ts.map +1 -1
- package/build/template/routes/changelog.js +13 -7
- package/build/template/routes/changelog.js.map +1 -1
- package/build/template/routes/pages.d.ts +10 -0
- package/build/template/routes/pages.d.ts.map +1 -0
- package/build/template/routes/pages.js +76 -0
- package/build/template/routes/pages.js.map +1 -0
- package/build/template/routes/reference.$type.$field.js +1 -1
- package/build/template/routes/reference.$type.$field.js.map +1 -1
- package/build/template/routes/reference.$type.d.ts +4 -0
- package/build/template/routes/reference.$type.d.ts.map +1 -1
- package/build/template/routes/reference.$type.js +2 -0
- package/build/template/routes/reference.$type.js.map +1 -1
- package/build/template/routes/reference.d.ts +9 -3
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +30 -8
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/reference.version.$version.$type.$field.d.ts +6 -0
- package/build/template/routes/reference.version.$version.$type.$field.d.ts.map +1 -0
- package/build/template/routes/reference.version.$version.$type.$field.js +32 -0
- package/build/template/routes/reference.version.$version.$type.$field.js.map +1 -0
- package/build/template/routes/reference.version.$version.$type.d.ts +11 -0
- package/build/template/routes/reference.version.$version.$type.d.ts.map +1 -0
- package/build/template/routes/reference.version.$version.$type.js +26 -0
- package/build/template/routes/reference.version.$version.$type.js.map +1 -0
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +8 -72
- package/build/template/routes/root.js.map +1 -1
- package/build/template/server/app.d.ts +22 -1
- package/build/template/server/app.d.ts.map +1 -1
- package/build/template/server/app.js +19 -9
- package/build/template/server/app.js.map +1 -1
- package/build/template/server/main.js +9 -1
- package/build/template/server/main.js.map +1 -1
- package/build/template/server/ssg/generate.js +2 -2
- package/build/template/server/ssg/generate.js.map +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
- package/build/template/server/ssg/get-route-paths.js +51 -27
- package/build/template/server/ssg/get-route-paths.js.map +1 -1
- package/build/template/sources/schema-source.d.ts +15 -0
- package/build/template/sources/schema-source.d.ts.map +1 -0
- package/build/template/sources/schema-source.js +63 -0
- package/build/template/sources/schema-source.js.map +1 -0
- package/package.json +16 -17
- package/src/api/api.ts +1 -0
- package/src/api/config/configurator.ts +51 -32
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- package/src/api/schema/data-sources/memory/memory.ts +3 -5
- package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
- package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
- package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
- package/src/api/schema/metadata.ts +23 -0
- package/src/api/schema/read.ts +3 -3
- package/src/api/schema/schema.ts +62 -2
- package/src/api/schema-source/index.ts +1 -0
- package/src/api/schema-source/schema-source.ts +189 -0
- package/src/api/static/manifest.ts +1 -1
- package/src/api/vite/plugins/core.ts +23 -18
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +317 -0
- package/src/api/vite/plugins/serve.ts +15 -8
- package/src/lib/graphql-change/change-groups.ts +57 -0
- package/src/lib/kit-temp.ts +13 -0
- package/src/lib/path-map/$.test.ts +22 -19
- package/src/lib/path-map/path-map.ts +3 -1
- package/src/project-data.ts +3 -11
- package/src/template/components/Changelog.tsx +16 -67
- package/src/template/components/CodeBlock.tsx +3 -5
- package/src/template/components/ComponentDispatch.tsx +42 -0
- package/src/template/components/ReferenceLink.tsx +34 -0
- package/src/template/components/TypeAnnotation.tsx +5 -7
- package/src/template/components/TypeFieldsLinkList.tsx +20 -23
- package/src/template/components/TypeIndex.tsx +10 -12
- package/src/template/components/VersionSelector.tsx +50 -0
- package/src/template/components/graphql/type-link.tsx +4 -3
- package/src/template/hooks/useVersionPath.ts +10 -0
- package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
- package/src/template/layouts/index.ts +1 -0
- package/src/template/lib/fetch-text.ts +13 -0
- package/src/template/lib/polen-url.ts +20 -0
- package/src/template/lib/schema-utils/constants.ts +4 -0
- package/src/template/lib/schema-utils/schema-utils.ts +42 -0
- package/src/template/routes/changelog.tsx +17 -8
- package/src/template/routes/pages.tsx +109 -0
- package/src/template/routes/reference.$type.$field.tsx +1 -1
- package/src/template/routes/reference.$type.tsx +2 -0
- package/src/template/routes/reference.tsx +38 -6
- package/src/template/routes/reference.version.$version.$type.$field.tsx +35 -0
- package/src/template/routes/reference.version.$version.$type.tsx +30 -0
- package/src/template/routes/root.tsx +8 -109
- package/src/template/server/app.ts +47 -14
- package/src/template/server/main.ts +9 -1
- package/src/template/server/ssg/generate.ts +2 -2
- package/src/template/server/ssg/get-route-paths.ts +53 -27
- package/src/template/sources/schema-source.ts +68 -0
- package/build/lib/graphql-document/$$.d.ts +0 -5
- package/build/lib/graphql-document/$$.d.ts.map +0 -1
- package/build/lib/graphql-document/$$.js +0 -5
- package/build/lib/graphql-document/$$.js.map +0 -1
- package/build/lib/graphql-document/$.d.ts +0 -2
- package/build/lib/graphql-document/$.d.ts.map +0 -1
- package/build/lib/graphql-document/$.js +0 -2
- package/build/lib/graphql-document/$.js.map +0 -1
- package/build/lib/graphql-document/analysis.d.ts +0 -44
- package/build/lib/graphql-document/analysis.d.ts.map +0 -1
- package/build/lib/graphql-document/analysis.js +0 -361
- package/build/lib/graphql-document/analysis.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
- package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
- package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
- package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
- package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
- package/build/lib/graphql-document/components/index.d.ts +0 -5
- package/build/lib/graphql-document/components/index.d.ts.map +0 -1
- package/build/lib/graphql-document/components/index.js +0 -5
- package/build/lib/graphql-document/components/index.js.map +0 -1
- package/build/lib/graphql-document/example.d.ts +0 -25
- package/build/lib/graphql-document/example.d.ts.map +0 -1
- package/build/lib/graphql-document/example.js +0 -140
- package/build/lib/graphql-document/example.js.map +0 -1
- package/build/lib/graphql-document/graphql-document.d.ts +0 -35
- package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
- package/build/lib/graphql-document/graphql-document.js +0 -36
- package/build/lib/graphql-document/graphql-document.js.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
- package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
- package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
- package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
- package/build/lib/graphql-document/positioning-simple.js +0 -185
- package/build/lib/graphql-document/positioning-simple.js.map +0 -1
- package/build/lib/graphql-document/schema-context.d.ts +0 -8
- package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-context.js +0 -11
- package/build/lib/graphql-document/schema-context.js.map +0 -1
- package/build/lib/graphql-document/schema-integration.d.ts +0 -135
- package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-integration.js +0 -328
- package/build/lib/graphql-document/schema-integration.js.map +0 -1
- package/build/lib/graphql-document/types.d.ts +0 -117
- package/build/lib/graphql-document/types.d.ts.map +0 -1
- package/build/lib/graphql-document/types.js +0 -2
- package/build/lib/graphql-document/types.js.map +0 -1
- package/build/template/components/ChangelogLayout.d.ts.map +0 -1
- package/build/template/components/ChangelogLayout.js.map +0 -1
- package/build/template/components/CodeHikePre.d.ts +0 -16
- package/build/template/components/CodeHikePre.d.ts.map +0 -1
- package/build/template/components/CodeHikePre.js +0 -37
- package/build/template/components/CodeHikePre.js.map +0 -1
- package/src/lib/graphql-document/$$.ts +0 -4
- package/src/lib/graphql-document/$.test.ts +0 -132
- package/src/lib/graphql-document/$.ts +0 -1
- package/src/lib/graphql-document/README.md +0 -102
- package/src/lib/graphql-document/analysis.ts +0 -415
- package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
- package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
- package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
- package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
- package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
- package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
- package/src/lib/graphql-document/components/index.ts +0 -4
- package/src/lib/graphql-document/demo.md +0 -155
- package/src/lib/graphql-document/example.ts +0 -163
- package/src/lib/graphql-document/graphql-document.ts +0 -37
- package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
- package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
- package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
- package/src/lib/graphql-document/positioning-simple.ts +0 -260
- package/src/lib/graphql-document/schema-context.tsx +0 -20
- package/src/lib/graphql-document/schema-integration.test.ts +0 -365
- package/src/lib/graphql-document/schema-integration.ts +0 -488
- package/src/lib/graphql-document/types.ts +0 -129
- package/src/template/components/CodeHikePre.tsx +0 -51
- /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -1,488 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Layer 2: Schema Integration
|
3
|
-
*
|
4
|
-
* Bridge between GraphQL analysis and Polen's schema system.
|
5
|
-
* Resolves identifiers against the actual schema, extracts documentation,
|
6
|
-
* and generates reference URLs for navigation.
|
7
|
-
*/
|
8
|
-
|
9
|
-
import {
|
10
|
-
getNamedType,
|
11
|
-
type GraphQLField,
|
12
|
-
type GraphQLInputField,
|
13
|
-
type GraphQLSchema,
|
14
|
-
type GraphQLType,
|
15
|
-
isInputObjectType,
|
16
|
-
isInterfaceType,
|
17
|
-
isListType,
|
18
|
-
isNonNullType,
|
19
|
-
isObjectType,
|
20
|
-
} from 'graphql'
|
21
|
-
import { analyze } from './analysis.js'
|
22
|
-
import type { Identifier } from './types.js'
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Documentation extracted from GraphQL schema
|
26
|
-
*/
|
27
|
-
export interface Documentation {
|
28
|
-
/** Description from schema SDL or introspection */
|
29
|
-
description?: string
|
30
|
-
/** Type signature (e.g., "String!", "[User!]!") */
|
31
|
-
typeInfo: string
|
32
|
-
/** Whether this field/type is deprecated */
|
33
|
-
deprecated?: {
|
34
|
-
reason: string
|
35
|
-
replacement?: string
|
36
|
-
}
|
37
|
-
/** Default value for arguments */
|
38
|
-
defaultValue?: string
|
39
|
-
}
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Result of resolving an identifier against the schema
|
43
|
-
*/
|
44
|
-
export interface SchemaResolution {
|
45
|
-
/** Whether the identifier exists in the schema */
|
46
|
-
exists: boolean
|
47
|
-
/** Documentation extracted from schema */
|
48
|
-
documentation?: Documentation
|
49
|
-
/** URL to the reference page for this identifier */
|
50
|
-
referenceUrl: string
|
51
|
-
/** Whether this identifier is deprecated */
|
52
|
-
deprecated?: {
|
53
|
-
reason: string
|
54
|
-
replacement?: string
|
55
|
-
}
|
56
|
-
/** The GraphQL type if this is a type identifier */
|
57
|
-
graphqlType?: GraphQLType
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Interface for resolving GraphQL identifiers against a schema
|
62
|
-
*/
|
63
|
-
export interface SchemaResolver {
|
64
|
-
/**
|
65
|
-
* Resolve an identifier against the schema
|
66
|
-
*/
|
67
|
-
resolveIdentifier(identifier: Identifier): SchemaResolution | null
|
68
|
-
|
69
|
-
/**
|
70
|
-
* Get documentation for a schema path
|
71
|
-
*/
|
72
|
-
getDocumentation(schemaPath: string[]): Documentation | null
|
73
|
-
|
74
|
-
/**
|
75
|
-
* Generate a reference URL for a schema path
|
76
|
-
*/
|
77
|
-
generateReferenceLink(schemaPath: string[]): string
|
78
|
-
|
79
|
-
/**
|
80
|
-
* Check if a type exists in the schema
|
81
|
-
*/
|
82
|
-
typeExists(typeName: string): boolean
|
83
|
-
|
84
|
-
/**
|
85
|
-
* Get all available types for validation
|
86
|
-
*/
|
87
|
-
getAllTypes(): string[]
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Configuration for URL generation
|
92
|
-
*/
|
93
|
-
export interface RouteConfig {
|
94
|
-
/** Base path for reference pages (default: "/reference") */
|
95
|
-
basePath?: string
|
96
|
-
/** Whether to include fragments in URLs (default: true) */
|
97
|
-
includeFragments?: boolean
|
98
|
-
}
|
99
|
-
|
100
|
-
/**
|
101
|
-
* Polen's implementation of SchemaResolver
|
102
|
-
*/
|
103
|
-
export class PolenSchemaResolver implements SchemaResolver {
|
104
|
-
constructor(
|
105
|
-
private schema: GraphQLSchema,
|
106
|
-
private routeConfig: RouteConfig = {},
|
107
|
-
) {}
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Resolve an identifier against the schema
|
111
|
-
*/
|
112
|
-
resolveIdentifier(identifier: Identifier): SchemaResolution | null {
|
113
|
-
const basePath = this.routeConfig.basePath || `/reference`
|
114
|
-
|
115
|
-
switch (identifier.kind) {
|
116
|
-
case `Type`:
|
117
|
-
return this.resolveType(identifier, basePath)
|
118
|
-
|
119
|
-
case `Field`:
|
120
|
-
return this.resolveField(identifier, basePath)
|
121
|
-
|
122
|
-
case `Argument`:
|
123
|
-
return this.resolveArgument(identifier, basePath)
|
124
|
-
|
125
|
-
case `Variable`:
|
126
|
-
// Variables don't have schema resolution
|
127
|
-
return {
|
128
|
-
exists: true,
|
129
|
-
referenceUrl: `${basePath}#variables`,
|
130
|
-
documentation: {
|
131
|
-
typeInfo: `Variable`,
|
132
|
-
description: `Query variable: $${identifier.name}`,
|
133
|
-
},
|
134
|
-
}
|
135
|
-
|
136
|
-
case `Directive`:
|
137
|
-
return this.resolveDirective(identifier, basePath)
|
138
|
-
|
139
|
-
case `Fragment`:
|
140
|
-
// Fragments don't have schema resolution
|
141
|
-
return {
|
142
|
-
exists: true,
|
143
|
-
referenceUrl: `${basePath}#fragments`,
|
144
|
-
documentation: {
|
145
|
-
typeInfo: `Fragment`,
|
146
|
-
description: `Fragment: ${identifier.name}`,
|
147
|
-
},
|
148
|
-
}
|
149
|
-
|
150
|
-
default:
|
151
|
-
return null
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Get documentation for a schema path
|
157
|
-
*/
|
158
|
-
getDocumentation(schemaPath: string[]): Documentation | null {
|
159
|
-
if (schemaPath.length === 0) return null
|
160
|
-
|
161
|
-
const [typeName, fieldName, argName] = schemaPath
|
162
|
-
|
163
|
-
if (!typeName) return null
|
164
|
-
|
165
|
-
const type = this.schema.getType(typeName)
|
166
|
-
if (!type) return null
|
167
|
-
|
168
|
-
// Type-level documentation
|
169
|
-
if (schemaPath.length === 1) {
|
170
|
-
return {
|
171
|
-
typeInfo: this.getTypeSignature(type),
|
172
|
-
description: type.description || undefined,
|
173
|
-
deprecated: `deprecationReason` in type
|
174
|
-
? {
|
175
|
-
reason: (type as any).deprecationReason,
|
176
|
-
}
|
177
|
-
: undefined,
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
// Field-level documentation
|
182
|
-
if (fieldName && schemaPath.length === 2) {
|
183
|
-
const field = this.getFieldFromType(type, fieldName)
|
184
|
-
if (!field) return null
|
185
|
-
|
186
|
-
return {
|
187
|
-
typeInfo: this.getTypeSignature(field.type),
|
188
|
-
description: field.description || undefined,
|
189
|
-
deprecated: field.deprecationReason
|
190
|
-
? {
|
191
|
-
reason: field.deprecationReason,
|
192
|
-
}
|
193
|
-
: undefined,
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
// Argument-level documentation
|
198
|
-
if (fieldName && argName && schemaPath.length === 3) {
|
199
|
-
const field = this.getFieldFromType(type, fieldName)
|
200
|
-
if (!field || !(`args` in field)) return null
|
201
|
-
|
202
|
-
const arg = field.args.find((a: any) => a.name === argName)
|
203
|
-
if (!arg) return null
|
204
|
-
|
205
|
-
return {
|
206
|
-
typeInfo: this.getTypeSignature(arg.type),
|
207
|
-
description: arg.description || undefined,
|
208
|
-
defaultValue: arg.defaultValue !== undefined
|
209
|
-
? String(arg.defaultValue)
|
210
|
-
: undefined,
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
|
-
return null
|
215
|
-
}
|
216
|
-
|
217
|
-
/**
|
218
|
-
* Generate a reference URL for a schema path
|
219
|
-
*/
|
220
|
-
generateReferenceLink(schemaPath: string[]): string {
|
221
|
-
const basePath = this.routeConfig.basePath || `/reference`
|
222
|
-
const includeFragments = this.routeConfig.includeFragments !== false
|
223
|
-
|
224
|
-
if (schemaPath.length === 0) return basePath
|
225
|
-
|
226
|
-
const [typeName, fieldName, argName] = schemaPath
|
227
|
-
|
228
|
-
// Type reference
|
229
|
-
if (schemaPath.length === 1) {
|
230
|
-
return `${basePath}/${typeName}`
|
231
|
-
}
|
232
|
-
|
233
|
-
// Field reference
|
234
|
-
if (fieldName && schemaPath.length === 2) {
|
235
|
-
const fragment = includeFragments ? `#${fieldName}` : ``
|
236
|
-
return `${basePath}/${typeName}${fragment}`
|
237
|
-
}
|
238
|
-
|
239
|
-
// Argument reference
|
240
|
-
if (fieldName && argName && schemaPath.length === 3) {
|
241
|
-
const fragment = includeFragments ? `#${fieldName}-${argName}` : ``
|
242
|
-
return `${basePath}/${typeName}${fragment}`
|
243
|
-
}
|
244
|
-
|
245
|
-
return `${basePath}/${typeName}`
|
246
|
-
}
|
247
|
-
|
248
|
-
/**
|
249
|
-
* Check if a type exists in the schema
|
250
|
-
*/
|
251
|
-
typeExists(typeName: string): boolean {
|
252
|
-
return !!this.schema.getType(typeName)
|
253
|
-
}
|
254
|
-
|
255
|
-
/**
|
256
|
-
* Get all available types for validation
|
257
|
-
*/
|
258
|
-
getAllTypes(): string[] {
|
259
|
-
return Object.keys(this.schema.getTypeMap())
|
260
|
-
.filter(name => !name.startsWith(`__`)) // Filter out introspection types
|
261
|
-
}
|
262
|
-
|
263
|
-
// Private helper methods
|
264
|
-
|
265
|
-
private resolveType(identifier: Identifier, basePath: string): SchemaResolution {
|
266
|
-
const type = this.schema.getType(identifier.name)
|
267
|
-
|
268
|
-
return {
|
269
|
-
exists: !!type,
|
270
|
-
graphqlType: type || undefined,
|
271
|
-
referenceUrl: `${basePath}/${identifier.name}`,
|
272
|
-
documentation: type
|
273
|
-
? {
|
274
|
-
typeInfo: this.getTypeSignature(type),
|
275
|
-
description: type.description || undefined,
|
276
|
-
}
|
277
|
-
: undefined,
|
278
|
-
}
|
279
|
-
}
|
280
|
-
|
281
|
-
private resolveField(identifier: Identifier, basePath: string): SchemaResolution {
|
282
|
-
if (!identifier.parentType) {
|
283
|
-
return {
|
284
|
-
exists: false,
|
285
|
-
referenceUrl: `${basePath}#${identifier.name}`,
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
const parentType = this.schema.getType(identifier.parentType)
|
290
|
-
if (!parentType) {
|
291
|
-
return {
|
292
|
-
exists: false,
|
293
|
-
referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
|
294
|
-
}
|
295
|
-
}
|
296
|
-
|
297
|
-
const field = this.getFieldFromType(parentType, identifier.name)
|
298
|
-
|
299
|
-
return {
|
300
|
-
exists: !!field,
|
301
|
-
referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
|
302
|
-
documentation: field
|
303
|
-
? {
|
304
|
-
typeInfo: this.getTypeSignature(field.type),
|
305
|
-
description: field.description || undefined,
|
306
|
-
deprecated: field.deprecationReason
|
307
|
-
? {
|
308
|
-
reason: field.deprecationReason,
|
309
|
-
}
|
310
|
-
: undefined,
|
311
|
-
}
|
312
|
-
: undefined,
|
313
|
-
deprecated: field?.deprecationReason
|
314
|
-
? {
|
315
|
-
reason: field.deprecationReason,
|
316
|
-
}
|
317
|
-
: undefined,
|
318
|
-
}
|
319
|
-
}
|
320
|
-
|
321
|
-
private resolveArgument(identifier: Identifier, basePath: string): SchemaResolution {
|
322
|
-
const schemaPath = identifier.schemaPath
|
323
|
-
if (schemaPath.length < 3) {
|
324
|
-
return {
|
325
|
-
exists: false,
|
326
|
-
referenceUrl: `${basePath}#${identifier.name}`,
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
const [typeName, fieldName] = schemaPath
|
331
|
-
if (!typeName || !fieldName) {
|
332
|
-
return {
|
333
|
-
exists: false,
|
334
|
-
referenceUrl: `${basePath}#${identifier.name}`,
|
335
|
-
}
|
336
|
-
}
|
337
|
-
|
338
|
-
const parentType = this.schema.getType(typeName)
|
339
|
-
if (!parentType) {
|
340
|
-
return {
|
341
|
-
exists: false,
|
342
|
-
referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
|
343
|
-
}
|
344
|
-
}
|
345
|
-
|
346
|
-
const field = this.getFieldFromType(parentType, fieldName)
|
347
|
-
if (!field || !(`args` in field)) {
|
348
|
-
return {
|
349
|
-
exists: false,
|
350
|
-
referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
|
351
|
-
}
|
352
|
-
}
|
353
|
-
|
354
|
-
const arg = field.args.find((a: any) => a.name === identifier.name)
|
355
|
-
|
356
|
-
return {
|
357
|
-
exists: !!arg,
|
358
|
-
referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
|
359
|
-
documentation: arg
|
360
|
-
? {
|
361
|
-
typeInfo: this.getTypeSignature(arg.type),
|
362
|
-
description: arg.description || undefined,
|
363
|
-
defaultValue: arg.defaultValue !== undefined
|
364
|
-
? String(arg.defaultValue)
|
365
|
-
: undefined,
|
366
|
-
}
|
367
|
-
: undefined,
|
368
|
-
}
|
369
|
-
}
|
370
|
-
|
371
|
-
private resolveDirective(identifier: Identifier, basePath: string): SchemaResolution {
|
372
|
-
const directive = this.schema.getDirective(identifier.name)
|
373
|
-
|
374
|
-
return {
|
375
|
-
exists: !!directive,
|
376
|
-
referenceUrl: `${basePath}/directives#${identifier.name}`,
|
377
|
-
documentation: directive
|
378
|
-
? {
|
379
|
-
typeInfo: `Directive`,
|
380
|
-
description: directive.description || undefined,
|
381
|
-
}
|
382
|
-
: undefined,
|
383
|
-
}
|
384
|
-
}
|
385
|
-
|
386
|
-
private getFieldFromType(type: GraphQLType, fieldName: string): GraphQLField<any, any> | GraphQLInputField | null {
|
387
|
-
if (isObjectType(type) || isInterfaceType(type)) {
|
388
|
-
return type.getFields()[fieldName] || null
|
389
|
-
}
|
390
|
-
|
391
|
-
if (isInputObjectType(type)) {
|
392
|
-
return type.getFields()[fieldName] || null
|
393
|
-
}
|
394
|
-
|
395
|
-
return null
|
396
|
-
}
|
397
|
-
|
398
|
-
private getTypeSignature(type: GraphQLType): string {
|
399
|
-
if (isNonNullType(type)) {
|
400
|
-
return `${this.getTypeSignature(type.ofType)}!`
|
401
|
-
}
|
402
|
-
|
403
|
-
if (isListType(type)) {
|
404
|
-
return `[${this.getTypeSignature(type.ofType)}]`
|
405
|
-
}
|
406
|
-
|
407
|
-
return getNamedType(type).name
|
408
|
-
}
|
409
|
-
}
|
410
|
-
|
411
|
-
/**
|
412
|
-
* Create a schema resolver for Polen
|
413
|
-
*/
|
414
|
-
export const createPolenSchemaResolver = (
|
415
|
-
schema: GraphQLSchema,
|
416
|
-
routeConfig?: RouteConfig,
|
417
|
-
): SchemaResolver => {
|
418
|
-
return new PolenSchemaResolver(schema, routeConfig)
|
419
|
-
}
|
420
|
-
|
421
|
-
/**
|
422
|
-
* Enhanced analysis result with schema resolution
|
423
|
-
*/
|
424
|
-
export interface SchemaAwareAnalysisResult {
|
425
|
-
/** Original analysis result */
|
426
|
-
analysis: import('./types.js').AnalysisResult
|
427
|
-
/** Schema resolutions for all identifiers */
|
428
|
-
resolutions: Map<string, SchemaResolution>
|
429
|
-
/** Validation errors from schema checking */
|
430
|
-
schemaErrors: {
|
431
|
-
identifier: Identifier
|
432
|
-
message: string
|
433
|
-
severity: `error` | `warning`
|
434
|
-
}[]
|
435
|
-
}
|
436
|
-
|
437
|
-
/**
|
438
|
-
* Perform schema-aware analysis of a GraphQL document
|
439
|
-
*/
|
440
|
-
export const analyzeWithSchema = (
|
441
|
-
source: string,
|
442
|
-
schema: GraphQLSchema,
|
443
|
-
routeConfig?: RouteConfig,
|
444
|
-
): SchemaAwareAnalysisResult => {
|
445
|
-
const analysis = analyze(source, {
|
446
|
-
schema,
|
447
|
-
validateAgainstSchema: true,
|
448
|
-
includePositions: true,
|
449
|
-
})
|
450
|
-
|
451
|
-
const resolver = createPolenSchemaResolver(schema, routeConfig)
|
452
|
-
const resolutions = new Map<string, SchemaResolution>()
|
453
|
-
const schemaErrors: SchemaAwareAnalysisResult[`schemaErrors`] = []
|
454
|
-
|
455
|
-
// Resolve all identifiers against schema
|
456
|
-
for (const identifier of analysis.identifiers.all) {
|
457
|
-
const key = `${identifier.position.start}-${identifier.name}-${identifier.kind}`
|
458
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
459
|
-
|
460
|
-
if (resolution) {
|
461
|
-
resolutions.set(key, resolution)
|
462
|
-
|
463
|
-
// Add validation errors for non-existent identifiers
|
464
|
-
if (!resolution.exists && (identifier.kind === `Type` || identifier.kind === `Field`)) {
|
465
|
-
schemaErrors.push({
|
466
|
-
identifier,
|
467
|
-
message: `${identifier.kind} "${identifier.name}" does not exist in schema`,
|
468
|
-
severity: `error`,
|
469
|
-
})
|
470
|
-
}
|
471
|
-
|
472
|
-
// Add deprecation warnings
|
473
|
-
if (resolution.deprecated) {
|
474
|
-
schemaErrors.push({
|
475
|
-
identifier,
|
476
|
-
message: `${identifier.kind} "${identifier.name}" is deprecated: ${resolution.deprecated.reason}`,
|
477
|
-
severity: `warning`,
|
478
|
-
})
|
479
|
-
}
|
480
|
-
}
|
481
|
-
}
|
482
|
-
|
483
|
-
return {
|
484
|
-
analysis,
|
485
|
-
resolutions,
|
486
|
-
schemaErrors,
|
487
|
-
}
|
488
|
-
}
|
@@ -1,129 +0,0 @@
|
|
1
|
-
import type { DocumentNode, GraphQLError, GraphQLSchema } from 'graphql'
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Represents a GraphQL identifier found in a document
|
5
|
-
*/
|
6
|
-
export interface Identifier {
|
7
|
-
/** The name of the identifier (e.g., 'User', 'name', 'id') */
|
8
|
-
name: string
|
9
|
-
/** The kind of GraphQL construct this identifier represents */
|
10
|
-
kind: `Type` | `Field` | `Argument` | `Directive` | `Variable` | `Fragment`
|
11
|
-
/** Position information in the source document */
|
12
|
-
position: {
|
13
|
-
/** Character offset from start of document */
|
14
|
-
start: number
|
15
|
-
/** Character offset for end of identifier */
|
16
|
-
end: number
|
17
|
-
/** Line number (1-based) */
|
18
|
-
line: number
|
19
|
-
/** Column number (1-based) */
|
20
|
-
column: number
|
21
|
-
}
|
22
|
-
/** The parent type name if this is a field or argument */
|
23
|
-
parentType?: string
|
24
|
-
/** Path through the schema to this identifier (e.g., ['User', 'posts', 'title']) */
|
25
|
-
schemaPath: string[]
|
26
|
-
/** Context about where this identifier appears */
|
27
|
-
context: IdentifierContext
|
28
|
-
}
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Additional context about where an identifier appears in the document
|
32
|
-
*/
|
33
|
-
export interface IdentifierContext {
|
34
|
-
/** The operation type if this identifier is within an operation */
|
35
|
-
operationType?: `query` | `mutation` | `subscription`
|
36
|
-
/** The operation name if this identifier is within a named operation */
|
37
|
-
operationName?: string
|
38
|
-
/** Whether this identifier is in a fragment definition */
|
39
|
-
inFragment?: string
|
40
|
-
/** The selection path leading to this identifier */
|
41
|
-
selectionPath: string[]
|
42
|
-
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Map of all identifiers found in a GraphQL document
|
46
|
-
*/
|
47
|
-
export interface IdentifierMap {
|
48
|
-
/** Quick lookup by character position */
|
49
|
-
byPosition: Map<number, Identifier>
|
50
|
-
/** Grouped by identifier kind for easy filtering */
|
51
|
-
byKind: Map<Identifier[`kind`], Identifier[]>
|
52
|
-
/** Any validation errors found during analysis */
|
53
|
-
errors: AnalysisError[]
|
54
|
-
/** All identifiers as a flat array */
|
55
|
-
all: Identifier[]
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* Analysis error with context about the identifier that caused it
|
60
|
-
*/
|
61
|
-
export interface AnalysisError {
|
62
|
-
/** The identifier that caused the error (if applicable) */
|
63
|
-
identifier?: Identifier
|
64
|
-
/** Human-readable error message */
|
65
|
-
message: string
|
66
|
-
/** Error severity level */
|
67
|
-
severity: `error` | `warning` | `info`
|
68
|
-
/** Position in the document where the error occurred */
|
69
|
-
position?: {
|
70
|
-
line: number
|
71
|
-
column: number
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Result of analyzing a GraphQL document
|
77
|
-
*/
|
78
|
-
export interface AnalysisResult {
|
79
|
-
/** The parsed AST */
|
80
|
-
ast: DocumentNode
|
81
|
-
/** Map of all identifiers found */
|
82
|
-
identifiers: IdentifierMap
|
83
|
-
/** Whether the document parsed successfully */
|
84
|
-
isValid: boolean
|
85
|
-
/** Any parse or validation errors */
|
86
|
-
errors: GraphQLError[]
|
87
|
-
}
|
88
|
-
|
89
|
-
/**
|
90
|
-
* Configuration for GraphQL document analysis
|
91
|
-
*/
|
92
|
-
export interface AnalysisConfig {
|
93
|
-
/** Whether to include position information for identifiers */
|
94
|
-
includePositions?: boolean
|
95
|
-
/** Whether to validate against a schema (if provided) */
|
96
|
-
validateAgainstSchema?: boolean
|
97
|
-
/** Schema to validate against */
|
98
|
-
schema?: GraphQLSchema
|
99
|
-
/** Whether to extract fragment information */
|
100
|
-
includeFragments?: boolean
|
101
|
-
}
|
102
|
-
|
103
|
-
/**
|
104
|
-
* Interface for the main GraphQL analyzer
|
105
|
-
*/
|
106
|
-
export interface GraphQLAnalyzer {
|
107
|
-
/**
|
108
|
-
* Parse a GraphQL document string into an AST
|
109
|
-
*/
|
110
|
-
parse(source: string): DocumentNode
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Extract all identifiers from a GraphQL AST
|
114
|
-
*/
|
115
|
-
extractIdentifiers(ast: DocumentNode, config?: AnalysisConfig): IdentifierMap
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Validate a GraphQL document against a schema
|
119
|
-
*/
|
120
|
-
validateAgainstSchema(
|
121
|
-
ast: DocumentNode,
|
122
|
-
schema: GraphQLSchema,
|
123
|
-
): GraphQLError[]
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Perform complete analysis of a GraphQL document
|
127
|
-
*/
|
128
|
-
analyze(source: string, config?: AnalysisConfig): AnalysisResult
|
129
|
-
}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { Pre as CodeHikePre } from 'codehike/code'
|
2
|
-
import React from 'react'
|
3
|
-
import { GraphQLDocument } from '../../lib/graphql-document/components/GraphQLDocument.js'
|
4
|
-
|
5
|
-
type CodeHikePreProps = React.ComponentProps<typeof CodeHikePre>
|
6
|
-
type HTMLPreProps = React.ComponentPropsWithoutRef<'pre'>
|
7
|
-
type PreProps = CodeHikePreProps | HTMLPreProps
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Custom Pre component that adds interactive GraphQL support to Code Hike
|
11
|
-
*
|
12
|
-
* Usage in MDX:
|
13
|
-
* ```graphql interactive
|
14
|
-
* query { ... }
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
export const Pre: React.FC<PreProps> = (props) => {
|
18
|
-
// Check if this is a Code Hike pre component (has 'code' prop)
|
19
|
-
if ('code' in props && props.code) {
|
20
|
-
const { code } = props
|
21
|
-
|
22
|
-
// Check if this is an interactive GraphQL block
|
23
|
-
if (code.lang === 'graphql' && code.meta?.includes('interactive')) {
|
24
|
-
// Extract the GraphQL schema if available
|
25
|
-
const schema = typeof window !== 'undefined'
|
26
|
-
? (window as any).__POLEN_GRAPHQL_SCHEMA__
|
27
|
-
: null
|
28
|
-
|
29
|
-
// For interactive GraphQL blocks, we need to apply Code Hike's styling
|
30
|
-
// but add GraphQLDocument's interactive features
|
31
|
-
return (
|
32
|
-
<GraphQLDocument
|
33
|
-
schema={schema}
|
34
|
-
options={{
|
35
|
-
className: 'ch-code-container',
|
36
|
-
// Use Code Hike's Pre component for rendering
|
37
|
-
renderCode: () => <CodeHikePre {...props as CodeHikePreProps} />,
|
38
|
-
}}
|
39
|
-
>
|
40
|
-
{code.code}
|
41
|
-
</GraphQLDocument>
|
42
|
-
)
|
43
|
-
}
|
44
|
-
|
45
|
-
// For other Code Hike code blocks, use Code Hike's Pre
|
46
|
-
return <CodeHikePre {...props as CodeHikePreProps} />
|
47
|
-
}
|
48
|
-
|
49
|
-
// For standard HTML pre elements, render as-is
|
50
|
-
return <pre {...props as HTMLPreProps} />
|
51
|
-
}
|
File without changes
|