polen 0.10.0 → 0.11.0-next.10
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 +55 -26
- 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/data-sources.d.ts +1 -0
- package/build/api/schema/data-sources/data-sources.d.ts.map +1 -1
- package/build/api/schema/data-sources/data-sources.js +1 -0
- package/build/api/schema/data-sources/data-sources.js.map +1 -1
- package/build/api/schema/data-sources/introspection/introspection.d.ts +83 -0
- package/build/api/schema/data-sources/introspection/introspection.d.ts.map +1 -0
- package/build/api/schema/data-sources/introspection/introspection.js +110 -0
- package/build/api/schema/data-sources/introspection/introspection.js.map +1 -0
- 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 +85 -11
- package/build/api/schema/read.d.ts.map +1 -1
- package/build/api/schema/read.js +15 -6
- 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/build.d.ts.map +1 -1
- package/build/api/vite/plugins/build.js +3 -0
- package/build/api/vite/plugins/build.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 +25 -22
- 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 +310 -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/cli/commands/open.js +1 -1
- package/build/cli/commands/open.js.map +1 -1
- package/build/lib/grafaid/schema/schema.d.ts +1 -1
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -1
- package/build/lib/grafaid/schema/schema.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 +14 -2
- 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/lib/react-router-aid/react-router-aid.d.ts +5 -3
- package/build/lib/react-router-aid/react-router-aid.d.ts.map +1 -1
- package/build/lib/react-router-aid/react-router-aid.js +7 -4
- package/build/lib/react-router-aid/react-router-aid.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 +15 -9
- package/build/template/routes/changelog.js.map +1 -1
- package/build/template/routes/index.js +2 -2
- package/build/template/routes/index.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.d.ts +35 -6
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +97 -14
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +11 -75
- 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 +90 -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 +64 -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 +86 -36
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- package/src/api/schema/data-sources/data-sources.ts +1 -0
- package/src/api/schema/data-sources/introspection/introspection.ts +213 -0
- 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 +109 -18
- 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/build.ts +3 -0
- package/src/api/vite/plugins/core.ts +27 -22
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +364 -0
- package/src/api/vite/plugins/serve.ts +15 -8
- package/src/cli/commands/open.ts +1 -1
- package/src/lib/grafaid/schema/schema.ts +1 -0
- package/src/lib/graphql-change/change-groups.ts +57 -0
- package/src/lib/kit-temp.ts +15 -2
- package/src/lib/mask/$.test.ts +3 -3
- package/src/lib/path-map/$.test.ts +22 -19
- package/src/lib/path-map/path-map.ts +3 -1
- package/src/lib/react-router-aid/react-router-aid.ts +12 -6
- 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 +19 -10
- package/src/template/routes/index.tsx +2 -2
- package/src/template/routes/pages.tsx +109 -0
- package/src/template/routes/reference.tsx +112 -12
- package/src/template/routes/root.tsx +11 -112
- 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.test.ts +132 -0
- package/src/template/server/ssg/get-route-paths.ts +91 -27
- package/src/template/sources/schema-source.ts +69 -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/build/template/routes/reference.$type.$field.d.ts +0 -5
- package/build/template/routes/reference.$type.$field.d.ts.map +0 -1
- package/build/template/routes/reference.$type.$field.js +0 -31
- package/build/template/routes/reference.$type.$field.js.map +0 -1
- package/build/template/routes/reference.$type.d.ts +0 -5
- package/build/template/routes/reference.$type.d.ts.map +0 -1
- package/build/template/routes/reference.$type.js +0 -23
- package/build/template/routes/reference.$type.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/src/template/routes/reference.$type.$field.tsx +0 -34
- package/src/template/routes/reference.$type.tsx +0 -27
- /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -1,260 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Layer 3: Simplified Positioning & Layout Engine
|
3
|
-
*
|
4
|
-
* Maps GraphQL AST positions to DOM coordinates for overlay placement.
|
5
|
-
* This simplified version focuses on working with Polen's existing infrastructure.
|
6
|
-
*/
|
7
|
-
|
8
|
-
import type { Identifier } from './types.js'
|
9
|
-
|
10
|
-
/**
|
11
|
-
* DOM position for rendering overlays
|
12
|
-
*/
|
13
|
-
export interface DOMPosition {
|
14
|
-
/** Distance from top of container in pixels */
|
15
|
-
top: number
|
16
|
-
/** Distance from left of container in pixels */
|
17
|
-
left: number
|
18
|
-
/** Width of the identifier in pixels */
|
19
|
-
width: number
|
20
|
-
/** Height of the identifier in pixels */
|
21
|
-
height: number
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Position calculation result
|
26
|
-
*/
|
27
|
-
export interface PositionResult {
|
28
|
-
/** The calculated DOM position */
|
29
|
-
position: DOMPosition
|
30
|
-
/** The identifier this position is for */
|
31
|
-
identifier: Identifier
|
32
|
-
}
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Simplified position calculator for syntax-highlighted code
|
36
|
-
*
|
37
|
-
* This version uses a more straightforward approach:
|
38
|
-
* 1. Find the line element by line number
|
39
|
-
* 2. Search for the identifier text within that line
|
40
|
-
* 3. Create a span around the identifier for positioning
|
41
|
-
*
|
42
|
-
* This approach modifies the DOM but is more reliable for testing
|
43
|
-
* and works well with React's reconciliation.
|
44
|
-
*/
|
45
|
-
export class SimplePositionCalculator {
|
46
|
-
/**
|
47
|
-
* Prepare a code block for positioning by wrapping identifiers in spans
|
48
|
-
*/
|
49
|
-
prepareCodeBlock(
|
50
|
-
containerElement: Element,
|
51
|
-
identifiers: Identifier[],
|
52
|
-
): void {
|
53
|
-
// Get the full text content of the container
|
54
|
-
const fullText = containerElement.textContent || ``
|
55
|
-
const lines = fullText.split(`\n`)
|
56
|
-
|
57
|
-
// Build a map of line start positions in the full text
|
58
|
-
const lineStartPositions: number[] = [0]
|
59
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
60
|
-
const lineLength = lines[i]?.length ?? 0
|
61
|
-
lineStartPositions.push(lineStartPositions[i]! + lineLength + 1) // +1 for newline
|
62
|
-
}
|
63
|
-
|
64
|
-
// Process identifiers by line
|
65
|
-
for (const identifier of identifiers) {
|
66
|
-
const lineIndex = identifier.position.line - 1
|
67
|
-
if (lineIndex >= lines.length || lineIndex < 0) continue
|
68
|
-
|
69
|
-
const lineText = lines[lineIndex]
|
70
|
-
if (!lineText) continue
|
71
|
-
|
72
|
-
const columnIndex = identifier.position.column - 1
|
73
|
-
|
74
|
-
// Check if the identifier exists at the expected position
|
75
|
-
if (lineText.substring(columnIndex).startsWith(identifier.name)) {
|
76
|
-
// Calculate the absolute position in the full text
|
77
|
-
const lineStartPosition = lineStartPositions[lineIndex] ?? 0
|
78
|
-
const absolutePosition = lineStartPosition + columnIndex
|
79
|
-
|
80
|
-
// Check if already wrapped at this specific position
|
81
|
-
const existingWrapped = containerElement.querySelectorAll(`[data-graphql-id]`)
|
82
|
-
let alreadyWrapped = false
|
83
|
-
for (const wrapped of existingWrapped) {
|
84
|
-
if (wrapped.textContent === identifier.name) {
|
85
|
-
const startPos = parseInt(wrapped.getAttribute(`data-graphql-start`) || `0`)
|
86
|
-
if (startPos === identifier.position.start) {
|
87
|
-
alreadyWrapped = true
|
88
|
-
break
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
if (alreadyWrapped) continue
|
93
|
-
|
94
|
-
// Create wrapper span
|
95
|
-
const wrapper = document.createElement(`span`)
|
96
|
-
const id = `${identifier.position.start}-${identifier.name}-${identifier.kind}`
|
97
|
-
wrapper.setAttribute(`data-graphql-id`, id)
|
98
|
-
wrapper.setAttribute(`data-graphql-name`, identifier.name)
|
99
|
-
wrapper.setAttribute(`data-graphql-kind`, identifier.kind)
|
100
|
-
wrapper.setAttribute(`data-graphql-start`, String(identifier.position.start))
|
101
|
-
wrapper.setAttribute(`data-graphql-end`, String(identifier.position.end))
|
102
|
-
wrapper.setAttribute(`data-graphql-line`, String(identifier.position.line))
|
103
|
-
wrapper.setAttribute(`data-graphql-column`, String(identifier.position.column))
|
104
|
-
wrapper.setAttribute(`data-graphql-path`, identifier.schemaPath.join(`,`))
|
105
|
-
|
106
|
-
// Find the position in the container and wrap the text
|
107
|
-
const walker = document.createTreeWalker(
|
108
|
-
containerElement,
|
109
|
-
NodeFilter.SHOW_TEXT,
|
110
|
-
null,
|
111
|
-
)
|
112
|
-
|
113
|
-
let currentPos = 0
|
114
|
-
let node: Node | null
|
115
|
-
|
116
|
-
while (node = walker.nextNode()) {
|
117
|
-
const textNode = node as Text
|
118
|
-
const text = textNode.textContent || ``
|
119
|
-
|
120
|
-
// Check if this text node contains our identifier
|
121
|
-
if (currentPos <= absolutePosition && absolutePosition < currentPos + text.length) {
|
122
|
-
const relativePos = absolutePosition - currentPos
|
123
|
-
|
124
|
-
if (text.substring(relativePos).startsWith(identifier.name)) {
|
125
|
-
// Split the text node
|
126
|
-
const before = text.substring(0, relativePos)
|
127
|
-
const identifierText = identifier.name
|
128
|
-
const after = text.substring(relativePos + identifierText.length)
|
129
|
-
|
130
|
-
const parent = textNode.parentNode!
|
131
|
-
|
132
|
-
if (before) {
|
133
|
-
parent.insertBefore(document.createTextNode(before), textNode)
|
134
|
-
}
|
135
|
-
|
136
|
-
wrapper.textContent = identifierText
|
137
|
-
parent.insertBefore(wrapper, textNode)
|
138
|
-
|
139
|
-
if (after) {
|
140
|
-
parent.insertBefore(document.createTextNode(after), textNode)
|
141
|
-
}
|
142
|
-
|
143
|
-
parent.removeChild(textNode)
|
144
|
-
break
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
currentPos += text.length
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Get positions of all wrapped identifiers
|
156
|
-
*/
|
157
|
-
getIdentifierPositions(
|
158
|
-
containerElement: Element,
|
159
|
-
relativeToElement?: Element,
|
160
|
-
): Map<string, PositionResult> {
|
161
|
-
const results = new Map<string, PositionResult>()
|
162
|
-
|
163
|
-
// Find all wrapped identifiers
|
164
|
-
const wrappedIdentifiers = containerElement.querySelectorAll(`[data-graphql-id]`)
|
165
|
-
|
166
|
-
// Use the provided element for relative positioning, or the container itself
|
167
|
-
const referenceElement = relativeToElement || containerElement
|
168
|
-
|
169
|
-
for (const element of wrappedIdentifiers) {
|
170
|
-
const id = element.getAttribute(`data-graphql-id`)
|
171
|
-
if (!id) continue
|
172
|
-
|
173
|
-
// Get position relative to the reference element
|
174
|
-
const referenceRect = referenceElement.getBoundingClientRect()
|
175
|
-
const elementRect = element.getBoundingClientRect()
|
176
|
-
|
177
|
-
const position: DOMPosition = {
|
178
|
-
top: elementRect.top - referenceRect.top,
|
179
|
-
left: elementRect.left - referenceRect.left,
|
180
|
-
width: elementRect.width,
|
181
|
-
height: elementRect.height,
|
182
|
-
}
|
183
|
-
|
184
|
-
// Reconstruct identifier from data attributes
|
185
|
-
const identifier: Identifier = {
|
186
|
-
name: element.getAttribute(`data-graphql-name`) || ``,
|
187
|
-
kind: (element.getAttribute(`data-graphql-kind`) || `Field`) as Identifier[`kind`],
|
188
|
-
position: {
|
189
|
-
start: parseInt(element.getAttribute(`data-graphql-start`) || `0`),
|
190
|
-
end: parseInt(element.getAttribute(`data-graphql-end`) || `0`),
|
191
|
-
line: parseInt(element.getAttribute(`data-graphql-line`) || `1`),
|
192
|
-
column: parseInt(element.getAttribute(`data-graphql-column`) || `1`),
|
193
|
-
},
|
194
|
-
schemaPath: (element.getAttribute(`data-graphql-path`) || ``).split(`,`).filter(Boolean),
|
195
|
-
context: { selectionPath: [] },
|
196
|
-
}
|
197
|
-
|
198
|
-
results.set(id, { position, identifier })
|
199
|
-
}
|
200
|
-
|
201
|
-
return results
|
202
|
-
}
|
203
|
-
}
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Create invisible overlay for a position
|
207
|
-
*/
|
208
|
-
export const createSimpleOverlay = (
|
209
|
-
position: DOMPosition,
|
210
|
-
identifier: Identifier,
|
211
|
-
options?: {
|
212
|
-
onClick?: (identifier: Identifier) => void
|
213
|
-
onHover?: (identifier: Identifier, event: MouseEvent) => void
|
214
|
-
className?: string
|
215
|
-
},
|
216
|
-
): HTMLElement => {
|
217
|
-
const overlay = document.createElement(`div`)
|
218
|
-
|
219
|
-
// Base styles for positioning
|
220
|
-
overlay.style.position = `absolute`
|
221
|
-
overlay.style.top = `${position.top}px`
|
222
|
-
overlay.style.left = `${position.left}px`
|
223
|
-
overlay.style.width = `${position.width}px`
|
224
|
-
overlay.style.height = `${position.height}px`
|
225
|
-
overlay.style.cursor = `pointer`
|
226
|
-
overlay.style.zIndex = `10`
|
227
|
-
|
228
|
-
// Add custom class if provided
|
229
|
-
if (options?.className) {
|
230
|
-
overlay.className = options.className
|
231
|
-
}
|
232
|
-
|
233
|
-
// Data attributes
|
234
|
-
overlay.setAttribute(`data-graphql-overlay`, `true`)
|
235
|
-
overlay.setAttribute(`data-graphql-name`, identifier.name)
|
236
|
-
overlay.setAttribute(`data-graphql-kind`, identifier.kind)
|
237
|
-
|
238
|
-
// Event handlers
|
239
|
-
if (options?.onClick) {
|
240
|
-
overlay.addEventListener(`click`, (e) => {
|
241
|
-
e.preventDefault()
|
242
|
-
options.onClick!(identifier)
|
243
|
-
})
|
244
|
-
}
|
245
|
-
|
246
|
-
if (options?.onHover) {
|
247
|
-
overlay.addEventListener(`mouseenter`, (e) => {
|
248
|
-
options.onHover!(identifier, e)
|
249
|
-
})
|
250
|
-
}
|
251
|
-
|
252
|
-
return overlay
|
253
|
-
}
|
254
|
-
|
255
|
-
/**
|
256
|
-
* Factory function for position calculator
|
257
|
-
*/
|
258
|
-
export const createSimplePositionCalculator = (): SimplePositionCalculator => {
|
259
|
-
return new SimplePositionCalculator()
|
260
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import type { GraphQLSchema } from 'graphql'
|
2
|
-
import React from 'react'
|
3
|
-
|
4
|
-
export const GraphQLSchemaContext = React.createContext<GraphQLSchema | null>(null)
|
5
|
-
|
6
|
-
export const useGraphQLSchema = () => {
|
7
|
-
const schema = React.useContext(GraphQLSchemaContext)
|
8
|
-
return schema
|
9
|
-
}
|
10
|
-
|
11
|
-
export const GraphQLSchemaProvider: React.FC<React.PropsWithChildren<{ schema: GraphQLSchema | null }>> = ({
|
12
|
-
children,
|
13
|
-
schema,
|
14
|
-
}) => {
|
15
|
-
return (
|
16
|
-
<GraphQLSchemaContext.Provider value={schema}>
|
17
|
-
{children}
|
18
|
-
</GraphQLSchemaContext.Provider>
|
19
|
-
)
|
20
|
-
}
|
@@ -1,365 +0,0 @@
|
|
1
|
-
import { buildSchema } from 'graphql'
|
2
|
-
import { describe, expect, it } from 'vitest'
|
3
|
-
import { analyzeWithSchema, createPolenSchemaResolver } from './schema-integration.js'
|
4
|
-
|
5
|
-
// Test schema
|
6
|
-
const testSchema = buildSchema(`
|
7
|
-
"""
|
8
|
-
A user in the system
|
9
|
-
"""
|
10
|
-
type User {
|
11
|
-
"""
|
12
|
-
The user's unique identifier
|
13
|
-
"""
|
14
|
-
id: ID!
|
15
|
-
|
16
|
-
"""
|
17
|
-
The user's full name
|
18
|
-
"""
|
19
|
-
name: String!
|
20
|
-
|
21
|
-
"""
|
22
|
-
The user's email address
|
23
|
-
"""
|
24
|
-
email: String!
|
25
|
-
|
26
|
-
"""
|
27
|
-
User's posts
|
28
|
-
"""
|
29
|
-
posts(
|
30
|
-
"""
|
31
|
-
Maximum number of posts to return
|
32
|
-
"""
|
33
|
-
first: Int = 10
|
34
|
-
|
35
|
-
"""
|
36
|
-
Filter posts after this cursor
|
37
|
-
"""
|
38
|
-
after: String
|
39
|
-
): [Post!]!
|
40
|
-
|
41
|
-
"""
|
42
|
-
@deprecated Use profile.avatar instead
|
43
|
-
"""
|
44
|
-
avatar: String @deprecated(reason: "Use profile.avatar instead")
|
45
|
-
}
|
46
|
-
|
47
|
-
"""
|
48
|
-
A blog post
|
49
|
-
"""
|
50
|
-
type Post {
|
51
|
-
id: ID!
|
52
|
-
title: String!
|
53
|
-
content: String!
|
54
|
-
author: User!
|
55
|
-
}
|
56
|
-
|
57
|
-
"""
|
58
|
-
Input for creating a user
|
59
|
-
"""
|
60
|
-
input CreateUserInput {
|
61
|
-
name: String!
|
62
|
-
email: String!
|
63
|
-
}
|
64
|
-
|
65
|
-
type Query {
|
66
|
-
"""
|
67
|
-
Get a user by ID
|
68
|
-
"""
|
69
|
-
user(id: ID!): User
|
70
|
-
|
71
|
-
"""
|
72
|
-
Search for users
|
73
|
-
"""
|
74
|
-
users(query: String!): [User!]!
|
75
|
-
}
|
76
|
-
|
77
|
-
type Mutation {
|
78
|
-
"""
|
79
|
-
Create a new user
|
80
|
-
"""
|
81
|
-
createUser(input: CreateUserInput!): User!
|
82
|
-
}
|
83
|
-
|
84
|
-
"""
|
85
|
-
Custom directive for validation
|
86
|
-
"""
|
87
|
-
directive @validate(pattern: String!) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
|
88
|
-
`)
|
89
|
-
|
90
|
-
describe('Schema Integration', () => {
|
91
|
-
describe('PolenSchemaResolver', () => {
|
92
|
-
const resolver = createPolenSchemaResolver(testSchema)
|
93
|
-
|
94
|
-
describe('Type Resolution', () => {
|
95
|
-
it('should resolve existing types', () => {
|
96
|
-
const identifier = {
|
97
|
-
name: 'User',
|
98
|
-
kind: 'Type' as const,
|
99
|
-
position: { start: 0, end: 4, line: 1, column: 1 },
|
100
|
-
schemaPath: ['User'],
|
101
|
-
context: { selectionPath: [] },
|
102
|
-
}
|
103
|
-
|
104
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
105
|
-
|
106
|
-
expect(resolution).toBeDefined()
|
107
|
-
expect(resolution!.exists).toBe(true)
|
108
|
-
expect(resolution!.referenceUrl).toBe('/reference/User')
|
109
|
-
expect(resolution!.documentation?.description).toContain('A user in the system')
|
110
|
-
expect(resolution!.documentation?.typeInfo).toBe('User')
|
111
|
-
})
|
112
|
-
|
113
|
-
it('should handle non-existent types', () => {
|
114
|
-
const identifier = {
|
115
|
-
name: 'NonExistentType',
|
116
|
-
kind: 'Type' as const,
|
117
|
-
position: { start: 0, end: 15, line: 1, column: 1 },
|
118
|
-
schemaPath: ['NonExistentType'],
|
119
|
-
context: { selectionPath: [] },
|
120
|
-
}
|
121
|
-
|
122
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
123
|
-
|
124
|
-
expect(resolution).toBeDefined()
|
125
|
-
expect(resolution!.exists).toBe(false)
|
126
|
-
expect(resolution!.referenceUrl).toBe('/reference/NonExistentType')
|
127
|
-
expect(resolution!.documentation).toBeUndefined()
|
128
|
-
})
|
129
|
-
})
|
130
|
-
|
131
|
-
describe('Field Resolution', () => {
|
132
|
-
it('should resolve existing fields', () => {
|
133
|
-
const identifier = {
|
134
|
-
name: 'name',
|
135
|
-
kind: 'Field' as const,
|
136
|
-
position: { start: 0, end: 4, line: 1, column: 1 },
|
137
|
-
parentType: 'User',
|
138
|
-
schemaPath: ['User', 'name'],
|
139
|
-
context: { selectionPath: ['name'] },
|
140
|
-
}
|
141
|
-
|
142
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
143
|
-
|
144
|
-
expect(resolution).toBeDefined()
|
145
|
-
expect(resolution!.exists).toBe(true)
|
146
|
-
expect(resolution!.referenceUrl).toBe('/reference/User#name')
|
147
|
-
expect(resolution!.documentation?.description).toContain("The user's full name")
|
148
|
-
expect(resolution!.documentation?.typeInfo).toBe('String!')
|
149
|
-
})
|
150
|
-
|
151
|
-
it('should detect deprecated fields', () => {
|
152
|
-
const identifier = {
|
153
|
-
name: 'avatar',
|
154
|
-
kind: 'Field' as const,
|
155
|
-
position: { start: 0, end: 6, line: 1, column: 1 },
|
156
|
-
parentType: 'User',
|
157
|
-
schemaPath: ['User', 'avatar'],
|
158
|
-
context: { selectionPath: ['avatar'] },
|
159
|
-
}
|
160
|
-
|
161
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
162
|
-
|
163
|
-
expect(resolution).toBeDefined()
|
164
|
-
expect(resolution!.exists).toBe(true)
|
165
|
-
expect(resolution!.deprecated).toBeDefined()
|
166
|
-
expect(resolution!.deprecated!.reason).toBe('Use profile.avatar instead')
|
167
|
-
})
|
168
|
-
|
169
|
-
it('should handle non-existent fields', () => {
|
170
|
-
const identifier = {
|
171
|
-
name: 'nonExistentField',
|
172
|
-
kind: 'Field' as const,
|
173
|
-
position: { start: 0, end: 16, line: 1, column: 1 },
|
174
|
-
parentType: 'User',
|
175
|
-
schemaPath: ['User', 'nonExistentField'],
|
176
|
-
context: { selectionPath: ['nonExistentField'] },
|
177
|
-
}
|
178
|
-
|
179
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
180
|
-
|
181
|
-
expect(resolution).toBeDefined()
|
182
|
-
expect(resolution!.exists).toBe(false)
|
183
|
-
expect(resolution!.referenceUrl).toBe('/reference/User#nonExistentField')
|
184
|
-
})
|
185
|
-
})
|
186
|
-
|
187
|
-
describe('Argument Resolution', () => {
|
188
|
-
it('should resolve field arguments', () => {
|
189
|
-
const identifier = {
|
190
|
-
name: 'first',
|
191
|
-
kind: 'Argument' as const,
|
192
|
-
position: { start: 0, end: 5, line: 1, column: 1 },
|
193
|
-
parentType: 'User',
|
194
|
-
schemaPath: ['User', 'posts', 'first'],
|
195
|
-
context: { selectionPath: ['posts'] },
|
196
|
-
}
|
197
|
-
|
198
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
199
|
-
|
200
|
-
expect(resolution).toBeDefined()
|
201
|
-
expect(resolution!.exists).toBe(true)
|
202
|
-
expect(resolution!.referenceUrl).toBe('/reference/User#posts-first')
|
203
|
-
expect(resolution!.documentation?.description).toContain('Maximum number of posts')
|
204
|
-
expect(resolution!.documentation?.typeInfo).toBe('Int')
|
205
|
-
expect(resolution!.documentation?.defaultValue).toBe('10')
|
206
|
-
})
|
207
|
-
})
|
208
|
-
|
209
|
-
describe('Variable Resolution', () => {
|
210
|
-
it('should handle variables', () => {
|
211
|
-
const identifier = {
|
212
|
-
name: 'id',
|
213
|
-
kind: 'Variable' as const,
|
214
|
-
position: { start: 0, end: 2, line: 1, column: 1 },
|
215
|
-
schemaPath: ['id'],
|
216
|
-
context: { selectionPath: [] },
|
217
|
-
}
|
218
|
-
|
219
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
220
|
-
|
221
|
-
expect(resolution).toBeDefined()
|
222
|
-
expect(resolution!.exists).toBe(true)
|
223
|
-
expect(resolution!.referenceUrl).toBe('/reference#variables')
|
224
|
-
expect(resolution!.documentation?.typeInfo).toBe('Variable')
|
225
|
-
expect(resolution!.documentation?.description).toBe('Query variable: $id')
|
226
|
-
})
|
227
|
-
})
|
228
|
-
|
229
|
-
describe('Directive Resolution', () => {
|
230
|
-
it('should resolve directives', () => {
|
231
|
-
const identifier = {
|
232
|
-
name: 'validate',
|
233
|
-
kind: 'Directive' as const,
|
234
|
-
position: { start: 0, end: 8, line: 1, column: 1 },
|
235
|
-
schemaPath: ['validate'],
|
236
|
-
context: { selectionPath: [] },
|
237
|
-
}
|
238
|
-
|
239
|
-
const resolution = resolver.resolveIdentifier(identifier)
|
240
|
-
|
241
|
-
expect(resolution).toBeDefined()
|
242
|
-
expect(resolution!.exists).toBe(true)
|
243
|
-
expect(resolution!.referenceUrl).toBe('/reference/directives#validate')
|
244
|
-
expect(resolution!.documentation?.description).toContain('Custom directive for validation')
|
245
|
-
})
|
246
|
-
})
|
247
|
-
|
248
|
-
describe('URL Generation', () => {
|
249
|
-
it('should generate correct URLs with custom base path', () => {
|
250
|
-
const customResolver = createPolenSchemaResolver(testSchema, {
|
251
|
-
basePath: '/docs/schema',
|
252
|
-
})
|
253
|
-
|
254
|
-
expect(customResolver.generateReferenceLink(['User'])).toBe('/docs/schema/User')
|
255
|
-
expect(customResolver.generateReferenceLink(['User', 'name'])).toBe('/docs/schema/User#name')
|
256
|
-
expect(customResolver.generateReferenceLink(['User', 'posts', 'first'])).toBe('/docs/schema/User#posts-first')
|
257
|
-
})
|
258
|
-
|
259
|
-
it('should handle fragment configuration', () => {
|
260
|
-
const noFragmentResolver = createPolenSchemaResolver(testSchema, {
|
261
|
-
includeFragments: false,
|
262
|
-
})
|
263
|
-
|
264
|
-
expect(noFragmentResolver.generateReferenceLink(['User', 'name'])).toBe('/reference/User')
|
265
|
-
})
|
266
|
-
})
|
267
|
-
|
268
|
-
describe('Documentation Extraction', () => {
|
269
|
-
it('should extract type documentation', () => {
|
270
|
-
const docs = resolver.getDocumentation(['User'])
|
271
|
-
|
272
|
-
expect(docs).toBeDefined()
|
273
|
-
expect(docs!.description).toContain('A user in the system')
|
274
|
-
expect(docs!.typeInfo).toBe('User')
|
275
|
-
})
|
276
|
-
|
277
|
-
it('should extract field documentation', () => {
|
278
|
-
const docs = resolver.getDocumentation(['User', 'email'])
|
279
|
-
|
280
|
-
expect(docs).toBeDefined()
|
281
|
-
expect(docs!.description).toContain("The user's email address")
|
282
|
-
expect(docs!.typeInfo).toBe('String!')
|
283
|
-
})
|
284
|
-
|
285
|
-
it('should extract argument documentation', () => {
|
286
|
-
const docs = resolver.getDocumentation(['User', 'posts', 'after'])
|
287
|
-
|
288
|
-
expect(docs).toBeDefined()
|
289
|
-
expect(docs!.description).toContain('Filter posts after this cursor')
|
290
|
-
expect(docs!.typeInfo).toBe('String')
|
291
|
-
})
|
292
|
-
})
|
293
|
-
|
294
|
-
describe('Schema Validation', () => {
|
295
|
-
it('should return all types', () => {
|
296
|
-
const types = resolver.getAllTypes()
|
297
|
-
|
298
|
-
expect(types).toContain('User')
|
299
|
-
expect(types).toContain('Post')
|
300
|
-
expect(types).toContain('CreateUserInput')
|
301
|
-
expect(types).toContain('Query')
|
302
|
-
expect(types).toContain('Mutation')
|
303
|
-
expect(types).not.toContain('__Schema') // Should filter introspection types
|
304
|
-
})
|
305
|
-
|
306
|
-
it('should check type existence', () => {
|
307
|
-
expect(resolver.typeExists('User')).toBe(true)
|
308
|
-
expect(resolver.typeExists('NonExistentType')).toBe(false)
|
309
|
-
})
|
310
|
-
})
|
311
|
-
})
|
312
|
-
|
313
|
-
describe('Schema-Aware Analysis', () => {
|
314
|
-
it('should perform complete schema-aware analysis', () => {
|
315
|
-
const source = `
|
316
|
-
query GetUser($id: ID!) {
|
317
|
-
user(id: $id) {
|
318
|
-
name
|
319
|
-
email
|
320
|
-
avatar
|
321
|
-
}
|
322
|
-
}
|
323
|
-
`
|
324
|
-
|
325
|
-
const result = analyzeWithSchema(source, testSchema)
|
326
|
-
|
327
|
-
expect(result.analysis.isValid).toBe(true)
|
328
|
-
expect(result.resolutions.size).toBeGreaterThan(0)
|
329
|
-
expect(result.schemaErrors.length).toBeGreaterThan(0)
|
330
|
-
|
331
|
-
// Should have deprecation warning for avatar field
|
332
|
-
const deprecationWarning = result.schemaErrors.find(
|
333
|
-
error => error.message.includes('avatar') && error.message.includes('deprecated'),
|
334
|
-
)
|
335
|
-
expect(deprecationWarning).toBeDefined()
|
336
|
-
expect(deprecationWarning!.severity).toBe('warning')
|
337
|
-
})
|
338
|
-
|
339
|
-
it('should resolve identifiers correctly', () => {
|
340
|
-
const source = `
|
341
|
-
query {
|
342
|
-
user(id: "123") {
|
343
|
-
name
|
344
|
-
}
|
345
|
-
}
|
346
|
-
`
|
347
|
-
|
348
|
-
const result = analyzeWithSchema(source, testSchema)
|
349
|
-
|
350
|
-
// Find the name field resolution
|
351
|
-
const nameField = result.analysis.identifiers.all.find(
|
352
|
-
id => id.name === 'name' && id.kind === 'Field',
|
353
|
-
)
|
354
|
-
expect(nameField).toBeDefined()
|
355
|
-
|
356
|
-
const nameResolutionKey = `${nameField!.position.start}-${nameField!.name}-${nameField!.kind}`
|
357
|
-
const nameResolution = result.resolutions.get(nameResolutionKey)
|
358
|
-
|
359
|
-
expect(nameResolution).toBeDefined()
|
360
|
-
expect(nameResolution!.exists).toBe(true)
|
361
|
-
expect(nameResolution!.referenceUrl).toBe('/reference/User#name')
|
362
|
-
expect(nameResolution!.documentation?.typeInfo).toBe('String!')
|
363
|
-
})
|
364
|
-
})
|
365
|
-
})
|