graphql 17.0.0-rc.0 → 17.0.0
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/README.md +3 -5
- package/diagnostics.d.mts +67 -38
- package/diagnostics.d.ts +67 -38
- package/diagnostics.js.map +1 -1
- package/diagnostics.mjs.map +1 -1
- package/error/locatedError.d.mts +1 -3
- package/error/locatedError.d.ts +1 -3
- package/error/locatedError.js.map +1 -1
- package/error/locatedError.mjs.map +1 -1
- package/execution/Executor.d.mts +2 -2
- package/execution/Executor.d.ts +2 -2
- package/execution/Executor.js.map +1 -1
- package/execution/Executor.mjs.map +1 -1
- package/execution/execute.d.mts +65 -44
- package/execution/execute.d.ts +65 -44
- package/execution/execute.js +11 -2
- package/execution/execute.js.map +1 -1
- package/execution/execute.mjs +11 -2
- package/execution/execute.mjs.map +1 -1
- package/execution/values.d.mts +17 -17
- package/execution/values.d.ts +17 -17
- package/execution/values.js.map +1 -1
- package/execution/values.mjs.map +1 -1
- package/language/parser.d.mts +20 -30
- package/language/parser.d.ts +20 -30
- package/language/parser.js +3 -9
- package/language/parser.js.map +1 -1
- package/language/parser.mjs +3 -9
- package/language/parser.mjs.map +1 -1
- package/language/predicates.d.mts +5 -1
- package/language/predicates.d.ts +5 -1
- package/language/predicates.js.map +1 -1
- package/language/predicates.mjs.map +1 -1
- package/language/source.d.mts +4 -5
- package/language/source.d.ts +4 -5
- package/language/source.js.map +1 -1
- package/language/source.mjs.map +1 -1
- package/language/visitor.d.mts +10 -2
- package/language/visitor.d.ts +10 -2
- package/language/visitor.js.map +1 -1
- package/language/visitor.mjs.map +1 -1
- package/package.json +2 -2
- package/type/definition.d.mts +96 -64
- package/type/definition.d.ts +96 -64
- package/type/definition.js.map +1 -1
- package/type/definition.mjs.map +1 -1
- package/type/directives.d.mts +3 -3
- package/type/directives.d.ts +3 -3
- package/type/directives.js.map +1 -1
- package/type/directives.mjs.map +1 -1
- package/type/schema.d.mts +4 -8
- package/type/schema.d.ts +4 -8
- package/type/schema.js.map +1 -1
- package/type/schema.mjs.map +1 -1
- package/type/validate.js +101 -30
- package/type/validate.js.map +1 -1
- package/type/validate.mjs +101 -30
- package/type/validate.mjs.map +1 -1
- package/utilities/TypeInfo.d.mts +1 -1
- package/utilities/TypeInfo.d.ts +1 -1
- package/utilities/TypeInfo.js.map +1 -1
- package/utilities/TypeInfo.mjs.map +1 -1
- package/utilities/buildASTSchema.d.mts +0 -1
- package/utilities/buildASTSchema.d.ts +0 -1
- package/utilities/buildASTSchema.js +0 -1
- package/utilities/buildASTSchema.js.map +1 -1
- package/utilities/buildASTSchema.mjs +0 -1
- package/utilities/buildASTSchema.mjs.map +1 -1
- package/utilities/buildClientSchema.d.mts +5 -1
- package/utilities/buildClientSchema.d.ts +5 -1
- package/utilities/buildClientSchema.js.map +1 -1
- package/utilities/buildClientSchema.mjs.map +1 -1
- package/utilities/coerceInputValue.d.mts +7 -6
- package/utilities/coerceInputValue.d.ts +7 -6
- package/utilities/coerceInputValue.js.map +1 -1
- package/utilities/coerceInputValue.mjs.map +1 -1
- package/utilities/concatAST.d.mts +4 -1
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js.map +1 -1
- package/utilities/concatAST.mjs.map +1 -1
- package/utilities/extendSchema.d.mts +3 -3
- package/utilities/extendSchema.d.ts +3 -3
- package/utilities/extendSchema.js +5 -1
- package/utilities/extendSchema.js.map +1 -1
- package/utilities/extendSchema.mjs +5 -1
- package/utilities/extendSchema.mjs.map +1 -1
- package/utilities/introspectionFromSchema.d.mts +6 -2
- package/utilities/introspectionFromSchema.d.ts +6 -2
- package/utilities/introspectionFromSchema.js.map +1 -1
- package/utilities/introspectionFromSchema.mjs.map +1 -1
- package/utilities/lexicographicSortSchema.d.mts +5 -1
- package/utilities/lexicographicSortSchema.d.ts +5 -1
- package/utilities/lexicographicSortSchema.js.map +1 -1
- package/utilities/lexicographicSortSchema.mjs.map +1 -1
- package/utilities/printSchema.d.mts +5 -1
- package/utilities/printSchema.d.ts +5 -1
- package/utilities/printSchema.js.map +1 -1
- package/utilities/printSchema.mjs.map +1 -1
- package/utilities/replaceVariables.d.mts +4 -8
- package/utilities/replaceVariables.d.ts +4 -8
- package/utilities/replaceVariables.js.map +1 -1
- package/utilities/replaceVariables.mjs.map +1 -1
- package/utilities/stripIgnoredCharacters.d.mts +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +2 -2
- package/utilities/stripIgnoredCharacters.js.map +1 -1
- package/utilities/stripIgnoredCharacters.mjs.map +1 -1
- package/utilities/typeComparators.d.mts +1 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js.map +1 -1
- package/utilities/typeComparators.mjs.map +1 -1
- package/utilities/validateInputValue.d.mts +10 -8
- package/utilities/validateInputValue.d.ts +10 -8
- package/utilities/validateInputValue.js.map +1 -1
- package/utilities/validateInputValue.mjs.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +4 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
- package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.d.mts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -2
- package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
- package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.mts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +3 -1
- package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
- package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -2
- package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.d.mts +3 -1
- package/validation/rules/KnownArgumentNamesRule.d.ts +3 -1
- package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
- package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/KnownDirectivesRule.js +2 -1
- package/validation/rules/KnownDirectivesRule.js.map +1 -1
- package/validation/rules/KnownDirectivesRule.mjs +2 -1
- package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.d.mts +3 -1
- package/validation/rules/KnownFragmentNamesRule.d.ts +3 -1
- package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
- package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.d.mts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -2
- package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
- package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.d.mts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -2
- package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
- package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
- package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.d.mts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.d.ts +3 -1
- package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
- package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.d.mts +3 -1
- package/validation/rules/NoUnusedVariablesRule.d.ts +3 -1
- package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
- package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +6 -2
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.d.mts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -2
- package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
- package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -2
- package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.d.mts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -2
- package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
- package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -2
- package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.d.mts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.d.ts +3 -1
- package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
- package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.d.mts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -2
- package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.d.mts +3 -1
- package/validation/rules/UniqueOperationNamesRule.d.ts +3 -1
- package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
- package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.d.mts +3 -1
- package/validation/rules/UniqueVariableNamesRule.d.ts +3 -1
- package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
- package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.mts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +3 -1
- package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
- package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.d.mts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -2
- package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
- package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.d.mts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -2
- package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
- package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +3 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +6 -2
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
- package/validation/validate.d.mts +3 -6
- package/validation/validate.d.ts +3 -6
- package/validation/validate.js.map +1 -1
- package/validation/validate.mjs.map +1 -1
- package/version.js +2 -2
- package/version.js.map +1 -1
- package/version.mjs +2 -2
- package/version.mjs.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeInfo.js","sourceRoot":"","sources":["../../src/utilities/TypeInfo.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,4BAA2B;AAC5C,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C,OAAO,EAAE,oBAAoB,EAAE,gCAA+B;AAY9D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,GACb,+BAA8B;AAI/B,OAAO,EAAE,WAAW,EAAE,0BAAyB;AAa/C,MAAM,OAAO,QAAQ;IAyFnB,YACE,MAAqB,EAKrB,WAAgC,EAChC,kBAEC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,yBAAyB,GAAG,kBAAkB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACpE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC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;oBACzB,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,IAAI;YACX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;YAC1D,IAAI,MAAM,CAAC;YACX,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Type Info */\n\nimport type { Maybe } from '../jsutils/Maybe.ts';\n\nimport type {\n ASTNode,\n DocumentNode,\n FragmentDefinitionNode,\n VariableDefinitionNode,\n} from '../language/ast.ts';\nimport { isNode } from '../language/ast.ts';\nimport { Kind } from '../language/kinds.ts';\nimport type { ASTVisitor } from '../language/visitor.ts';\nimport { getEnterLeaveForKind } from '../language/visitor.ts';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n getNamedType,\n getNullableType,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isListType,\n isObjectType,\n isOutputType,\n} from '../type/definition.ts';\nimport type { GraphQLDirective } from '../type/directives.ts';\nimport type { GraphQLSchema } from '../type/schema.ts';\n\nimport { typeFromAST } from './typeFromAST.ts';\n\n/** @internal */\nexport interface FragmentSignature {\n readonly definition: FragmentDefinitionNode;\n readonly variableDefinitions: Map<string, VariableDefinitionNode>;\n}\n\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\nexport class TypeInfo {\n private _schema: GraphQLSchema;\n private _typeStack: Array<Maybe<GraphQLOutputType>>;\n private _parentTypeStack: Array<Maybe<GraphQLCompositeType>>;\n private _inputTypeStack: Array<Maybe<GraphQLInputType>>;\n private _fieldDefStack: Array<Maybe<GraphQLField<unknown, unknown>>>;\n private _defaultValueStack: Array<unknown>;\n private _directive: Maybe<GraphQLDirective>;\n private _argument: Maybe<GraphQLArgument>;\n private _enumValue: Maybe<GraphQLEnumValue>;\n private _fragmentSignaturesByName: (\n fragmentName: string,\n ) => Maybe<FragmentSignature>;\n\n private _fragmentSignature: Maybe<FragmentSignature>;\n private _fragmentArgument: Maybe<VariableDefinitionNode>;\n\n /**\n * Creates a TypeInfo instance.\n * @param schema - Schema used for type lookups.\n * @param initialType - Optional type to use at the start of traversal.\n * @param fragmentSignatures - Fragment signatures available during traversal.\n * @example\n * ```ts\n * // Track field types during a visitWithTypeInfo traversal.\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema } from 'graphql/utilities';\n * import { TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const seenTypes = [];\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: () => {\n * seenTypes.push(String(typeInfo.getType()));\n * },\n * }),\n * );\n *\n * seenTypes; // => ['String']\n * ```\n * @example\n * ```ts\n * // This variant starts from an initial type and supplies fragment signatures.\n * import { Kind, parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting(name: String): String\n * }\n * `);\n * const fragmentDocument = parse(\n * 'fragment GreetingFields($name: String) on Query { greeting(name: $name) }',\n * { experimentalFragmentArguments: true },\n * );\n * const fragmentDefinition = fragmentDocument.definitions[0];\n * const variableDefinition = fragmentDefinition.variableDefinitions[0];\n * const typeInfo = new TypeInfo(schema, schema.getQueryType(), (name) =>\n * name === 'GreetingFields'\n * ? {\n * definition: fragmentDefinition,\n * variableDefinitions: new Map([ ['name', variableDefinition] ]),\n * }\n * : undefined,\n * );\n *\n * typeInfo.enter({\n * kind: Kind.SELECTION_SET,\n * selections: [],\n * });\n * typeInfo.enter({\n * kind: Kind.FRAGMENT_SPREAD,\n * name: { kind: Kind.NAME, value: 'GreetingFields' },\n * arguments: [],\n * directives: [],\n * });\n *\n * String(typeInfo.getParentType()); // => 'Query'\n * typeInfo.getFragmentSignature()?.definition.name.value; // => 'GreetingFields'\n * ```\n */\n constructor(\n schema: GraphQLSchema,\n /**\n * Initial type may be provided in rare cases to facilitate traversals\n * beginning somewhere other than documents.\n */\n initialType?: Maybe<GraphQLType>,\n fragmentSignatures?: Maybe<\n (fragmentName: string) => Maybe<FragmentSignature>\n >,\n ) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._fragmentSignaturesByName = fragmentSignatures ?? (() => null);\n this._fragmentSignature = null;\n this._fragmentArgument = null;\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'TypeInfo';\n }\n\n /**\n * Returns the current output type at this point in traversal.\n * @returns The current output type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * viewer: User\n * }\n *\n * type User {\n * name: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const fieldTypes = {};\n *\n * visit(\n * parse('{ viewer { name } }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * fieldTypes[node.name.value] = String(typeInfo.getType());\n * },\n * }),\n * );\n *\n * fieldTypes; // => { viewer: 'User', name: 'String' }\n * ```\n */\n getType(): Maybe<GraphQLOutputType> {\n return this._typeStack.at(-1);\n }\n\n /**\n * Returns the current parent composite type.\n * @returns The current parent composite type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * viewer: User\n * }\n *\n * type User {\n * name: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const parentTypes = {};\n *\n * visit(\n * parse('{ viewer { name } }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * parentTypes[node.name.value] = String(typeInfo.getParentType());\n * },\n * }),\n * );\n *\n * parentTypes; // => { viewer: 'Query', name: 'User' }\n * ```\n */\n getParentType(): Maybe<GraphQLCompositeType> {\n return this._parentTypeStack.at(-1);\n }\n\n /**\n * Returns the current input type at this point in traversal.\n * @returns The current input type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(stars: Int!, sort: Sort = NEWEST): [String]\n * }\n *\n * enum Sort {\n * NEWEST\n * OLDEST\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const inputTypes = {};\n *\n * visit(\n * parse('{ reviews(stars: 5, sort: OLDEST) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: (node) => {\n * inputTypes[node.name.value] = String(typeInfo.getInputType());\n * },\n * }),\n * );\n *\n * inputTypes; // => { stars: 'Int!', sort: 'Sort' }\n * ```\n */\n getInputType(): Maybe<GraphQLInputType> {\n return this._inputTypeStack.at(-1);\n }\n\n // Note: continues to expose the closest enclosing valid input type if\n // traversal descends into syntax with no corresponding GraphQL input type.\n /**\n * Returns the parent input type for the current input position.\n * @returns The parent input type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * input ReviewFilter {\n * stars: Int!\n * }\n *\n * type Query {\n * reviews(filter: ReviewFilter): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const parentInputTypes = {};\n *\n * visit(\n * parse('{ reviews(filter: { stars: 5 }) }'),\n * visitWithTypeInfo(typeInfo, {\n * ObjectField: (node) => {\n * parentInputTypes[node.name.value] = String(typeInfo.getParentInputType());\n * },\n * }),\n * );\n *\n * parentInputTypes; // => { stars: 'ReviewFilter' }\n * ```\n */\n getParentInputType(): Maybe<GraphQLInputType> {\n return this._inputTypeStack.at(-2);\n }\n\n /**\n * Returns the current field definition.\n * @returns The current field definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let fieldName;\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: () => {\n * fieldName = typeInfo.getFieldDef()?.name;\n * },\n * }),\n * );\n *\n * fieldName; // => 'greeting'\n * ```\n */\n getFieldDef(): Maybe<GraphQLField<unknown, unknown>> {\n return this._fieldDefStack.at(-1);\n }\n\n /**\n * Returns the default input representation for the current input position.\n * @returns The current default input, if one is available.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(limit: Int = 10): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let defaultLimit;\n *\n * visit(\n * parse('{ reviews(limit: 5) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: () => {\n * defaultLimit = typeInfo.getDefaultValue();\n * },\n * }),\n * );\n *\n * defaultLimit; // => { literal: { kind: 'IntValue', value: '10' } }\n * ```\n */\n getDefaultValue(): unknown {\n return this._defaultValueStack.at(-1);\n }\n\n /**\n * Returns the current directive definition.\n * @returns The current directive definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let directiveName;\n *\n * visit(\n * parse('{ greeting @include(if: true) }'),\n * visitWithTypeInfo(typeInfo, {\n * Directive: () => {\n * directiveName = typeInfo.getDirective()?.name;\n * },\n * }),\n * );\n *\n * directiveName; // => 'include'\n * ```\n */\n getDirective(): Maybe<GraphQLDirective> {\n return this._directive;\n }\n\n /**\n * Returns the current argument definition.\n * @returns The current argument definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(limit: Int = 10): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let argumentName;\n *\n * visit(\n * parse('{ reviews(limit: 5) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: () => {\n * argumentName = typeInfo.getArgument()?.name;\n * },\n * }),\n * );\n *\n * argumentName; // => 'limit'\n * ```\n */\n getArgument(): Maybe<GraphQLArgument> {\n return this._argument;\n }\n\n /**\n * Returns the current fragment signature.\n * @returns The fragment signature for the current fragment definition.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields\n * }\n *\n * fragment GreetingFields on Query {\n * greeting\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let fragmentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * FragmentSpread: () => {\n * fragmentName = typeInfo.getFragmentSignature()?.definition.name.value;\n * },\n * }),\n * );\n *\n * fragmentName; // => 'GreetingFields'\n * ```\n */\n getFragmentSignature(): Maybe<FragmentSignature> {\n return this._fragmentSignature;\n }\n\n /**\n * Returns the function used to look up fragment signatures by name.\n * @returns A function that maps fragment names to fragment signatures.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields\n * }\n *\n * fragment GreetingFields on Query {\n * greeting\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let fragmentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * Document: () => {\n * const getFragmentSignature = typeInfo.getFragmentSignatureByName();\n * fragmentName =\n * getFragmentSignature('GreetingFields')?.definition.name.value;\n * },\n * }),\n * );\n *\n * fragmentName; // => 'GreetingFields'\n * ```\n */\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe<FragmentSignature> {\n return this._fragmentSignaturesByName;\n }\n\n /**\n * Returns the current fragment argument definition.\n * @returns The variable definition for the current fragment argument.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting(name: String): String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields(name: \"Ada\")\n * }\n *\n * fragment GreetingFields($name: String) on Query {\n * greeting(name: $name)\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let argumentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * FragmentArgument: () => {\n * argumentName = typeInfo.getFragmentArgument()?.variable.name.value;\n * },\n * }),\n * );\n *\n * argumentName; // => 'name'\n * ```\n */\n getFragmentArgument(): Maybe<VariableDefinitionNode> {\n return this._fragmentArgument;\n }\n\n /**\n * Returns the current enum value definition.\n * @returns The current enum value definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * enum Sort {\n * NEWEST\n * OLDEST\n * }\n *\n * type Query {\n * reviews(sort: Sort = NEWEST): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let enumValueName;\n *\n * visit(\n * parse('{ reviews(sort: OLDEST) }'),\n * visitWithTypeInfo(typeInfo, {\n * EnumValue: () => {\n * enumValueName = typeInfo.getEnumValue()?.name;\n * },\n * }),\n * );\n *\n * enumValueName; // => 'OLDEST'\n * ```\n */\n getEnumValue(): Maybe<GraphQLEnumValue> {\n return this._enumValue;\n }\n\n /**\n * Updates this TypeInfo instance for an entered AST node.\n * @param node - AST node being entered.\n * @returns Nothing.\n * @example\n * ```ts\n * import { Kind, parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse('{ greeting }');\n * const operation = document.definitions[0];\n * const selectionSet = operation.selectionSet;\n * const field = selectionSet.selections[0];\n * const typeInfo = new TypeInfo(schema);\n *\n * typeInfo.enter(operation);\n * typeInfo.enter(selectionSet);\n * typeInfo.enter(field);\n *\n * field.kind; // => Kind.FIELD\n * typeInfo.getParentType()?.name; // => 'Query'\n * String(typeInfo.getType()); // => 'String'\n * ```\n */\n enter(node: ASTNode): void {\n const schema = this._schema;\n // Note: many of the types below are explicitly typed as \"unknown\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n switch (node.kind) {\n case Kind.DOCUMENT: {\n const fragmentSignatures = getFragmentSignatures(node);\n this._fragmentSignaturesByName = (fragmentName: string) =>\n fragmentSignatures.get(fragmentName);\n break;\n }\n case Kind.SELECTION_SET: {\n const namedType: unknown = getNamedType(this.getType());\n this._parentTypeStack.push(\n isCompositeType(namedType) ? namedType : undefined,\n );\n break;\n }\n case Kind.FIELD: {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType: unknown;\n if (parentType) {\n fieldDef = schema.getField(parentType, node.name.value);\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n this._fieldDefStack.push(fieldDef);\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n break;\n }\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n case Kind.OPERATION_DEFINITION: {\n const rootType = schema.getRootType(node.operation);\n this._typeStack.push(isObjectType(rootType) ? rootType : undefined);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n this._fragmentSignature = this.getFragmentSignatureByName()(\n node.name.value,\n );\n break;\n }\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION: {\n const typeConditionAST = node.typeCondition;\n const outputType: unknown = typeConditionAST\n ? typeFromAST(schema, typeConditionAST)\n : getNamedType(this.getType());\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n break;\n }\n case Kind.VARIABLE_DEFINITION: {\n const inputType: unknown = typeFromAST(schema, node.type);\n this._inputTypeStack.push(\n isInputType(inputType) ? inputType : undefined,\n );\n break;\n }\n case Kind.ARGUMENT: {\n let argDef;\n let argType: unknown;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(\n (arg) => arg.name === node.name.value,\n );\n if (argDef) {\n argType = argDef.type;\n }\n }\n this._argument = argDef;\n this._defaultValueStack.push(\n argDef?.default ?? argDef?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.FRAGMENT_ARGUMENT: {\n const fragmentSignature = this.getFragmentSignature();\n const argDef = fragmentSignature?.variableDefinitions.get(\n node.name.value,\n );\n this._fragmentArgument = argDef;\n let argType: unknown;\n if (argDef) {\n argType = typeFromAST(this._schema, argDef.type);\n }\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.LIST: {\n const listType: unknown = getNullableType(this.getInputType());\n const itemType: unknown = isListType(listType)\n ? listType.ofType\n : undefined;\n // List positions never have a default value.\n this._defaultValueStack.push(undefined);\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n break;\n }\n case Kind.OBJECT_FIELD: {\n const objectType: unknown = getNamedType(this.getInputType());\n let inputFieldType: GraphQLInputType | undefined;\n let inputField: GraphQLInputField | undefined;\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n if (inputField != null) {\n inputFieldType = inputField.type;\n }\n }\n this._defaultValueStack.push(\n inputField?.default ?? inputField?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(\n isInputType(inputFieldType) ? inputFieldType : undefined,\n );\n break;\n }\n case Kind.ENUM: {\n const enumType: unknown = getNamedType(this.getInputType());\n let enumValue;\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n this._enumValue = enumValue;\n break;\n }\n default:\n // Ignore other nodes\n }\n }\n\n /**\n * Updates this TypeInfo instance for a left AST node.\n * @param node - AST node being entered.\n * @returns Nothing.\n * @example\n * ```ts\n * import { parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse('{ greeting }');\n * const operation = document.definitions[0];\n * const selectionSet = operation.selectionSet;\n * const field = selectionSet.selections[0];\n * const typeInfo = new TypeInfo(schema);\n *\n * typeInfo.enter(operation);\n * typeInfo.enter(selectionSet);\n * typeInfo.enter(field);\n * String(typeInfo.getType()); // => 'String'\n *\n * typeInfo.leave(field);\n * typeInfo.getType(); // => undefined\n * ```\n */\n leave(node: ASTNode): void {\n switch (node.kind) {\n case Kind.DOCUMENT:\n this._fragmentSignaturesByName = () => null;\n break;\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n break;\n case Kind.FIELD:\n this._fieldDefStack.pop();\n this._typeStack.pop();\n break;\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n case Kind.FRAGMENT_SPREAD:\n this._fragmentSignature = null;\n break;\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n break;\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n break;\n case Kind.ARGUMENT:\n this._argument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.FRAGMENT_ARGUMENT: {\n this._fragmentArgument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n }\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.ENUM:\n this._enumValue = null;\n break;\n default:\n // Ignore other nodes\n }\n }\n}\n\nfunction getFragmentSignatures(\n document: DocumentNode,\n): Map<string, FragmentSignature> {\n const fragmentSignatures = new Map<string, FragmentSignature>();\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n const variableDefinitions = new Map<string, VariableDefinitionNode>();\n if (definition.variableDefinitions) {\n for (const varDef of definition.variableDefinitions) {\n variableDefinitions.set(varDef.variable.name.value, varDef);\n }\n }\n const signature = { definition, variableDefinitions };\n fragmentSignatures.set(definition.name.value, signature);\n }\n }\n return fragmentSignatures;\n}\n\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n * @param typeInfo - TypeInfo instance to update during traversal.\n * @param visitor - Visitor callbacks to wrap with TypeInfo updates.\n * @returns A visitor that keeps TypeInfo in sync while delegating callbacks.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const fields = [];\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * fields.push({\n * name: node.name.value,\n * parentType: String(typeInfo.getParentType()),\n * type: String(typeInfo.getType()),\n * });\n * },\n * }),\n * );\n *\n * fields; // => [{ name: 'greeting', parentType: 'Query', type: 'String' }]\n * ```\n */\nexport function visitWithTypeInfo(\n typeInfo: TypeInfo,\n visitor: ASTVisitor,\n): ASTVisitor {\n return {\n enter(...args) {\n const node = args[0];\n typeInfo.enter(node);\n const fn = getEnterLeaveForKind(visitor, node.kind).enter;\n if (fn) {\n const result = fn.apply(visitor, args);\n if (result !== undefined) {\n typeInfo.leave(node);\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n return result;\n }\n },\n leave(...args) {\n const node = args[0];\n const fn = getEnterLeaveForKind(visitor, node.kind).leave;\n let result;\n if (fn) {\n result = fn.apply(visitor, args);\n }\n typeInfo.leave(node);\n return result;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeInfo.js","sourceRoot":"","sources":["../../src/utilities/TypeInfo.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,4BAA2B;AAC5C,OAAO,EAAE,IAAI,EAAE,8BAA6B;AAE5C,OAAO,EAAE,oBAAoB,EAAE,gCAA+B;AAY9D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,GACb,+BAA8B;A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AC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAqCD,MAAM,UAAU,iBAAiB,CAC/B,QAAkB,EAClB,OAAmB;IAEnB,OAAO;QACL,KAAK,CAAC,GAAG,IAAI;YACX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,MAAM,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;YAC1D,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBACzB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACrB,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;wBACnB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,GAAG,IAAI;YACX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;YAC1D,IAAI,MAAM,CAAC;YACX,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** @category Type Info */\n\nimport type { Maybe } from '../jsutils/Maybe.ts';\n\nimport type {\n ASTNode,\n DocumentNode,\n FragmentDefinitionNode,\n VariableDefinitionNode,\n} from '../language/ast.ts';\nimport { isNode } from '../language/ast.ts';\nimport { Kind } from '../language/kinds.ts';\nimport type { ASTVisitor } from '../language/visitor.ts';\nimport { getEnterLeaveForKind } from '../language/visitor.ts';\n\nimport type {\n GraphQLArgument,\n GraphQLCompositeType,\n GraphQLEnumValue,\n GraphQLField,\n GraphQLInputField,\n GraphQLInputType,\n GraphQLOutputType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n getNamedType,\n getNullableType,\n isCompositeType,\n isEnumType,\n isInputObjectType,\n isInputType,\n isListType,\n isObjectType,\n isOutputType,\n} from '../type/definition.ts';\nimport type { GraphQLDirective } from '../type/directives.ts';\nimport type { GraphQLSchema } from '../type/schema.ts';\n\nimport { typeFromAST } from './typeFromAST.ts';\n\n/** @internal */\nexport interface FragmentSignature {\n readonly definition: FragmentDefinitionNode;\n readonly variableDefinitions: Map<string, VariableDefinitionNode>;\n}\n\n/**\n * TypeInfo is a utility class which, given a GraphQL schema, can keep track\n * of the current field and type definitions at any point in a GraphQL document\n * AST during a recursive descent by calling `enter(node)` and `leave(node)`.\n */\nexport class TypeInfo {\n private _schema: GraphQLSchema;\n private _typeStack: Array<Maybe<GraphQLOutputType>>;\n private _parentTypeStack: Array<Maybe<GraphQLCompositeType>>;\n private _inputTypeStack: Array<Maybe<GraphQLInputType>>;\n private _fieldDefStack: Array<Maybe<GraphQLField<unknown, unknown>>>;\n private _defaultValueStack: Array<unknown>;\n private _directive: Maybe<GraphQLDirective>;\n private _argument: Maybe<GraphQLArgument>;\n private _enumValue: Maybe<GraphQLEnumValue>;\n private _fragmentSignaturesByName: (\n fragmentName: string,\n ) => Maybe<FragmentSignature>;\n\n private _fragmentSignature: Maybe<FragmentSignature>;\n private _fragmentArgument: Maybe<VariableDefinitionNode>;\n\n /**\n * Creates a TypeInfo instance.\n * @param schema - Schema used for type lookups.\n * @param initialType - Optional type to use at the start of traversal.\n * @param fragmentSignatures - Fragment signatures available during traversal.\n * @example\n * ```ts\n * // Track field types during a visitWithTypeInfo traversal.\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema } from 'graphql/utilities';\n * import { TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const seenTypes = [];\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: () => {\n * seenTypes.push(String(typeInfo.getType()));\n * },\n * }),\n * );\n *\n * seenTypes; // => ['String']\n * ```\n * @example\n * ```ts\n * // This variant starts from an initial type and supplies fragment signatures.\n * import { Kind, parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting(name: String): String\n * }\n * `);\n * const fragmentDocument = parse(\n * 'fragment GreetingFields($name: String) on Query { greeting(name: $name) }',\n * { experimentalFragmentArguments: true },\n * );\n * const fragmentDefinition = fragmentDocument.definitions[0];\n * const variableDefinition = fragmentDefinition.variableDefinitions[0];\n * const typeInfo = new TypeInfo(schema, schema.getQueryType(), (name) =>\n * name === 'GreetingFields'\n * ? {\n * definition: fragmentDefinition,\n * variableDefinitions: new Map([['name', variableDefinition]]),\n * }\n * : undefined,\n * );\n *\n * typeInfo.enter({\n * kind: Kind.SELECTION_SET,\n * selections: [],\n * });\n * typeInfo.enter({\n * kind: Kind.FRAGMENT_SPREAD,\n * name: { kind: Kind.NAME, value: 'GreetingFields' },\n * arguments: [],\n * directives: [],\n * });\n *\n * String(typeInfo.getParentType()); // => 'Query'\n * typeInfo.getFragmentSignature()?.definition.name.value; // => 'GreetingFields'\n * ```\n */\n constructor(\n schema: GraphQLSchema,\n /**\n * Initial type may be provided in rare cases to facilitate traversals\n * beginning somewhere other than documents.\n */\n initialType?: Maybe<GraphQLType>,\n fragmentSignatures?: Maybe<\n (fragmentName: string) => Maybe<FragmentSignature>\n >,\n ) {\n this._schema = schema;\n this._typeStack = [];\n this._parentTypeStack = [];\n this._inputTypeStack = [];\n this._fieldDefStack = [];\n this._defaultValueStack = [];\n this._directive = null;\n this._argument = null;\n this._enumValue = null;\n this._fragmentSignaturesByName = fragmentSignatures ?? (() => null);\n this._fragmentSignature = null;\n this._fragmentArgument = null;\n if (initialType) {\n if (isInputType(initialType)) {\n this._inputTypeStack.push(initialType);\n }\n if (isCompositeType(initialType)) {\n this._parentTypeStack.push(initialType);\n }\n if (isOutputType(initialType)) {\n this._typeStack.push(initialType);\n }\n }\n }\n\n /**\n * Returns the value used by `Object.prototype.toString`.\n * @returns The built-in string tag for this object.\n */\n get [Symbol.toStringTag](): string {\n return 'TypeInfo';\n }\n\n /**\n * Returns the current output type at this point in traversal.\n * @returns The current output type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * viewer: User\n * }\n *\n * type User {\n * name: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const fieldTypes = {};\n *\n * visit(\n * parse('{ viewer { name } }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * fieldTypes[node.name.value] = String(typeInfo.getType());\n * },\n * }),\n * );\n *\n * fieldTypes; // => { viewer: 'User', name: 'String' }\n * ```\n */\n getType(): Maybe<GraphQLOutputType> {\n return this._typeStack.at(-1);\n }\n\n /**\n * Returns the current parent composite type.\n * @returns The current parent composite type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * viewer: User\n * }\n *\n * type User {\n * name: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const parentTypes = {};\n *\n * visit(\n * parse('{ viewer { name } }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * parentTypes[node.name.value] = String(typeInfo.getParentType());\n * },\n * }),\n * );\n *\n * parentTypes; // => { viewer: 'Query', name: 'User' }\n * ```\n */\n getParentType(): Maybe<GraphQLCompositeType> {\n return this._parentTypeStack.at(-1);\n }\n\n /**\n * Returns the current input type at this point in traversal.\n * @returns The current input type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(stars: Int!, sort: Sort = NEWEST): [String]\n * }\n *\n * enum Sort {\n * NEWEST\n * OLDEST\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const inputTypes = {};\n *\n * visit(\n * parse('{ reviews(stars: 5, sort: OLDEST) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: (node) => {\n * inputTypes[node.name.value] = String(typeInfo.getInputType());\n * },\n * }),\n * );\n *\n * inputTypes; // => { stars: 'Int!', sort: 'Sort' }\n * ```\n */\n getInputType(): Maybe<GraphQLInputType> {\n return this._inputTypeStack.at(-1);\n }\n\n // Note: continues to expose the closest enclosing valid input type if\n // traversal descends into syntax with no corresponding GraphQL input type.\n /**\n * Returns the parent input type for the current input position.\n * @returns The parent input type, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * input ReviewFilter {\n * stars: Int!\n * }\n *\n * type Query {\n * reviews(filter: ReviewFilter): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const parentInputTypes = {};\n *\n * visit(\n * parse('{ reviews(filter: { stars: 5 }) }'),\n * visitWithTypeInfo(typeInfo, {\n * ObjectField: (node) => {\n * parentInputTypes[node.name.value] = String(typeInfo.getParentInputType());\n * },\n * }),\n * );\n *\n * parentInputTypes; // => { stars: 'ReviewFilter' }\n * ```\n */\n getParentInputType(): Maybe<GraphQLInputType> {\n return this._inputTypeStack.at(-2);\n }\n\n /**\n * Returns the current field definition.\n * @returns The current field definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let fieldName;\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: () => {\n * fieldName = typeInfo.getFieldDef()?.name;\n * },\n * }),\n * );\n *\n * fieldName; // => 'greeting'\n * ```\n */\n getFieldDef(): Maybe<GraphQLField<unknown, unknown>> {\n return this._fieldDefStack.at(-1);\n }\n\n /**\n * Returns the default input representation for the current input position.\n * @returns The current default input, if one is available.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(limit: Int = 10): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let defaultLimit;\n *\n * visit(\n * parse('{ reviews(limit: 5) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: () => {\n * defaultLimit = typeInfo.getDefaultValue();\n * },\n * }),\n * );\n *\n * defaultLimit; // => { literal: { kind: 'IntValue', value: '10' } }\n * ```\n */\n getDefaultValue(): unknown {\n return this._defaultValueStack.at(-1);\n }\n\n /**\n * Returns the current directive definition.\n * @returns The current directive definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let directiveName;\n *\n * visit(\n * parse('{ greeting @include(if: true) }'),\n * visitWithTypeInfo(typeInfo, {\n * Directive: () => {\n * directiveName = typeInfo.getDirective()?.name;\n * },\n * }),\n * );\n *\n * directiveName; // => 'include'\n * ```\n */\n getDirective(): Maybe<GraphQLDirective> {\n return this._directive;\n }\n\n /**\n * Returns the current argument definition.\n * @returns The current argument definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * reviews(limit: Int = 10): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let argumentName;\n *\n * visit(\n * parse('{ reviews(limit: 5) }'),\n * visitWithTypeInfo(typeInfo, {\n * Argument: () => {\n * argumentName = typeInfo.getArgument()?.name;\n * },\n * }),\n * );\n *\n * argumentName; // => 'limit'\n * ```\n */\n getArgument(): Maybe<GraphQLArgument> {\n return this._argument;\n }\n\n /**\n * Returns the current fragment signature.\n * @returns The fragment signature for the current fragment definition.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields\n * }\n *\n * fragment GreetingFields on Query {\n * greeting\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let fragmentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * FragmentSpread: () => {\n * fragmentName = typeInfo.getFragmentSignature()?.definition.name.value;\n * },\n * }),\n * );\n *\n * fragmentName; // => 'GreetingFields'\n * ```\n */\n getFragmentSignature(): Maybe<FragmentSignature> {\n return this._fragmentSignature;\n }\n\n /**\n * Returns the function used to look up fragment signatures by name.\n * @returns A function that maps fragment names to fragment signatures.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields\n * }\n *\n * fragment GreetingFields on Query {\n * greeting\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let fragmentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * Document: () => {\n * const getFragmentSignature = typeInfo.getFragmentSignatureByName();\n * fragmentName =\n * getFragmentSignature('GreetingFields')?.definition.name.value;\n * },\n * }),\n * );\n *\n * fragmentName; // => 'GreetingFields'\n * ```\n */\n getFragmentSignatureByName(): (\n fragmentName: string,\n ) => Maybe<FragmentSignature> {\n return this._fragmentSignaturesByName;\n }\n\n /**\n * Returns the current fragment argument definition.\n * @returns The variable definition for the current fragment argument.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting(name: String): String\n * }\n * `);\n * const document = parse(\n * `\n * {\n * ...GreetingFields(name: \"Ada\")\n * }\n *\n * fragment GreetingFields($name: String) on Query {\n * greeting(name: $name)\n * }\n * `,\n * { experimentalFragmentArguments: true },\n * );\n * const typeInfo = new TypeInfo(schema);\n * let argumentName;\n *\n * visit(\n * document,\n * visitWithTypeInfo(typeInfo, {\n * FragmentArgument: () => {\n * argumentName = typeInfo.getFragmentArgument()?.variable.name.value;\n * },\n * }),\n * );\n *\n * argumentName; // => 'name'\n * ```\n */\n getFragmentArgument(): Maybe<VariableDefinitionNode> {\n return this._fragmentArgument;\n }\n\n /**\n * Returns the current enum value definition.\n * @returns The current enum value definition, if known.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * enum Sort {\n * NEWEST\n * OLDEST\n * }\n *\n * type Query {\n * reviews(sort: Sort = NEWEST): [String]\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * let enumValueName;\n *\n * visit(\n * parse('{ reviews(sort: OLDEST) }'),\n * visitWithTypeInfo(typeInfo, {\n * EnumValue: () => {\n * enumValueName = typeInfo.getEnumValue()?.name;\n * },\n * }),\n * );\n *\n * enumValueName; // => 'OLDEST'\n * ```\n */\n getEnumValue(): Maybe<GraphQLEnumValue> {\n return this._enumValue;\n }\n\n /**\n * Updates this TypeInfo instance for an entered AST node.\n * @param node - AST node being entered.\n * @returns Nothing.\n * @example\n * ```ts\n * import { Kind, parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse('{ greeting }');\n * const operation = document.definitions[0];\n * const selectionSet = operation.selectionSet;\n * const field = selectionSet.selections[0];\n * const typeInfo = new TypeInfo(schema);\n *\n * typeInfo.enter(operation);\n * typeInfo.enter(selectionSet);\n * typeInfo.enter(field);\n *\n * field.kind; // => Kind.FIELD\n * typeInfo.getParentType()?.name; // => 'Query'\n * String(typeInfo.getType()); // => 'String'\n * ```\n */\n enter(node: ASTNode): void {\n const schema = this._schema;\n // Note: many of the types below are explicitly typed as \"unknown\" to drop\n // any assumptions of a valid schema to ensure runtime types are properly\n // checked before continuing since TypeInfo is used as part of validation\n // which occurs before guarantees of schema and document validity.\n switch (node.kind) {\n case Kind.DOCUMENT: {\n const fragmentSignatures = getFragmentSignatures(node);\n this._fragmentSignaturesByName = (fragmentName: string) =>\n fragmentSignatures.get(fragmentName);\n break;\n }\n case Kind.SELECTION_SET: {\n const namedType: unknown = getNamedType(this.getType());\n this._parentTypeStack.push(\n isCompositeType(namedType) ? namedType : undefined,\n );\n break;\n }\n case Kind.FIELD: {\n const parentType = this.getParentType();\n let fieldDef;\n let fieldType: unknown;\n if (parentType) {\n fieldDef = schema.getField(parentType, node.name.value);\n if (fieldDef) {\n fieldType = fieldDef.type;\n }\n }\n this._fieldDefStack.push(fieldDef);\n this._typeStack.push(isOutputType(fieldType) ? fieldType : undefined);\n break;\n }\n case Kind.DIRECTIVE:\n this._directive = schema.getDirective(node.name.value);\n break;\n case Kind.OPERATION_DEFINITION: {\n const rootType = schema.getRootType(node.operation);\n this._typeStack.push(isObjectType(rootType) ? rootType : undefined);\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n this._fragmentSignature = this.getFragmentSignatureByName()(\n node.name.value,\n );\n break;\n }\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION: {\n const typeConditionAST = node.typeCondition;\n const outputType: unknown = typeConditionAST\n ? typeFromAST(schema, typeConditionAST)\n : getNamedType(this.getType());\n this._typeStack.push(isOutputType(outputType) ? outputType : undefined);\n break;\n }\n case Kind.VARIABLE_DEFINITION: {\n const inputType: unknown = typeFromAST(schema, node.type);\n this._inputTypeStack.push(\n isInputType(inputType) ? inputType : undefined,\n );\n break;\n }\n case Kind.ARGUMENT: {\n let argDef;\n let argType: unknown;\n const fieldOrDirective = this.getDirective() ?? this.getFieldDef();\n if (fieldOrDirective) {\n argDef = fieldOrDirective.args.find(\n (arg) => arg.name === node.name.value,\n );\n if (argDef) {\n argType = argDef.type;\n }\n }\n this._argument = argDef;\n this._defaultValueStack.push(\n argDef?.default ?? argDef?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.FRAGMENT_ARGUMENT: {\n const fragmentSignature = this.getFragmentSignature();\n const argDef = fragmentSignature?.variableDefinitions.get(\n node.name.value,\n );\n this._fragmentArgument = argDef;\n let argType: unknown;\n if (argDef) {\n argType = typeFromAST(this._schema, argDef.type);\n }\n this._inputTypeStack.push(isInputType(argType) ? argType : undefined);\n break;\n }\n case Kind.LIST: {\n const listType: unknown = getNullableType(this.getInputType());\n const itemType: unknown = isListType(listType)\n ? listType.ofType\n : undefined;\n // List positions never have a default value.\n this._defaultValueStack.push(undefined);\n this._inputTypeStack.push(isInputType(itemType) ? itemType : undefined);\n break;\n }\n case Kind.OBJECT_FIELD: {\n const objectType: unknown = getNamedType(this.getInputType());\n let inputFieldType: GraphQLInputType | undefined;\n let inputField: GraphQLInputField | undefined;\n if (isInputObjectType(objectType)) {\n inputField = objectType.getFields()[node.name.value];\n if (inputField != null) {\n inputFieldType = inputField.type;\n }\n }\n this._defaultValueStack.push(\n inputField?.default ?? inputField?.defaultValue ?? undefined,\n );\n this._inputTypeStack.push(\n isInputType(inputFieldType) ? inputFieldType : undefined,\n );\n break;\n }\n case Kind.ENUM: {\n const enumType: unknown = getNamedType(this.getInputType());\n let enumValue;\n if (isEnumType(enumType)) {\n enumValue = enumType.getValue(node.value);\n }\n this._enumValue = enumValue;\n break;\n }\n default:\n // Ignore other nodes\n }\n }\n\n /**\n * Updates this TypeInfo instance for a left AST node.\n * @param node - AST node being entered.\n * @returns Nothing.\n * @example\n * ```ts\n * import { parse } from 'graphql/language';\n * import { buildSchema, TypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const document = parse('{ greeting }');\n * const operation = document.definitions[0];\n * const selectionSet = operation.selectionSet;\n * const field = selectionSet.selections[0];\n * const typeInfo = new TypeInfo(schema);\n *\n * typeInfo.enter(operation);\n * typeInfo.enter(selectionSet);\n * typeInfo.enter(field);\n * String(typeInfo.getType()); // => 'String'\n *\n * typeInfo.leave(field);\n * typeInfo.getType(); // => undefined\n * ```\n */\n leave(node: ASTNode): void {\n switch (node.kind) {\n case Kind.DOCUMENT:\n this._fragmentSignaturesByName = () => null;\n break;\n case Kind.SELECTION_SET:\n this._parentTypeStack.pop();\n break;\n case Kind.FIELD:\n this._fieldDefStack.pop();\n this._typeStack.pop();\n break;\n case Kind.DIRECTIVE:\n this._directive = null;\n break;\n case Kind.FRAGMENT_SPREAD:\n this._fragmentSignature = null;\n break;\n case Kind.OPERATION_DEFINITION:\n case Kind.INLINE_FRAGMENT:\n case Kind.FRAGMENT_DEFINITION:\n this._typeStack.pop();\n break;\n case Kind.VARIABLE_DEFINITION:\n this._inputTypeStack.pop();\n break;\n case Kind.ARGUMENT:\n this._argument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.FRAGMENT_ARGUMENT: {\n this._fragmentArgument = null;\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n }\n case Kind.LIST:\n case Kind.OBJECT_FIELD:\n this._defaultValueStack.pop();\n this._inputTypeStack.pop();\n break;\n case Kind.ENUM:\n this._enumValue = null;\n break;\n default:\n // Ignore other nodes\n }\n }\n}\n\nfunction getFragmentSignatures(\n document: DocumentNode,\n): Map<string, FragmentSignature> {\n const fragmentSignatures = new Map<string, FragmentSignature>();\n for (const definition of document.definitions) {\n if (definition.kind === Kind.FRAGMENT_DEFINITION) {\n const variableDefinitions = new Map<string, VariableDefinitionNode>();\n if (definition.variableDefinitions) {\n for (const varDef of definition.variableDefinitions) {\n variableDefinitions.set(varDef.variable.name.value, varDef);\n }\n }\n const signature = { definition, variableDefinitions };\n fragmentSignatures.set(definition.name.value, signature);\n }\n }\n return fragmentSignatures;\n}\n\n/**\n * Creates a new visitor instance which maintains a provided TypeInfo instance\n * along with visiting visitor.\n * @param typeInfo - TypeInfo instance to update during traversal.\n * @param visitor - Visitor callbacks to wrap with TypeInfo updates.\n * @returns A visitor that keeps TypeInfo in sync while delegating callbacks.\n * @example\n * ```ts\n * import { parse, visit } from 'graphql/language';\n * import { buildSchema, TypeInfo, visitWithTypeInfo } from 'graphql/utilities';\n *\n * const schema = buildSchema(`\n * type Query {\n * greeting: String\n * }\n * `);\n * const typeInfo = new TypeInfo(schema);\n * const fields = [];\n *\n * visit(\n * parse('{ greeting }'),\n * visitWithTypeInfo(typeInfo, {\n * Field: (node) => {\n * fields.push({\n * name: node.name.value,\n * parentType: String(typeInfo.getParentType()),\n * type: String(typeInfo.getType()),\n * });\n * },\n * }),\n * );\n *\n * fields; // => [{ name: 'greeting', parentType: 'Query', type: 'String' }]\n * ```\n */\nexport function visitWithTypeInfo(\n typeInfo: TypeInfo,\n visitor: ASTVisitor,\n): ASTVisitor {\n return {\n enter(...args) {\n const node = args[0];\n typeInfo.enter(node);\n const fn = getEnterLeaveForKind(visitor, node.kind).enter;\n if (fn) {\n const result = fn.apply(visitor, args);\n if (result !== undefined) {\n typeInfo.leave(node);\n if (isNode(result)) {\n typeInfo.enter(result);\n }\n }\n return result;\n }\n },\n leave(...args) {\n const node = args[0];\n const fn = getEnterLeaveForKind(visitor, node.kind).leave;\n let result;\n if (fn) {\n result = fn.apply(visitor, args);\n }\n typeInfo.leave(node);\n return result;\n },\n };\n}\n"]}
|
|
@@ -74,7 +74,6 @@ export declare function buildASTSchema(documentAST: DocumentNode, options?: Buil
|
|
|
74
74
|
* 'directive @tag on FIELD_DEFINITION\n' +
|
|
75
75
|
* 'directive @compose @tag on FIELD_DEFINITION',
|
|
76
76
|
* {
|
|
77
|
-
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
78
77
|
* experimentalFragmentArguments: true,
|
|
79
78
|
* noLocation: true,
|
|
80
79
|
* },
|
|
@@ -74,7 +74,6 @@ export declare function buildASTSchema(documentAST: DocumentNode, options?: Buil
|
|
|
74
74
|
* 'directive @tag on FIELD_DEFINITION\n' +
|
|
75
75
|
* 'directive @compose @tag on FIELD_DEFINITION',
|
|
76
76
|
* {
|
|
77
|
-
* experimentalDirectivesOnDirectiveDefinitions: true,
|
|
78
77
|
* experimentalFragmentArguments: true,
|
|
79
78
|
* noLocation: true,
|
|
80
79
|
* },
|
|
@@ -45,7 +45,6 @@ function buildSchema(source, options) {
|
|
|
45
45
|
const document = (0, parser_ts_1.parse)(source, {
|
|
46
46
|
noLocation: options?.noLocation,
|
|
47
47
|
experimentalFragmentArguments: options?.experimentalFragmentArguments,
|
|
48
|
-
experimentalDirectivesOnDirectiveDefinitions: options?.experimentalDirectivesOnDirectiveDefinitions,
|
|
49
48
|
});
|
|
50
49
|
return buildASTSchema(document, {
|
|
51
50
|
assumeValidSDL: options?.assumeValidSDL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildASTSchema.js","sourceRoot":"","sources":["../../src/utilities/buildASTSchema.ts"],"names":[],"mappings":";;AA8DA,wCAmDC;
|
|
1
|
+
{"version":3,"file":"buildASTSchema.js","sourceRoot":"","sources":["../../src/utilities/buildASTSchema.ts"],"names":[],"mappings":";;AA8DA,wCAmDC;AAoCD,kCAaC;AA9JD,qDAA8C;AAG9C,yDAA4D;AAE5D,iDAAkD;AAElD,2DAA2D;AAE3D,uDAAqD;AAiDrD,SAAgB,cAAc,CAC5B,WAAyB,EACzB,OAA4B;IAE5B,IAAI,OAAO,EAAE,WAAW,KAAK,IAAI,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI,EAAE,CAAC;QACtE,IAAA,4BAAc,EAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,iBAAiB,GAAG;QACxB,WAAW,EAAE,SAAS;QACtB,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/B,iBAAiB,EAAE,EAAE;QACrB,WAAW,EAAE,KAAK;KACnB,CAAC;IACF,MAAM,MAAM,GAAG,IAAA,kCAAgB,EAAC,iBAAiB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAEzE,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAChC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;gBAIlB,KAAK,OAAO;oBAEV,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;oBACpB,MAAM;gBACR,KAAK,UAAU;oBAEb,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;oBACvB,MAAM;gBACR,KAAK,cAAc;oBAEjB,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;oBAC3B,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,MAAM,CAAC,UAAU;QAEpB,GAAG,mCAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAC7C,MAAM,CAAC,UAAU,CAAC,KAAK,CACrB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CACpD,CACF;KACF,CAAC;IAEF,OAAO,IAAI,yBAAa,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC;AAoCD,SAAgB,WAAW,CACzB,MAAuB,EACvB,OAA2C;IAE3C,MAAM,QAAQ,GAAG,IAAA,iBAAK,EAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,6BAA6B,EAAE,OAAO,EAAE,6BAA6B;KACtE,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE;QAC9B,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,WAAW,EAAE,OAAO,EAAE,WAAW;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/** @category Schema Construction */\n\nimport type { DocumentNode } from '../language/ast.ts';\nimport type { ParseOptions } from '../language/parser.ts';\nimport { parse } from '../language/parser.ts';\nimport type { Source } from '../language/source.ts';\n\nimport { specifiedDirectives } from '../type/directives.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport { assertValidSDL } from '../validation/validate.ts';\n\nimport { extendSchemaImpl } from './extendSchema.ts';\n\n/** Options used when building a schema from SDL or a parsed SDL document. */\nexport interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * Builds a GraphQLSchema from a parsed schema definition language document.\n *\n * If no schema definition is provided, then it will look for types named Query,\n * Mutation and Subscription.\n *\n * The resulting schema has no resolver functions, so execution will use the\n * default field resolver.\n * @param documentAST - The parsed GraphQL document AST.\n * @param options - Optional configuration for this operation.\n * @returns The schema built from the provided SDL document.\n * @example\n * ```ts\n * // Build a schema from a valid parsed SDL document.\n * import { parse } from 'graphql/language';\n * import { buildASTSchema } from 'graphql/utilities';\n *\n * const document = parse('type Query { hello: String }');\n * const schema = buildASTSchema(document);\n *\n * schema.getQueryType().name; // => 'Query'\n * ```\n * @example\n * ```ts\n * // This variant uses validation options when the SDL references unknown types.\n * import { parse } from 'graphql/language';\n * import { buildASTSchema } from 'graphql/utilities';\n *\n * const document = parse('type Query { broken: MissingType }');\n *\n * buildASTSchema(document); // throws an error\n * buildASTSchema(document, {\n * assumeValid: true,\n * assumeValidSDL: true,\n * }); // does not throw\n * ```\n */\nexport function buildASTSchema(\n documentAST: DocumentNode,\n options?: BuildSchemaOptions,\n): GraphQLSchema {\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: Object.create(null),\n extensionASTNodes: [],\n assumeValid: false,\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n // @ts-expect-error validated in `validateSchema`\n config.query = type;\n break;\n case 'Mutation':\n // @ts-expect-error validated in `validateSchema`\n config.mutation = type;\n break;\n case 'Subscription':\n // @ts-expect-error validated in `validateSchema`\n config.subscription = type;\n break;\n }\n }\n }\n\n const directives = [\n ...config.directives,\n // If specified directives were not explicitly declared, add them.\n ...specifiedDirectives.filter((stdDirective) =>\n config.directives.every(\n (directive) => directive.name !== stdDirective.name,\n ),\n ),\n ];\n\n return new GraphQLSchema({ ...config, directives });\n}\n\n/**\n * Builds a GraphQLSchema directly from a schema definition language source.\n * @param source - The GraphQL source text or source object.\n * @param options - Optional configuration for this operation.\n * @returns The schema built from the provided SDL document.\n * @example\n * ```ts\n * // Build a schema from SDL source using the default options.\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n *\n * schema.getQueryType().name; // => 'Query'\n * ```\n * @example\n * ```ts\n * // This variant enables parser options and omits source locations.\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(\n * 'directive @tag on FIELD_DEFINITION\\n' +\n * 'directive @compose @tag on FIELD_DEFINITION',\n * {\n * experimentalFragmentArguments: true,\n * noLocation: true,\n * },\n * );\n *\n * const directive = schema.getDirective('compose');\n *\n * directive.name; // => 'compose'\n * directive.astNode.loc; // => undefined\n * ```\n */\nexport function buildSchema(\n source: string | Source,\n options?: BuildSchemaOptions & ParseOptions,\n): GraphQLSchema {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentArguments: options?.experimentalFragmentArguments,\n });\n\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid,\n });\n}\n"]}
|
|
@@ -41,7 +41,6 @@ export function buildSchema(source, options) {
|
|
|
41
41
|
const document = parse(source, {
|
|
42
42
|
noLocation: options?.noLocation,
|
|
43
43
|
experimentalFragmentArguments: options?.experimentalFragmentArguments,
|
|
44
|
-
experimentalDirectivesOnDirectiveDefinitions: options?.experimentalDirectivesOnDirectiveDefinitions,
|
|
45
44
|
});
|
|
46
45
|
return buildASTSchema(document, {
|
|
47
46
|
assumeValidSDL: options?.assumeValidSDL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildASTSchema.js","sourceRoot":"","sources":["../../src/utilities/buildASTSchema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,+BAA8B;AAG9C,OAAO,EAAE,mBAAmB,EAAE,+BAA8B;AAE5D,OAAO,EAAE,aAAa,EAAE,2BAA0B;AAElD,OAAO,EAAE,cAAc,EAAE,mCAAkC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,2BAA0B;AAiDrD,MAAM,UA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;QACjB,GAAG,MAAM,CAAC,UAAU;QAEpB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAC7C,MAAM,CAAC,UAAU,CAAC,KAAK,CACrB,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CACpD,CACF;KACF,CAAC;IAEF,OAAO,IAAI,aAAa,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC;AAoCD,MAAM,UAAU,WAAW,CACzB,MAAuB,EACvB,OAA2C;IAE3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,6BAA6B,EAAE,OAAO,EAAE,6BAA6B;KACtE,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,QAAQ,EAAE;QAC9B,cAAc,EAAE,OAAO,EAAE,cAAc;QACvC,WAAW,EAAE,OAAO,EAAE,WAAW;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/** @category Schema Construction */\n\nimport type { DocumentNode } from '../language/ast.ts';\nimport type { ParseOptions } from '../language/parser.ts';\nimport { parse } from '../language/parser.ts';\nimport type { Source } from '../language/source.ts';\n\nimport { specifiedDirectives } from '../type/directives.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport { assertValidSDL } from '../validation/validate.ts';\n\nimport { extendSchemaImpl } from './extendSchema.ts';\n\n/** Options used when building a schema from SDL or a parsed SDL document. */\nexport interface BuildSchemaOptions extends GraphQLSchemaValidationOptions {\n /**\n * Set to true to assume the SDL is valid.\n *\n * Default: false\n */\n assumeValidSDL?: boolean | undefined;\n}\n\n/**\n * Builds a GraphQLSchema from a parsed schema definition language document.\n *\n * If no schema definition is provided, then it will look for types named Query,\n * Mutation and Subscription.\n *\n * The resulting schema has no resolver functions, so execution will use the\n * default field resolver.\n * @param documentAST - The parsed GraphQL document AST.\n * @param options - Optional configuration for this operation.\n * @returns The schema built from the provided SDL document.\n * @example\n * ```ts\n * // Build a schema from a valid parsed SDL document.\n * import { parse } from 'graphql/language';\n * import { buildASTSchema } from 'graphql/utilities';\n *\n * const document = parse('type Query { hello: String }');\n * const schema = buildASTSchema(document);\n *\n * schema.getQueryType().name; // => 'Query'\n * ```\n * @example\n * ```ts\n * // This variant uses validation options when the SDL references unknown types.\n * import { parse } from 'graphql/language';\n * import { buildASTSchema } from 'graphql/utilities';\n *\n * const document = parse('type Query { broken: MissingType }');\n *\n * buildASTSchema(document); // throws an error\n * buildASTSchema(document, {\n * assumeValid: true,\n * assumeValidSDL: true,\n * }); // does not throw\n * ```\n */\nexport function buildASTSchema(\n documentAST: DocumentNode,\n options?: BuildSchemaOptions,\n): GraphQLSchema {\n if (options?.assumeValid !== true && options?.assumeValidSDL !== true) {\n assertValidSDL(documentAST);\n }\n\n const emptySchemaConfig = {\n description: undefined,\n types: [],\n directives: [],\n extensions: Object.create(null),\n extensionASTNodes: [],\n assumeValid: false,\n };\n const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);\n\n if (config.astNode == null) {\n for (const type of config.types) {\n switch (type.name) {\n // Note: While this could make early assertions to get the correctly\n // typed values below, that would throw immediately while type system\n // validation with validateSchema() will produce more actionable results.\n case 'Query':\n // @ts-expect-error validated in `validateSchema`\n config.query = type;\n break;\n case 'Mutation':\n // @ts-expect-error validated in `validateSchema`\n config.mutation = type;\n break;\n case 'Subscription':\n // @ts-expect-error validated in `validateSchema`\n config.subscription = type;\n break;\n }\n }\n }\n\n const directives = [\n ...config.directives,\n // If specified directives were not explicitly declared, add them.\n ...specifiedDirectives.filter((stdDirective) =>\n config.directives.every(\n (directive) => directive.name !== stdDirective.name,\n ),\n ),\n ];\n\n return new GraphQLSchema({ ...config, directives });\n}\n\n/**\n * Builds a GraphQLSchema directly from a schema definition language source.\n * @param source - The GraphQL source text or source object.\n * @param options - Optional configuration for this operation.\n * @returns The schema built from the provided SDL document.\n * @example\n * ```ts\n * // Build a schema from SDL source using the default options.\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n *\n * schema.getQueryType().name; // => 'Query'\n * ```\n * @example\n * ```ts\n * // This variant enables parser options and omits source locations.\n * import { buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema(\n * 'directive @tag on FIELD_DEFINITION\\n' +\n * 'directive @compose @tag on FIELD_DEFINITION',\n * {\n * experimentalFragmentArguments: true,\n * noLocation: true,\n * },\n * );\n *\n * const directive = schema.getDirective('compose');\n *\n * directive.name; // => 'compose'\n * directive.astNode.loc; // => undefined\n * ```\n */\nexport function buildSchema(\n source: string | Source,\n options?: BuildSchemaOptions & ParseOptions,\n): GraphQLSchema {\n const document = parse(source, {\n noLocation: options?.noLocation,\n experimentalFragmentArguments: options?.experimentalFragmentArguments,\n });\n\n return buildASTSchema(document, {\n assumeValidSDL: options?.assumeValidSDL,\n assumeValid: options?.assumeValid,\n });\n}\n"]}
|
|
@@ -18,7 +18,11 @@ import type { IntrospectionQuery } from "./getIntrospectionQuery.mjs";
|
|
|
18
18
|
* @returns The client schema represented by the introspection result.
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* import {
|
|
21
|
+
* import {
|
|
22
|
+
* buildClientSchema,
|
|
23
|
+
* introspectionFromSchema,
|
|
24
|
+
* buildSchema,
|
|
25
|
+
* } from 'graphql/utilities';
|
|
22
26
|
*
|
|
23
27
|
* const schema = buildSchema('type Query { hello: String }');
|
|
24
28
|
* const clientSchema = buildClientSchema(introspectionFromSchema(schema), {
|
|
@@ -18,7 +18,11 @@ import type { IntrospectionQuery } from "./getIntrospectionQuery.js";
|
|
|
18
18
|
* @returns The client schema represented by the introspection result.
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* import {
|
|
21
|
+
* import {
|
|
22
|
+
* buildClientSchema,
|
|
23
|
+
* introspectionFromSchema,
|
|
24
|
+
* buildSchema,
|
|
25
|
+
* } from 'graphql/utilities';
|
|
22
26
|
*
|
|
23
27
|
* const schema = buildSchema('type Query { hello: String }');
|
|
24
28
|
* const clientSchema = buildClientSchema(introspectionFromSchema(schema), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":";;AA8EA,8CA8VC;AA1aD,0DAAoD;AACpD,sDAAgD;AAChD,gEAA0D;AAC1D,0DAAoD;AAEpD,qDAAwD;AAQxD,yDAc+B;AAC/B,yDAAyD;AACzD,+DAAwE;AACxE,mDAA0D;AAE1D,iDAAkD;AA4ClD,SAAgB,iBAAiB,CAC/B,aAAiC,EACjC,OAAwC;UAKtC,IAAA,8BAAY,EAAC,aAAa,CAAC,IAAI,IAAA,8BAAY,EAAC,aAAa,CAAC,QAAQ,CAAC;YADrE,wBAAS,SAEP,6JAA6J,IAAA,oBAAO,EAClK,aAAa,CACd,GAAG;IAIN,MAAM,mBAAmB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAGnD,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACnD,iBAAiB,CAAC,IAAI;QACtB,SAAS,CAAC,iBAAiB,CAAC;KAC7B,CAAC,CACH,CAAC;IAGF,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,iCAAoB,EAAE,GAAG,qCAAkB,CAAC,EAAE,CAAC;QACvE,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAGD,MAAM,SAAS,GACb,mBAAmB,CAAC,SAAS,IAAI,IAAI;QACnC,CAAC,CAAC,aAAa,CAA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,CAAC,EAAE;gBACpE,CAAC,CAAC,SAAS;YACf,iBAAiB,EAAE,uBAAuB,CAAC,iBAAiB;SAC7D,CAAC;IACJ,CAAC;IAED,SAAS,cAAc,CACrB,sBAA8C;QAE9C,IAAI,sBAAsB,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACxC,MAAM,yBAAyB,GAAG,IAAA,oBAAO,EAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,gDAAgD,yBAAyB,GAAG,CAC7E,CAAC;QACJ,CAAC;QACD,IAAI,sBAAsB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7C,MAAM,yBAAyB,GAAG,IAAA,oBAAO,EAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,qDAAqD,yBAAyB,GAAG,CAClF,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,gCAAgB,CAAC;YAC1B,IAAI,EAAE,sBAAsB,CAAC,IAAI;YACjC,WAAW,EAAE,sBAAsB,CAAC,WAAW;YAC/C,YAAY,EAAE,sBAAsB,CAAC,YAAY;YACjD,iBAAiB,EAAE,sBAAsB,CAAC,iBAAiB;YAC3D,SAAS,EAAE,sBAAsB,CAAC,SAAS,CAAC,KAAK,EAAE;YACnD,IAAI,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["/** @category Introspection */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\n\nimport { parseConstValue } from '../language/parser.ts';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.ts';\nimport { GraphQLDirective } from '../type/directives.ts';\nimport { introspectionTypes, TypeKind } from '../type/introspection.ts';\nimport { specifiedScalarTypes } from '../type/scalars.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.ts';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n * @param introspection - Introspection result data to build from.\n * @param options - Optional configuration for this operation.\n * @returns The client schema represented by the introspection result.\n * @example\n * ```ts\n * import { buildClientSchema, introspectionFromSchema, buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n * const clientSchema = buildClientSchema(introspectionFromSchema(schema), {\n * assumeValid: true,\n * });\n *\n * clientSchema.getQueryType().name; // => 'Query'\n * ```\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map<string, GraphQLNamedType>(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionObjectType>,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionInterfaceType>,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n default:\n // TypeScript considers this unreachable, but invalid runtime input can reach it.\n // Note: we include a default case rather than throwing after the switch to avoid\n // the use of a @ts-expect-error statement.\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array<GraphQLInterfaceType> {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap<unknown, unknown> {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig<unknown, unknown> {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray<IntrospectionInputValue>,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n deprecationReason: directiveIntrospection.deprecationReason,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":";;AAkFA,8CA8VC;AA9aD,0DAAoD;AACpD,sDAAgD;AAChD,gEAA0D;AAC1D,0DAAoD;AAEpD,qDAAwD;AAQxD,yDAc+B;AAC/B,yDAAyD;AACzD,+DAAwE;AACxE,mDAA0D;AAE1D,iDAAkD;AAgDlD,SAAgB,iBAAiB,CAC/B,aAAiC,EACjC,OAAwC;UAKtC,IAAA,8BAAY,EAAC,aAAa,CAAC,IAAI,IAAA,8BAAY,EAAC,aAAa,CAAC,QAAQ,CAAC;YADrE,wBAAS,SAEP,6JAA6J,IAAA,oBAAO,EAClK,aAAa,CACd,GAAG;IAIN,MAAM,mBAAmB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAGnD,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACnD,iBAAiB,CAAC,IAAI;QACtB,SAAS,CAAC,iBAAiB,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C;IACL,CAAC;AACH,CAAC","sourcesContent":["/** @category Introspection */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\n\nimport { parseConstValue } from '../language/parser.ts';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.ts';\nimport { GraphQLDirective } from '../type/directives.ts';\nimport { introspectionTypes, TypeKind } from '../type/introspection.ts';\nimport { specifiedScalarTypes } from '../type/scalars.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.ts';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n * @param introspection - Introspection result data to build from.\n * @param options - Optional configuration for this operation.\n * @returns The client schema represented by the introspection result.\n * @example\n * ```ts\n * import {\n * buildClientSchema,\n * introspectionFromSchema,\n * buildSchema,\n * } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n * const clientSchema = buildClientSchema(introspectionFromSchema(schema), {\n * assumeValid: true,\n * });\n *\n * clientSchema.getQueryType().name; // => 'Query'\n * ```\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map<string, GraphQLNamedType>(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionObjectType>,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionInterfaceType>,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n default:\n // TypeScript considers this unreachable, but invalid runtime input can reach it.\n // Note: we include a default case rather than throwing after the switch to avoid\n // the use of a @ts-expect-error statement.\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array<GraphQLInterfaceType> {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap<unknown, unknown> {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig<unknown, unknown> {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray<IntrospectionInputValue>,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n deprecationReason: directiveIntrospection.deprecationReason,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,eAAe,EAA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OAAO,CAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,gDAAgD,yBAAyB,GAAG,CAC7E,CAAC;QACJ,CAAC;QACD,IAAI,sBAAsB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7C,MAAM,yBAAyB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,qDAAqD,yBAAyB,GAAG,CAClF,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,gBAAgB,CAAC;YAC1B,IAAI,EAAE,sBAAsB,CAAC,IAAI;YACjC,WAAW,EAAE,sBAAsB,CAAC,WAAW;YAC/C,YAAY,EAAE,sBAAsB,CAAC,YAAY;YACjD,iBAAiB,EAAE,sBAAsB,CAAC,iBAAiB;YAC3D,SAAS,EAAE,sBAAsB,CAAC,SAAS,CAAC,KAAK,EAAE;YACnD,IAAI,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,IAAI,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["/** @category Introspection */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\n\nimport { parseConstValue } from '../language/parser.ts';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.ts';\nimport { GraphQLDirective } from '../type/directives.ts';\nimport { introspectionTypes, TypeKind } from '../type/introspection.ts';\nimport { specifiedScalarTypes } from '../type/scalars.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.ts';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n * @param introspection - Introspection result data to build from.\n * @param options - Optional configuration for this operation.\n * @returns The client schema represented by the introspection result.\n * @example\n * ```ts\n * import { buildClientSchema, introspectionFromSchema, buildSchema } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n * const clientSchema = buildClientSchema(introspectionFromSchema(schema), {\n * assumeValid: true,\n * });\n *\n * clientSchema.getQueryType().name; // => 'Query'\n * ```\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map<string, GraphQLNamedType>(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionObjectType>,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionInterfaceType>,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n default:\n // TypeScript considers this unreachable, but invalid runtime input can reach it.\n // Note: we include a default case rather than throwing after the switch to avoid\n // the use of a @ts-expect-error statement.\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array<GraphQLInterfaceType> {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap<unknown, unknown> {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig<unknown, unknown> {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray<IntrospectionInputValue>,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n deprecationReason: directiveIntrospection.deprecationReason,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"buildClientSchema.js","sourceRoot":"","sources":["../../src/utilities/buildClientSchema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,OAAO,EAAE,+BAA8B;AAChD,OAAO,EAAE,YAAY,EAAE,oCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAEpD,OAAO,EAAE,eAAe,EAAE,+BAA8B;AAQxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,+BAA8B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,+BAA8B;AACzD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,kCAAiC;AACxE,OAAO,EAAE,oBAAoB,EAAE,4BAA2B;AAE1D,OAAO,EAAE,aAAa,EAAE,2BAA0B;AAgDlD,MAAM,UAAU,iBAAiB,CAC/B,aAAiC,EACjC,OAAwC;UAKtC,YAAY,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC;QADrE,SAAS,QAEP,6JAA6J,OAAO,CAClK,aAAa,CACd,GAAG;IAIN,MAAM,mBAAmB,GAAG,aAAa,CAAC,QAAQ,CAAC;IAGnD,MAAM,OAAO,GA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CAAC","sourcesContent":["/** @category Introspection */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\nimport { isObjectLike } from '../jsutils/isObjectLike.ts';\nimport { keyValMap } from '../jsutils/keyValMap.ts';\n\nimport { parseConstValue } from '../language/parser.ts';\n\nimport type {\n GraphQLFieldConfig,\n GraphQLFieldConfigMap,\n GraphQLNamedType,\n GraphQLType,\n} from '../type/definition.ts';\nimport {\n assertInterfaceType,\n assertNullableType,\n assertObjectType,\n GraphQLEnumType,\n GraphQLInputObjectType,\n GraphQLInterfaceType,\n GraphQLList,\n GraphQLNonNull,\n GraphQLObjectType,\n GraphQLScalarType,\n GraphQLUnionType,\n isInputType,\n isOutputType,\n} from '../type/definition.ts';\nimport { GraphQLDirective } from '../type/directives.ts';\nimport { introspectionTypes, TypeKind } from '../type/introspection.ts';\nimport { specifiedScalarTypes } from '../type/scalars.ts';\nimport type { GraphQLSchemaValidationOptions } from '../type/schema.ts';\nimport { GraphQLSchema } from '../type/schema.ts';\n\nimport type {\n IntrospectionDirective,\n IntrospectionEnumType,\n IntrospectionField,\n IntrospectionInputObjectType,\n IntrospectionInputValue,\n IntrospectionInterfaceType,\n IntrospectionNamedTypeRef,\n IntrospectionObjectType,\n IntrospectionQuery,\n IntrospectionScalarType,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionUnionType,\n} from './getIntrospectionQuery.ts';\n\n/**\n * Build a GraphQLSchema for use by client tools.\n *\n * Given the result of a client running the introspection query, creates and\n * returns a GraphQLSchema instance which can be then used with all graphql-js\n * tools, but cannot be used to execute a query, as introspection does not\n * represent the \"resolver\", \"parse\" or \"serialize\" functions or any other\n * server-internal mechanisms.\n *\n * This function expects a complete introspection result. Don't forget to check\n * the \"errors\" field of a server response before calling this function.\n * @param introspection - Introspection result data to build from.\n * @param options - Optional configuration for this operation.\n * @returns The client schema represented by the introspection result.\n * @example\n * ```ts\n * import {\n * buildClientSchema,\n * introspectionFromSchema,\n * buildSchema,\n * } from 'graphql/utilities';\n *\n * const schema = buildSchema('type Query { hello: String }');\n * const clientSchema = buildClientSchema(introspectionFromSchema(schema), {\n * assumeValid: true,\n * });\n *\n * clientSchema.getQueryType().name; // => 'Query'\n * ```\n */\nexport function buildClientSchema(\n introspection: IntrospectionQuery,\n options?: GraphQLSchemaValidationOptions,\n): GraphQLSchema {\n // Even though the `introspection` argument is typed, in most cases it's received\n // as an untyped value from the server, so we will do an additional check here.\n devAssert(\n isObjectLike(introspection) && isObjectLike(introspection.__schema),\n `Invalid or incomplete introspection result. Ensure that you are passing \"data\" property of introspection response and no \"errors\" was returned alongside: ${inspect(\n introspection,\n )}.`,\n );\n\n // Get the schema from the introspection result.\n const schemaIntrospection = introspection.__schema;\n\n // Iterate through all types, getting the type definition for each.\n const typeMap = new Map<string, GraphQLNamedType>(\n schemaIntrospection.types.map((typeIntrospection) => [\n typeIntrospection.name,\n buildType(typeIntrospection),\n ]),\n );\n\n // Include standard types only if they are used.\n for (const stdType of [...specifiedScalarTypes, ...introspectionTypes]) {\n if (typeMap.has(stdType.name)) {\n typeMap.set(stdType.name, stdType);\n }\n }\n\n // Get the root Query, Mutation, and Subscription types.\n const queryType =\n schemaIntrospection.queryType != null\n ? getObjectType(schemaIntrospection.queryType)\n : null;\n\n const mutationType =\n schemaIntrospection.mutationType != null\n ? getObjectType(schemaIntrospection.mutationType)\n : null;\n\n const subscriptionType =\n schemaIntrospection.subscriptionType != null\n ? getObjectType(schemaIntrospection.subscriptionType)\n : null;\n\n // Get the directives supported by Introspection, assuming empty-set if\n // directives were not queried for.\n const directives =\n schemaIntrospection.directives != null\n ? schemaIntrospection.directives.map(buildDirective)\n : [];\n\n // Then produce and return a Schema with these types.\n return new GraphQLSchema({\n description: schemaIntrospection.description,\n query: queryType,\n mutation: mutationType,\n subscription: subscriptionType,\n types: [...typeMap.values()],\n directives,\n assumeValid: options?.assumeValid,\n });\n\n // Given a type reference in introspection, return the GraphQLType instance.\n // preferring cached instances before building new instances.\n function getType(typeRef: IntrospectionTypeRef): GraphQLType {\n if (typeRef.kind === TypeKind.LIST) {\n const itemRef = typeRef.ofType;\n if (itemRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n return new GraphQLList(getType(itemRef));\n }\n if (typeRef.kind === TypeKind.NON_NULL) {\n const nullableRef = typeRef.ofType;\n if (nullableRef == null) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n const nullableType = getType(nullableRef);\n return new GraphQLNonNull(assertNullableType(nullableType));\n }\n return getNamedType(typeRef);\n }\n\n function getNamedType(typeRef: IntrospectionNamedTypeRef): GraphQLNamedType {\n const typeName = typeRef.name;\n if (!typeName) {\n throw new Error(`Unknown type reference: ${inspect(typeRef)}.`);\n }\n\n const type = typeMap.get(typeName);\n if (type == null) {\n throw new Error(\n `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`,\n );\n }\n\n return type;\n }\n\n function getObjectType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionObjectType>,\n ): GraphQLObjectType {\n return assertObjectType(getNamedType(typeRef));\n }\n\n function getInterfaceType(\n typeRef: IntrospectionNamedTypeRef<IntrospectionInterfaceType>,\n ): GraphQLInterfaceType {\n return assertInterfaceType(getNamedType(typeRef));\n }\n\n // Given a type's introspection result, construct the correct\n // GraphQLType instance.\n function buildType(type: IntrospectionType): GraphQLNamedType {\n switch (type.kind) {\n case TypeKind.SCALAR:\n return buildScalarDef(type);\n case TypeKind.OBJECT:\n return buildObjectDef(type);\n case TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n case TypeKind.UNION:\n return buildUnionDef(type);\n case TypeKind.ENUM:\n return buildEnumDef(type);\n case TypeKind.INPUT_OBJECT:\n return buildInputObjectDef(type);\n default:\n // TypeScript considers this unreachable, but invalid runtime input can reach it.\n // Note: we include a default case rather than throwing after the switch to avoid\n // the use of a @ts-expect-error statement.\n throw new Error(\n `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${inspect(\n type,\n )}.`,\n );\n }\n }\n\n function buildScalarDef(\n scalarIntrospection: IntrospectionScalarType,\n ): GraphQLScalarType {\n return new GraphQLScalarType({\n name: scalarIntrospection.name,\n description: scalarIntrospection.description,\n specifiedByURL: scalarIntrospection.specifiedByURL,\n });\n }\n\n function buildImplementationsList(\n implementingIntrospection:\n | IntrospectionObjectType\n | IntrospectionInterfaceType,\n ): Array<GraphQLInterfaceType> {\n // TODO: Temporary workaround until GraphQL ecosystem will fully support\n // 'interfaces' on interface types.\n if (\n implementingIntrospection.interfaces === null &&\n implementingIntrospection.kind === TypeKind.INTERFACE\n ) {\n return [];\n }\n\n if (implementingIntrospection.interfaces == null) {\n const implementingIntrospectionStr = inspect(implementingIntrospection);\n throw new Error(\n `Introspection result missing interfaces: ${implementingIntrospectionStr}.`,\n );\n }\n\n return implementingIntrospection.interfaces.map(getInterfaceType);\n }\n\n function buildObjectDef(\n objectIntrospection: IntrospectionObjectType,\n ): GraphQLObjectType {\n return new GraphQLObjectType({\n name: objectIntrospection.name,\n description: objectIntrospection.description,\n interfaces: () => buildImplementationsList(objectIntrospection),\n fields: () => buildFieldDefMap(objectIntrospection),\n });\n }\n\n function buildInterfaceDef(\n interfaceIntrospection: IntrospectionInterfaceType,\n ): GraphQLInterfaceType {\n return new GraphQLInterfaceType({\n name: interfaceIntrospection.name,\n description: interfaceIntrospection.description,\n interfaces: () => buildImplementationsList(interfaceIntrospection),\n fields: () => buildFieldDefMap(interfaceIntrospection),\n });\n }\n\n function buildUnionDef(\n unionIntrospection: IntrospectionUnionType,\n ): GraphQLUnionType {\n if (unionIntrospection.possibleTypes == null) {\n const unionIntrospectionStr = inspect(unionIntrospection);\n throw new Error(\n `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`,\n );\n }\n return new GraphQLUnionType({\n name: unionIntrospection.name,\n description: unionIntrospection.description,\n types: () => unionIntrospection.possibleTypes.map(getObjectType),\n });\n }\n\n function buildEnumDef(\n enumIntrospection: IntrospectionEnumType,\n ): GraphQLEnumType {\n if (enumIntrospection.enumValues == null) {\n const enumIntrospectionStr = inspect(enumIntrospection);\n throw new Error(\n `Introspection result missing enumValues: ${enumIntrospectionStr}.`,\n );\n }\n return new GraphQLEnumType({\n name: enumIntrospection.name,\n description: enumIntrospection.description,\n values: keyValMap(\n enumIntrospection.enumValues,\n (valueIntrospection) => valueIntrospection.name,\n (valueIntrospection) => ({\n description: valueIntrospection.description,\n deprecationReason: valueIntrospection.deprecationReason,\n }),\n ),\n });\n }\n\n function buildInputObjectDef(\n inputObjectIntrospection: IntrospectionInputObjectType,\n ): GraphQLInputObjectType {\n if (inputObjectIntrospection.inputFields == null) {\n const inputObjectIntrospectionStr = inspect(inputObjectIntrospection);\n throw new Error(\n `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`,\n );\n }\n return new GraphQLInputObjectType({\n name: inputObjectIntrospection.name,\n description: inputObjectIntrospection.description,\n fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields),\n isOneOf: inputObjectIntrospection.isOneOf,\n });\n }\n\n function buildFieldDefMap(\n typeIntrospection: IntrospectionObjectType | IntrospectionInterfaceType,\n ): GraphQLFieldConfigMap<unknown, unknown> {\n if (typeIntrospection.fields == null) {\n throw new Error(\n `Introspection result missing fields: ${inspect(typeIntrospection)}.`,\n );\n }\n\n return keyValMap(\n typeIntrospection.fields,\n (fieldIntrospection) => fieldIntrospection.name,\n buildField,\n );\n }\n\n function buildField(\n fieldIntrospection: IntrospectionField,\n ): GraphQLFieldConfig<unknown, unknown> {\n const type = getType(fieldIntrospection.type);\n if (!isOutputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide output type for fields, but received: ${typeStr}.`,\n );\n }\n\n if (fieldIntrospection.args == null) {\n const fieldIntrospectionStr = inspect(fieldIntrospection);\n throw new Error(\n `Introspection result missing field args: ${fieldIntrospectionStr}.`,\n );\n }\n\n return {\n description: fieldIntrospection.description,\n deprecationReason: fieldIntrospection.deprecationReason,\n type,\n args: buildInputValueDefMap(fieldIntrospection.args),\n };\n }\n\n function buildInputValueDefMap(\n inputValueIntrospections: ReadonlyArray<IntrospectionInputValue>,\n ) {\n return keyValMap(\n inputValueIntrospections,\n (inputValue) => inputValue.name,\n buildInputValue,\n );\n }\n\n function buildInputValue(inputValueIntrospection: IntrospectionInputValue) {\n const type = getType(inputValueIntrospection.type);\n if (!isInputType(type)) {\n const typeStr = inspect(type);\n throw new Error(\n `Introspection must provide input type for arguments, but received: ${typeStr}.`,\n );\n }\n\n return {\n description: inputValueIntrospection.description,\n type,\n default:\n inputValueIntrospection.defaultValue != null\n ? { literal: parseConstValue(inputValueIntrospection.defaultValue) }\n : undefined,\n deprecationReason: inputValueIntrospection.deprecationReason,\n };\n }\n\n function buildDirective(\n directiveIntrospection: IntrospectionDirective,\n ): GraphQLDirective {\n if (directiveIntrospection.args == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive args: ${directiveIntrospectionStr}.`,\n );\n }\n if (directiveIntrospection.locations == null) {\n const directiveIntrospectionStr = inspect(directiveIntrospection);\n throw new Error(\n `Introspection result missing directive locations: ${directiveIntrospectionStr}.`,\n );\n }\n return new GraphQLDirective({\n name: directiveIntrospection.name,\n description: directiveIntrospection.description,\n isRepeatable: directiveIntrospection.isRepeatable,\n deprecationReason: directiveIntrospection.deprecationReason,\n locations: directiveIntrospection.locations.slice(),\n args: buildInputValueDefMap(directiveIntrospection.args),\n });\n }\n}\n"]}
|
|
@@ -68,7 +68,10 @@ export declare function coerceInputValue(inputValue: unknown, type: GraphQLInput
|
|
|
68
68
|
* },
|
|
69
69
|
* });
|
|
70
70
|
*
|
|
71
|
-
* coerceInputLiteral(
|
|
71
|
+
* coerceInputLiteral(
|
|
72
|
+
* parseValue('{ stars: 5, comment: "Loved it" }'),
|
|
73
|
+
* ReviewInput,
|
|
74
|
+
* ); // => { stars: 5, comment: 'Loved it' }
|
|
72
75
|
* coerceInputLiteral(parseValue('{ comment: "Missing" }'), ReviewInput); // => undefined
|
|
73
76
|
* ```
|
|
74
77
|
* @example
|
|
@@ -87,11 +90,9 @@ export declare function coerceInputValue(inputValue: unknown, type: GraphQLInput
|
|
|
87
90
|
* `);
|
|
88
91
|
* const document = parse('query ($stars: Int = 5) { review(stars: $stars) }');
|
|
89
92
|
* const operation = document.definitions[0];
|
|
90
|
-
* const result = getVariableValues(
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* { stars: '4' },
|
|
94
|
-
* );
|
|
93
|
+
* const result = getVariableValues(schema, operation.variableDefinitions, {
|
|
94
|
+
* stars: '4',
|
|
95
|
+
* });
|
|
95
96
|
*
|
|
96
97
|
* assert('variableValues' in result);
|
|
97
98
|
*
|