polen 0.11.0-next.24 → 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 +259 -77
- 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 +433 -143
- 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 +191 -121
- 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/diagnostic/diagnostic.d.ts +0 -23
- package/build/api/examples/diagnostic/diagnostic.d.ts.map +1 -1
- package/build/api/examples/diagnostic/diagnostic.js +1 -3
- package/build/api/examples/diagnostic/diagnostic.js.map +1 -1
- package/build/api/examples/scanner.d.ts +27 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +30 -17
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/schemas/catalog.d.ts +56 -12
- package/build/api/examples/schemas/catalog.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.d.ts +54 -11
- 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/api/schema/augmentations/$$.d.ts +7 -0
- package/build/api/schema/augmentations/$$.d.ts.map +1 -0
- package/build/api/schema/augmentations/$$.js +7 -0
- package/build/api/schema/augmentations/$$.js.map +1 -0
- package/build/api/schema/augmentations/$.d.ts +1 -1
- package/build/api/schema/augmentations/$.d.ts.map +1 -1
- package/build/api/schema/augmentations/$.js +1 -1
- package/build/api/schema/augmentations/$.js.map +1 -1
- package/build/api/schema/augmentations/apply.d.ts +29 -0
- package/build/api/schema/augmentations/apply.d.ts.map +1 -0
- package/build/api/schema/augmentations/apply.js +181 -0
- package/build/api/schema/augmentations/apply.js.map +1 -0
- package/build/api/schema/augmentations/augmentation.d.ts +31 -0
- package/build/api/schema/augmentations/augmentation.d.ts.map +1 -0
- package/build/api/schema/augmentations/augmentation.js +22 -0
- package/build/api/schema/augmentations/augmentation.js.map +1 -0
- package/build/api/schema/augmentations/config.d.ts +24 -0
- package/build/api/schema/augmentations/config.d.ts.map +1 -0
- package/build/api/schema/augmentations/config.js +9 -0
- package/build/api/schema/augmentations/config.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.d.ts +67 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.js +13 -0
- package/build/api/schema/augmentations/diagnostics/diagnostic.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.d.ts +45 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.js +17 -0
- package/build/api/schema/augmentations/diagnostics/duplicate-version.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.d.ts +46 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.js +18 -0
- package/build/api/schema/augmentations/diagnostics/invalid-path.js.map +1 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.d.ts +46 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.d.ts.map +1 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.js +18 -0
- package/build/api/schema/augmentations/diagnostics/version-mismatch.js.map +1 -0
- package/build/api/schema/augmentations/input.d.ts +145 -0
- package/build/api/schema/augmentations/input.d.ts.map +1 -0
- package/build/api/schema/augmentations/input.js +191 -0
- package/build/api/schema/augmentations/input.js.map +1 -0
- package/build/api/schema/augmentations/placement.d.ts +8 -0
- package/build/api/schema/augmentations/placement.d.ts.map +1 -0
- package/build/api/schema/augmentations/placement.js +7 -0
- package/build/api/schema/augmentations/placement.js.map +1 -0
- package/build/api/schema/config-schema.d.ts +66 -66
- package/build/api/schema/config-schema.d.ts.map +1 -1
- package/build/api/schema/config-schema.js +2 -2
- package/build/api/schema/config-schema.js.map +1 -1
- package/build/api/schema/input-source/load.d.ts +2 -0
- package/build/api/schema/input-source/load.d.ts.map +1 -1
- package/build/api/schema/input-source/load.js.map +1 -1
- package/build/api/schema/input-sources/directory.d.ts +39 -39
- package/build/api/schema/input-sources/file.d.ts +39 -39
- package/build/api/schema/input-sources/introspection-file.d.ts +39 -39
- package/build/api/schema/input-sources/introspection.d.ts +39 -39
- package/build/api/schema/input-sources/memory.d.ts +39 -39
- package/build/api/schema/input-sources/versioned-directory.d.ts +79 -79
- package/build/api/schema/load.d.ts.map +1 -1
- package/build/api/schema/load.js +9 -2
- package/build/api/schema/load.js.map +1 -1
- package/build/lib/catalog/catalog.d.ts +1181 -1181
- package/build/lib/catalog/unversioned.d.ts +312 -312
- package/build/lib/catalog/versioned.d.ts +634 -634
- package/build/lib/change/change.d.ts +238 -238
- package/build/lib/document/document.d.ts +14 -8
- package/build/lib/document/document.d.ts.map +1 -1
- package/build/lib/document/versioned.d.ts +17 -10
- package/build/lib/document/versioned.d.ts.map +1 -1
- package/build/lib/grafaid/schema/KindMap/_.d.ts +1 -1
- 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/lib/graphql-path/$$.d.ts +7 -13
- package/build/lib/graphql-path/$$.d.ts.map +1 -1
- package/build/lib/graphql-path/$$.js +7 -13
- package/build/lib/graphql-path/$$.js.map +1 -1
- package/build/lib/graphql-path/definition.d.ts +104 -94
- package/build/lib/graphql-path/definition.d.ts.map +1 -1
- package/build/lib/graphql-path/definition.js +126 -125
- package/build/lib/graphql-path/definition.js.map +1 -1
- package/build/lib/graphql-path/query.d.ts +25 -57
- package/build/lib/graphql-path/query.d.ts.map +1 -1
- package/build/lib/graphql-path/query.js +15 -93
- package/build/lib/graphql-path/query.js.map +1 -1
- package/build/lib/graphql-path/schema.d.ts +49 -0
- package/build/lib/graphql-path/schema.d.ts.map +1 -0
- package/build/lib/graphql-path/schema.js +89 -0
- package/build/lib/graphql-path/schema.js.map +1 -0
- package/build/lib/graphql-path/types.d.ts +76 -28
- package/build/lib/graphql-path/types.d.ts.map +1 -1
- package/build/lib/graphql-path/types.js +101 -2
- package/build/lib/graphql-path/types.js.map +1 -1
- package/build/lib/revision/revision.d.ts +1170 -1170
- package/build/lib/schema/schema.d.ts +708 -708
- package/build/lib/schema/unversioned.d.ts +1092 -1092
- package/build/lib/schema/versioned.d.ts +634 -634
- package/build/lib/semver/official-release.d.ts +10 -10
- package/build/lib/semver/pre-release.d.ts +10 -10
- package/build/lib/semver/semver.d.ts +50 -50
- package/build/lib/version-coverage/version-coverage.d.ts +43 -11
- package/build/lib/version-coverage/version-coverage.d.ts.map +1 -1
- package/build/lib/version-coverage/version-coverage.js +40 -6
- package/build/lib/version-coverage/version-coverage.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 +4 -1
- 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/changelog/ChangelogSidebar.d.ts +2 -2
- package/build/template/routes/changelog/ChangelogSidebar.d.ts.map +1 -1
- package/build/template/routes/changelog/ChangelogSidebar.js +4 -4
- package/build/template/routes/changelog/ChangelogSidebar.js.map +1 -1
- package/build/template/routes/examples/_.d.ts +12 -3
- package/build/template/routes/examples/_.d.ts.map +1 -1
- package/build/template/routes/examples/_index.d.ts +8 -2
- package/build/template/routes/examples/_index.d.ts.map +1 -1
- package/build/template/routes/examples/name.d.ts +12 -3
- 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/template/stores/changelog.d.ts +39 -39
- 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 -3
- 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/build/vite/plugins/schemas.d.ts.map +1 -1
- package/build/vite/plugins/schemas.js +38 -2
- package/build/vite/plugins/schemas.js.map +1 -1
- 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/diagnostic/diagnostic.ts +0 -3
- package/src/api/examples/scanner.test.ts +83 -0
- package/src/api/examples/scanner.ts +31 -21
- 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/api/schema/augmentations/$$.ts +6 -0
- package/src/api/schema/augmentations/$.ts +1 -1
- package/src/api/schema/augmentations/apply.test.ts +89 -0
- package/src/api/schema/augmentations/apply.ts +277 -0
- package/src/api/schema/augmentations/augmentation.ts +24 -0
- package/src/api/schema/augmentations/config.ts +11 -0
- package/src/api/schema/augmentations/diagnostics/diagnostic.ts +20 -0
- package/src/api/schema/augmentations/diagnostics/duplicate-version.ts +20 -0
- package/src/api/schema/augmentations/diagnostics/invalid-path.ts +21 -0
- package/src/api/schema/augmentations/diagnostics/version-mismatch.ts +21 -0
- package/src/api/schema/augmentations/input.test.ts +144 -0
- package/src/api/schema/augmentations/input.ts +215 -0
- package/src/api/schema/augmentations/placement.ts +11 -0
- package/src/api/schema/config-schema.ts +2 -2
- package/src/api/schema/input-source/load.ts +2 -0
- package/src/api/schema/load.ts +19 -2
- package/src/lib/grafaid/schema/format-default-value.ts +22 -0
- package/src/lib/grafaid/schema/schema.ts +2 -0
- package/src/lib/graphql-path/$$.ts +7 -13
- package/src/lib/graphql-path/$.test.ts +175 -0
- package/src/lib/graphql-path/definition.ts +162 -162
- package/src/lib/graphql-path/query.ts +15 -98
- package/src/lib/graphql-path/schema.ts +136 -0
- package/src/lib/graphql-path/types.ts +108 -28
- package/src/lib/version-coverage/version-coverage.ts +48 -6
- 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/changelog/ChangelogSidebar.tsx +4 -4
- 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 -2
- 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/src/vite/plugins/schemas.ts +51 -2
- package/build/api/examples/diagnostic/unused-default.d.ts +0 -49
- package/build/api/examples/diagnostic/unused-default.d.ts.map +0 -1
- package/build/api/examples/diagnostic/unused-default.js +0 -19
- package/build/api/examples/diagnostic/unused-default.js.map +0 -1
- package/build/api/schema/augmentations/augmentations/description.d.ts +0 -26
- package/build/api/schema/augmentations/augmentations/description.d.ts.map +0 -1
- package/build/api/schema/augmentations/augmentations/description.js +0 -55
- package/build/api/schema/augmentations/augmentations/description.js.map +0 -1
- package/build/api/schema/augmentations/schema-augmentation.d.ts +0 -20
- package/build/api/schema/augmentations/schema-augmentation.d.ts.map +0 -1
- package/build/api/schema/augmentations/schema-augmentation.js +0 -22
- package/build/api/schema/augmentations/schema-augmentation.js.map +0 -1
- package/build/api/schema/augmentations/target.d.ts +0 -25
- package/build/api/schema/augmentations/target.d.ts.map +0 -1
- package/build/api/schema/augmentations/target.js +0 -39
- package/build/api/schema/augmentations/target.js.map +0 -1
- package/build/lib/graphql-path/constructors.d.ts +0 -57
- package/build/lib/graphql-path/constructors.d.ts.map +0 -1
- package/build/lib/graphql-path/constructors.js +0 -73
- package/build/lib/graphql-path/constructors.js.map +0 -1
- 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/api/examples/diagnostic/unused-default.ts +0 -22
- package/src/api/schema/augmentations/augmentations/description.ts +0 -69
- package/src/api/schema/augmentations/schema-augmentation.ts +0 -32
- package/src/api/schema/augmentations/target.ts +0 -61
- package/src/lib/graphql-path/constructors.ts +0 -81
- package/src/template/components/ArgumentList.tsx +0 -22
@@ -0,0 +1,175 @@
|
|
1
|
+
import { S } from '#lib/kit-temp/effect'
|
2
|
+
import { describe, expect, test } from 'vitest'
|
3
|
+
import { GraphQLPath } from './$.js'
|
4
|
+
|
5
|
+
describe('decode', () => {
|
6
|
+
test.for([
|
7
|
+
['User', [{ _tag: 'TypeSegment', type: 'User' }]],
|
8
|
+
['User.name', [
|
9
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
10
|
+
{ _tag: 'FieldSegment', field: 'name' },
|
11
|
+
]],
|
12
|
+
['User.posts(limit)', [
|
13
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
14
|
+
{ _tag: 'FieldSegment', field: 'posts' },
|
15
|
+
{ _tag: 'ArgumentSegment', argument: 'limit' },
|
16
|
+
]],
|
17
|
+
])('decodes "%s"', ([input, expected]) => {
|
18
|
+
expect(GraphQLPath.Definition.decodeSync(input)).toEqual(expected)
|
19
|
+
})
|
20
|
+
|
21
|
+
test.for([
|
22
|
+
'',
|
23
|
+
'Type.field.extra',
|
24
|
+
'Type(arg)',
|
25
|
+
'.field',
|
26
|
+
'Type.',
|
27
|
+
])('throws on invalid format "%s"', (input) => {
|
28
|
+
expect(() => GraphQLPath.Definition.decodeSync(input)).toThrow()
|
29
|
+
})
|
30
|
+
})
|
31
|
+
|
32
|
+
describe('encode', () => {
|
33
|
+
test.for(
|
34
|
+
[
|
35
|
+
[GraphQLPath.Definition.type('User'), 'User'],
|
36
|
+
[GraphQLPath.Definition.field('User', 'name'), 'User.name'],
|
37
|
+
[GraphQLPath.Definition.argument('User', 'posts', 'limit'), 'User.posts(limit)'],
|
38
|
+
] as const,
|
39
|
+
)('encodes path to "%s"', ([path, expected]) => {
|
40
|
+
expect(GraphQLPath.Definition.encodeSync(path as any)).toBe(expected)
|
41
|
+
})
|
42
|
+
})
|
43
|
+
|
44
|
+
describe('round-trip', () => {
|
45
|
+
test.for([
|
46
|
+
'Query',
|
47
|
+
'Mutation',
|
48
|
+
'User',
|
49
|
+
'User.id',
|
50
|
+
'User.name',
|
51
|
+
'Query.users',
|
52
|
+
'User.posts(limit)',
|
53
|
+
'Query.search(query)',
|
54
|
+
'Mutation.createUser(input)',
|
55
|
+
])('round-trips "%s"', (pathString) => {
|
56
|
+
const decoded = GraphQLPath.Definition.decodeSync(pathString)
|
57
|
+
const encoded = GraphQLPath.Definition.encodeSync(decoded)
|
58
|
+
expect(encoded).toBe(pathString)
|
59
|
+
})
|
60
|
+
})
|
61
|
+
|
62
|
+
describe('type guards', () => {
|
63
|
+
const typePath = GraphQLPath.Definition.decodeSync('User')
|
64
|
+
const fieldPath = GraphQLPath.Definition.decodeSync('User.name')
|
65
|
+
const argPath = GraphQLPath.Definition.decodeSync('User.posts(limit)')
|
66
|
+
|
67
|
+
test('isTypeDefinitionPath', () => {
|
68
|
+
expect(GraphQLPath.Definition.isTypeDefinitionPath(typePath)).toBe(true)
|
69
|
+
expect(GraphQLPath.Definition.isTypeDefinitionPath(fieldPath)).toBe(false)
|
70
|
+
expect(GraphQLPath.Definition.isTypeDefinitionPath(argPath)).toBe(false)
|
71
|
+
})
|
72
|
+
|
73
|
+
test('isFieldDefinitionPath', () => {
|
74
|
+
expect(GraphQLPath.Definition.isFieldDefinitionPath(typePath)).toBe(false)
|
75
|
+
expect(GraphQLPath.Definition.isFieldDefinitionPath(fieldPath)).toBe(true)
|
76
|
+
expect(GraphQLPath.Definition.isFieldDefinitionPath(argPath)).toBe(false)
|
77
|
+
})
|
78
|
+
|
79
|
+
test('isArgumentDefinitionPath', () => {
|
80
|
+
expect(GraphQLPath.Definition.isArgumentDefinitionPath(typePath)).toBe(false)
|
81
|
+
expect(GraphQLPath.Definition.isArgumentDefinitionPath(fieldPath)).toBe(false)
|
82
|
+
expect(GraphQLPath.Definition.isArgumentDefinitionPath(argPath)).toBe(true)
|
83
|
+
})
|
84
|
+
|
85
|
+
test('Effect Schema derived segment type guards', async () => {
|
86
|
+
// Import from the types module directly since constructors re-exports them
|
87
|
+
const { isTypeSegment, isFieldSegment, isArgumentSegment } = await import('./types.js')
|
88
|
+
|
89
|
+
const typeSegment = { _tag: 'TypeSegment', type: 'User' } as const
|
90
|
+
const fieldSegment = { _tag: 'FieldSegment', field: 'name' } as const
|
91
|
+
const argSegment = { _tag: 'ArgumentSegment', argument: 'limit' } as const
|
92
|
+
|
93
|
+
// Test that Effect Schema derived guards work correctly
|
94
|
+
expect(isTypeSegment(typeSegment)).toBe(true)
|
95
|
+
expect(isTypeSegment(fieldSegment)).toBe(false)
|
96
|
+
expect(isFieldSegment(fieldSegment)).toBe(true)
|
97
|
+
expect(isFieldSegment(typeSegment)).toBe(false)
|
98
|
+
expect(isArgumentSegment(argSegment)).toBe(true)
|
99
|
+
expect(isArgumentSegment(typeSegment)).toBe(false)
|
100
|
+
})
|
101
|
+
})
|
102
|
+
|
103
|
+
describe('helper functions', () => {
|
104
|
+
test('getType extracts type from all path types', () => {
|
105
|
+
expect(GraphQLPath.Definition.getType(GraphQLPath.Definition.decodeSync('User'))).toBe('User')
|
106
|
+
expect(GraphQLPath.Definition.getType(GraphQLPath.Definition.decodeSync('User.name'))).toBe('User')
|
107
|
+
expect(GraphQLPath.Definition.getType(GraphQLPath.Definition.decodeSync('User.posts(limit)'))).toBe('User')
|
108
|
+
})
|
109
|
+
|
110
|
+
test('getField extracts field name', () => {
|
111
|
+
const fieldPath = GraphQLPath.Definition.decodeSync('User.name')
|
112
|
+
const argPath = GraphQLPath.Definition.decodeSync('User.posts(limit)')
|
113
|
+
|
114
|
+
if (GraphQLPath.Definition.isFieldDefinitionPath(fieldPath)) {
|
115
|
+
expect(GraphQLPath.Definition.getField(fieldPath)).toBe('name')
|
116
|
+
}
|
117
|
+
if (GraphQLPath.Definition.isArgumentDefinitionPath(argPath)) {
|
118
|
+
expect(GraphQLPath.Definition.getField(argPath)).toBe('posts')
|
119
|
+
}
|
120
|
+
})
|
121
|
+
|
122
|
+
test('getArgument extracts argument name', () => {
|
123
|
+
const argPath = GraphQLPath.Definition.decodeSync('User.posts(limit)')
|
124
|
+
if (GraphQLPath.Definition.isArgumentDefinitionPath(argPath)) {
|
125
|
+
expect(GraphQLPath.Definition.getArgument(argPath)).toBe('limit')
|
126
|
+
}
|
127
|
+
})
|
128
|
+
})
|
129
|
+
|
130
|
+
describe('constructors', () => {
|
131
|
+
test.for([
|
132
|
+
[GraphQLPath.Definition.type('User'), [{ _tag: 'TypeSegment', type: 'User' }]],
|
133
|
+
[GraphQLPath.Definition.field('User', 'name'), [
|
134
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
135
|
+
{ _tag: 'FieldSegment', field: 'name' },
|
136
|
+
]],
|
137
|
+
[GraphQLPath.Definition.argument('User', 'posts', 'limit'), [
|
138
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
139
|
+
{ _tag: 'FieldSegment', field: 'posts' },
|
140
|
+
{ _tag: 'ArgumentSegment', argument: 'limit' },
|
141
|
+
]],
|
142
|
+
])('constructor creates correct structure', ([result, expected]) => {
|
143
|
+
expect(result).toEqual(expected)
|
144
|
+
})
|
145
|
+
})
|
146
|
+
|
147
|
+
describe('Schema validation', () => {
|
148
|
+
test.for(
|
149
|
+
[
|
150
|
+
[GraphQLPath.Definition.TypeDefinitionPath, 'User', [{ _tag: 'TypeSegment', type: 'User' }]],
|
151
|
+
[GraphQLPath.Definition.FieldDefinitionPath, 'User.name', [
|
152
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
153
|
+
{ _tag: 'FieldSegment', field: 'name' },
|
154
|
+
]],
|
155
|
+
[GraphQLPath.Definition.ArgumentDefinitionPath, 'User.posts(limit)', [
|
156
|
+
{ _tag: 'TypeSegment', type: 'User' },
|
157
|
+
{ _tag: 'FieldSegment', field: 'posts' },
|
158
|
+
{ _tag: 'ArgumentSegment', argument: 'limit' },
|
159
|
+
]],
|
160
|
+
] as const,
|
161
|
+
)('validates through Effect Schema', ([schema, input, expected]) => {
|
162
|
+
const result = S.decodeUnknownSync(schema as any)(input)
|
163
|
+
expect(result).toEqual(expected)
|
164
|
+
})
|
165
|
+
|
166
|
+
test('union automatically selects correct type', () => {
|
167
|
+
const typePath = S.decodeUnknownSync(GraphQLPath.Definition.DefinitionPath)('User')
|
168
|
+
const fieldPath = S.decodeUnknownSync(GraphQLPath.Definition.DefinitionPath)('User.name')
|
169
|
+
const argPath = S.decodeUnknownSync(GraphQLPath.Definition.DefinitionPath)('User.posts(limit)')
|
170
|
+
|
171
|
+
expect(typePath.length).toBe(1)
|
172
|
+
expect(fieldPath.length).toBe(2)
|
173
|
+
expect(argPath.length).toBe(3)
|
174
|
+
})
|
175
|
+
})
|
@@ -1,73 +1,153 @@
|
|
1
1
|
/**
|
2
|
-
* Definition path operations
|
3
|
-
*/
|
4
|
-
|
5
|
-
import {
|
6
|
-
|
7
|
-
import
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
2
|
+
* Definition path operations using Effect Schema transforms
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { S } from '#lib/kit-temp/effect'
|
6
|
+
import { ParseResult } from 'effect'
|
7
|
+
import { ArgumentSegment, FieldSegment, TypeSegment } from './types.js'
|
8
|
+
|
9
|
+
// ============================================================================
|
10
|
+
// Internal Path Schemas (Decoded Forms)
|
11
|
+
// ============================================================================
|
12
|
+
|
13
|
+
const TypeDefinitionPathDecoded = S.Tuple(TypeSegment)
|
14
|
+
const FieldDefinitionPathDecoded = S.Tuple(TypeSegment, FieldSegment)
|
15
|
+
const ArgumentDefinitionPathDecoded = S.Tuple(TypeSegment, FieldSegment, ArgumentSegment)
|
16
|
+
|
17
|
+
// ============================================================================
|
18
|
+
// Transform Codecs (String <-> Struct)
|
19
|
+
// ============================================================================
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Type definition path codec
|
23
|
+
* Encoded: "User"
|
24
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }]
|
25
|
+
*/
|
26
|
+
export const TypeDefinitionPath = S.transformOrFail(
|
27
|
+
S.String,
|
28
|
+
TypeDefinitionPathDecoded,
|
29
|
+
{
|
30
|
+
decode: (str, _options, ast) => {
|
31
|
+
if (!str || str.includes('.') || str.includes('(')) {
|
32
|
+
return ParseResult.fail(new ParseResult.Type(ast, str))
|
33
|
+
}
|
34
|
+
return ParseResult.succeed([TypeSegment.make({ type: str })])
|
35
|
+
},
|
36
|
+
encode: (path) => ParseResult.succeed(path[0].type),
|
37
|
+
},
|
38
|
+
).annotations({
|
39
|
+
identifier: 'TypeDefinitionPath',
|
40
|
+
description: 'Path to a type definition',
|
41
|
+
})
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Field definition path codec
|
45
|
+
* Encoded: "User.name"
|
46
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'name' }]
|
47
|
+
*/
|
48
|
+
export const FieldDefinitionPath = S.transformOrFail(
|
49
|
+
S.String,
|
50
|
+
FieldDefinitionPathDecoded,
|
51
|
+
{
|
52
|
+
decode: (str, _options, ast) => {
|
53
|
+
const parts = str.split('.')
|
54
|
+
if (parts.length !== 2 || !parts[0] || !parts[1] || str.includes('(')) {
|
55
|
+
return ParseResult.fail(new ParseResult.Type(ast, str))
|
56
|
+
}
|
57
|
+
return ParseResult.succeed([
|
58
|
+
TypeSegment.make({ type: parts[0] }),
|
59
|
+
FieldSegment.make({ field: parts[1] }),
|
60
|
+
])
|
61
|
+
},
|
62
|
+
encode: (path) => ParseResult.succeed(`${path[0].type}.${path[1].field}`),
|
63
|
+
},
|
64
|
+
).annotations({
|
65
|
+
identifier: 'FieldDefinitionPath',
|
66
|
+
description: 'Path to a field definition',
|
67
|
+
})
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Argument definition path codec
|
71
|
+
* Encoded: "User.posts(limit)"
|
72
|
+
* Decoded: [{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'posts' }, { _tag: 'ArgumentSegment', argument: 'limit' }]
|
73
|
+
*/
|
74
|
+
export const ArgumentDefinitionPath = S.transformOrFail(
|
75
|
+
S.String,
|
76
|
+
ArgumentDefinitionPathDecoded,
|
77
|
+
{
|
78
|
+
decode: (str, _options, ast) => {
|
79
|
+
const match = str.match(/^([^.]+)\.([^.(]+)\(([^)]+)\)$/)
|
80
|
+
if (!match || !match[1] || !match[2] || !match[3]) {
|
81
|
+
return ParseResult.fail(new ParseResult.Type(ast, str))
|
82
|
+
}
|
83
|
+
return ParseResult.succeed([
|
84
|
+
TypeSegment.make({ type: match[1] }),
|
85
|
+
FieldSegment.make({ field: match[2] }),
|
86
|
+
ArgumentSegment.make({ argument: match[3] }),
|
87
|
+
])
|
88
|
+
},
|
89
|
+
encode: (path) => ParseResult.succeed(`${path[0].type}.${path[1].field}(${path[2].argument})`),
|
90
|
+
},
|
91
|
+
).annotations({
|
92
|
+
identifier: 'ArgumentDefinitionPath',
|
93
|
+
description: 'Path to an argument definition',
|
94
|
+
})
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Union of all definition paths
|
98
|
+
* Automatically determines the correct path type from the string format
|
99
|
+
*/
|
100
|
+
export const DefinitionPath = S.Union(
|
101
|
+
ArgumentDefinitionPath, // Check argument first (most specific)
|
102
|
+
FieldDefinitionPath, // Then field
|
103
|
+
TypeDefinitionPath, // Then type (least specific)
|
104
|
+
).annotations({
|
105
|
+
identifier: 'DefinitionPath',
|
106
|
+
description: 'Union of all definition path types',
|
107
|
+
})
|
108
|
+
|
109
|
+
// ============================================================================
|
110
|
+
// Type Exports
|
111
|
+
// ============================================================================
|
112
|
+
|
113
|
+
export type TypeDefinitionPath = S.Schema.Type<typeof TypeDefinitionPath>
|
114
|
+
export type FieldDefinitionPath = S.Schema.Type<typeof FieldDefinitionPath>
|
115
|
+
export type ArgumentDefinitionPath = S.Schema.Type<typeof ArgumentDefinitionPath>
|
116
|
+
export type DefinitionPath = S.Schema.Type<typeof DefinitionPath>
|
117
|
+
|
118
|
+
// ============================================================================
|
119
|
+
// Codec Functions
|
120
|
+
// ============================================================================
|
28
121
|
|
29
122
|
/**
|
30
123
|
* Decode a string expression into a definition path
|
31
|
-
*
|
32
124
|
* @param expression - The string expression to decode
|
33
|
-
* @returns The decoded definition path
|
125
|
+
* @returns The decoded definition path
|
34
126
|
* @example
|
35
127
|
* decode('User') // type definition path
|
36
128
|
* decode('User.name') // field definition path
|
37
129
|
* decode('User.posts(limit)') // argument definition path
|
38
130
|
*/
|
39
|
-
export const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
// Handle type path: Type
|
57
|
-
const typeMatch = expression.match(/^[^.]+$/)
|
58
|
-
if (typeMatch) {
|
59
|
-
return createTypeDefinitionPath(expression)
|
60
|
-
}
|
61
|
-
|
62
|
-
return null
|
63
|
-
}
|
131
|
+
export const decodeSync = S.decodeUnknownSync(DefinitionPath)
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Encode a definition path to a string expression
|
135
|
+
* @param path - The definition path to encode
|
136
|
+
* @returns A string expression representation
|
137
|
+
* @example
|
138
|
+
* encode([{ _tag: 'TypeSegment', type: 'User' }]) // 'User'
|
139
|
+
* encode([{ _tag: 'TypeSegment', type: 'User' }, { _tag: 'FieldSegment', field: 'name' }]) // 'User.name'
|
140
|
+
*/
|
141
|
+
export const encodeSync = S.encodeSync(DefinitionPath)
|
142
|
+
|
143
|
+
// ============================================================================
|
144
|
+
// Helper Functions
|
145
|
+
// ============================================================================
|
64
146
|
|
65
147
|
/**
|
66
148
|
* Extract the type name from any definition path
|
67
|
-
*
|
68
149
|
* @param path - The definition path
|
69
150
|
* @returns The type name
|
70
|
-
* @example getType([{ kind: 'type', type: 'User' }]) // 'User'
|
71
151
|
*/
|
72
152
|
export const getType = (path: DefinitionPath): string => {
|
73
153
|
return path[0].type
|
@@ -75,10 +155,8 @@ export const getType = (path: DefinitionPath): string => {
|
|
75
155
|
|
76
156
|
/**
|
77
157
|
* Extract the field name from a field or argument definition path
|
78
|
-
*
|
79
158
|
* @param path - The field or argument definition path
|
80
159
|
* @returns The field name
|
81
|
-
* @example getField([{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]) // 'name'
|
82
160
|
*/
|
83
161
|
export const getField = (path: FieldDefinitionPath | ArgumentDefinitionPath): string => {
|
84
162
|
return path[1].field
|
@@ -86,155 +164,77 @@ export const getField = (path: FieldDefinitionPath | ArgumentDefinitionPath): st
|
|
86
164
|
|
87
165
|
/**
|
88
166
|
* Extract the argument name from an argument definition path
|
89
|
-
*
|
90
167
|
* @param path - The argument definition path
|
91
168
|
* @returns The argument name
|
92
|
-
* @example getArgument([{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]) // 'limit'
|
93
169
|
*/
|
94
170
|
export const getArgument = (path: ArgumentDefinitionPath): string => {
|
95
171
|
return path[2].argument
|
96
172
|
}
|
97
173
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
export const parseFieldPath = (path?: string): { typeName: string | null; fieldName: string | null } => {
|
102
|
-
if (!path) return { typeName: null, fieldName: null }
|
103
|
-
|
104
|
-
const parts = path.split('.')
|
105
|
-
if (parts.length >= 2) {
|
106
|
-
return {
|
107
|
-
typeName: parts[0] || null,
|
108
|
-
fieldName: parts[1] || null,
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
return { typeName: null, fieldName: null }
|
113
|
-
}
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Definition paths - direct paths to schema definition elements
|
117
|
-
* These represent the "address" of a specific schema element
|
118
|
-
*/
|
119
|
-
export type DefinitionPath =
|
120
|
-
| TypeDefinitionPath
|
121
|
-
| FieldDefinitionPath
|
122
|
-
| ArgumentDefinitionPath
|
123
|
-
|
124
|
-
/**
|
125
|
-
* Path to a type definition
|
126
|
-
* @example [{ kind: 'type', type: 'User' }]
|
127
|
-
*/
|
128
|
-
export type TypeDefinitionPath = [TypeSegment]
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Path to a field definition (type + field)
|
132
|
-
* @example [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]
|
133
|
-
*/
|
134
|
-
export type FieldDefinitionPath = [TypeSegment, FieldSegment]
|
135
|
-
|
136
|
-
/**
|
137
|
-
* Path to an argument definition (type + field + argument)
|
138
|
-
* @example [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]
|
139
|
-
*/
|
140
|
-
export type ArgumentDefinitionPath = [TypeSegment, FieldSegment, ArgumentSegment]
|
174
|
+
// ============================================================================
|
175
|
+
// Type Guards
|
176
|
+
// ============================================================================
|
141
177
|
|
142
178
|
/**
|
143
179
|
* Type guard to check if a path is a type definition path
|
144
|
-
*
|
145
|
-
* @param path - The path to check
|
146
|
-
* @returns True if the path is a type definition path
|
147
180
|
*/
|
148
181
|
export const isTypeDefinitionPath = (path: DefinitionPath): path is TypeDefinitionPath => {
|
149
|
-
return path.length === 1 && path[0].
|
182
|
+
return path.length === 1 && path[0]._tag === 'TypeSegment'
|
150
183
|
}
|
151
184
|
|
152
185
|
/**
|
153
186
|
* Type guard to check if a path is a field definition path
|
154
|
-
*
|
155
|
-
* @param path - The path to check
|
156
|
-
* @returns True if the path is a field definition path
|
157
187
|
*/
|
158
188
|
export const isFieldDefinitionPath = (path: DefinitionPath): path is FieldDefinitionPath => {
|
159
|
-
return path.length === 2 && path[0].
|
189
|
+
return path.length === 2 && path[0]._tag === 'TypeSegment' && path[1]._tag === 'FieldSegment'
|
160
190
|
}
|
161
191
|
|
162
192
|
/**
|
163
193
|
* Type guard to check if a path is an argument definition path
|
164
|
-
*
|
165
|
-
* @param path - The path to check
|
166
|
-
* @returns True if the path is an argument definition path
|
167
194
|
*/
|
168
195
|
export const isArgumentDefinitionPath = (path: DefinitionPath): path is ArgumentDefinitionPath => {
|
169
|
-
return
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
* @param type - The type name
|
176
|
-
* @returns A type definition path
|
177
|
-
* @example createTypeDefinitionPath('User') // [{ kind: 'type', type: 'User' }]
|
178
|
-
*/
|
179
|
-
export const createTypeDefinitionPath = (type: string): TypeDefinitionPath => {
|
180
|
-
return [createTypeSegment(type)]
|
181
|
-
}
|
182
|
-
|
183
|
-
/**
|
184
|
-
* Create a path to a field definition
|
185
|
-
*
|
186
|
-
* @param type - The type name
|
187
|
-
* @param field - The field name
|
188
|
-
* @returns A field definition path
|
189
|
-
* @example createFieldDefinitionPath('User', 'name') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]
|
190
|
-
*/
|
191
|
-
export const createFieldDefinitionPath = (type: string, field: string): FieldDefinitionPath => {
|
192
|
-
return [createTypeSegment(type), createFieldSegment(field)]
|
196
|
+
return (
|
197
|
+
path.length === 3
|
198
|
+
&& path[0]._tag === 'TypeSegment'
|
199
|
+
&& path[1]._tag === 'FieldSegment'
|
200
|
+
&& path[2]._tag === 'ArgumentSegment'
|
201
|
+
)
|
193
202
|
}
|
194
203
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
* @param type - The type name
|
199
|
-
* @param field - The field name
|
200
|
-
* @param argument - The argument name
|
201
|
-
* @returns An argument definition path
|
202
|
-
* @example createArgumentDefinitionPath('User', 'posts', 'limit') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]
|
203
|
-
*/
|
204
|
-
export const createArgumentDefinitionPath = (
|
205
|
-
type: string,
|
206
|
-
field: string,
|
207
|
-
argument: string,
|
208
|
-
): ArgumentDefinitionPath => {
|
209
|
-
return [createTypeSegment(type), createFieldSegment(field), createArgumentSegment(argument)]
|
210
|
-
}
|
204
|
+
// ============================================================================
|
205
|
+
// Constructor Functions
|
206
|
+
// ============================================================================
|
211
207
|
|
212
208
|
/**
|
213
209
|
* Create a type definition path
|
214
|
-
*
|
215
210
|
* @param type - The type name
|
216
211
|
* @returns A type definition path
|
217
|
-
* @example type('User') // [{ kind: 'type', type: 'User' }]
|
218
212
|
*/
|
219
|
-
export const type =
|
213
|
+
export const type = (typeName: string): TypeDefinitionPath => {
|
214
|
+
return [TypeSegment.make({ type: typeName })]
|
215
|
+
}
|
220
216
|
|
221
217
|
/**
|
222
218
|
* Create a field definition path
|
223
|
-
*
|
224
219
|
* @param type - The type name
|
225
220
|
* @param field - The field name
|
226
221
|
* @returns A field definition path
|
227
|
-
* @example field('User', 'name') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'name' }]
|
228
222
|
*/
|
229
|
-
export const field =
|
223
|
+
export const field = (typeName: string, fieldName: string): FieldDefinitionPath => {
|
224
|
+
return [TypeSegment.make({ type: typeName }), FieldSegment.make({ field: fieldName })]
|
225
|
+
}
|
230
226
|
|
231
227
|
/**
|
232
228
|
* Create an argument definition path
|
233
|
-
*
|
234
229
|
* @param type - The type name
|
235
230
|
* @param field - The field name
|
236
231
|
* @param argument - The argument name
|
237
232
|
* @returns An argument definition path
|
238
|
-
* @example argument('User', 'posts', 'limit') // [{ kind: 'type', type: 'User' }, { kind: 'field', field: 'posts' }, { kind: 'argument', argument: 'limit' }]
|
239
233
|
*/
|
240
|
-
export const argument =
|
234
|
+
export const argument = (typeName: string, fieldName: string, argumentName: string): ArgumentDefinitionPath => {
|
235
|
+
return [
|
236
|
+
TypeSegment.make({ type: typeName }),
|
237
|
+
FieldSegment.make({ field: fieldName }),
|
238
|
+
ArgumentSegment.make({ argument: argumentName }),
|
239
|
+
]
|
240
|
+
}
|