graphql-jit 0.9.0 → 0.9.1
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/dist/cjs/ast.js +1 -1
- package/dist/cjs/ast.js.map +1 -1
- package/dist/cjs/compat.d.ts +23 -16
- package/dist/cjs/compat.js +27 -6
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/execution.d.ts +6 -0
- package/dist/cjs/execution.js +72 -25
- package/dist/cjs/execution.js.map +1 -1
- package/dist/cjs/variables.js +1 -1
- package/dist/cjs/variables.js.map +1 -1
- package/dist/esm/ast.js +1 -1
- package/dist/esm/ast.js.map +1 -1
- package/dist/esm/compat.d.ts +23 -16
- package/dist/esm/compat.js +25 -6
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/execution.d.ts +6 -0
- package/dist/esm/execution.js +73 -26
- package/dist/esm/execution.js.map +1 -1
- package/dist/esm/variables.js +2 -2
- package/dist/esm/variables.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../src/variables.ts"],"names":[],"mappings":";;;;;;;AAAA,+CAAsC;AACtC,qCAoBiB;AACjB,qCAAsE;AACtE,yCAA6D;AAC7D,2CAA+D;AAC/D,8DAAyC;AACzC,yCAKoB;AAEpB,MAAM,OAAO,GAAG,IAAA,oBAAa,GAAE,CAAC;AAYhC,8BAAqC,CAAM;IACzC,OAAO,CAAC,CAAC,MAAM,CAAC;AAClB,CAAC;AAgBD,SAAS,2BAA2B,CAClC,OAA2B;IAE3B,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;AACxB,CAAC;AACD,gCACE,MAAqB,EACrB,WAAkD,EAClD,KAAuC;IAEvC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,aAAa,GAA2B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,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C,CAAC,CAAC,GAAG,IAAI;gBAC3B,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,IAAgB;IACvC,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,GAA2B,IAAI,CAAC;IACxC,OAAO,IAAI,EAAE,CAAC;QACZ,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,OAAO,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACzD,IAAI;YACF,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS;gBAC7B,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBACxB,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { genFn } from \"./generate.js\";\nimport {\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n type GraphQLInputType,\n GraphQLInt,\n GraphQLSchema,\n GraphQLString,\n isEnumType,\n isInputType,\n isListType,\n isNonNullType,\n isScalarType,\n print,\n type OperationDefinitionNode,\n type SourceLocation,\n typeFromAST,\n valueFromAST,\n type VariableDefinitionNode\n} from \"graphql\";\nimport { addPath, computeLocations, type ObjectPath } from \"./ast.js\";\nimport { GraphQLError as GraphQLJITError } from \"./error.js\";\nimport { getDefaultValue, hasDefaultValue } from \"./compat.js\";\nimport createInspect from \"./inspect.js\";\nimport {\n appendSourceURL,\n createGeneratedSourceName,\n formatDebugSource,\n type CompilerDebugOptions\n} from \"./debug.js\";\n\nconst inspect = createInspect();\n\ninterface FailedVariableCoercion {\n errors: ReadonlyArray<GraphQLError>;\n}\n\ninterface VariableValues {\n coerced: { [key: string]: any };\n}\n\nexport type CoercedVariableValues = FailedVariableCoercion | VariableValues;\n\nexport function failToParseVariables(x: any): x is FailedVariableCoercion {\n return x.errors;\n}\n\ninterface CompilationContext {\n inputPath: ObjectPath;\n responsePath: ObjectPath;\n depth: number;\n varDefNode: VariableDefinitionNode;\n dependencies: Map<string, (...args: any[]) => any>;\n errorMessage?: string;\n}\n\ninterface VariableCompilationDebugOptions {\n compilerOptions: CompilerDebugOptions;\n operation: OperationDefinitionNode;\n}\n\nfunction createSubCompilationContext(\n context: CompilationContext\n): CompilationContext {\n return { ...context };\n}\nexport function compileVariableParsing(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n debug?: VariableCompilationDebugOptions\n): (inputs: { [key: string]: any }) => CoercedVariableValues {\n const errors = [];\n const coercedValues: { [key: string]: any } = Object.create(null);\n\n let mainBody = \"\";\n const dependencies = new Map();\n for (const varDefNode of varDefNodes) {\n const context: CompilationContext = {\n varDefNode,\n depth: 0,\n inputPath: addPath(undefined, \"input\"),\n responsePath: addPath(undefined, \"coerced\"),\n dependencies\n };\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type as any);\n if (!varType || !isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n errors.push(\n new (GraphQLJITError as any)(\n `Variable \"$${varName}\" expected value of type ` +\n `\"${\n varType || print(varDefNode.type)\n }\" which cannot be used as an input type.`,\n computeLocations([varDefNode.type])\n )\n );\n continue;\n }\n\n // Ensure a constant shape of the input map\n coercedValues[varName] = undefined;\n const hasValueName = hasValue(addPath(context.inputPath, varName));\n mainBody += `const ${hasValueName} = Object.prototype.hasOwnProperty.call(${getObjectPath(\n context.inputPath\n )}, \"${varName}\");\\n`;\n context.inputPath = addPath(context.inputPath, varName);\n context.responsePath = addPath(context.responsePath, varName);\n mainBody += generateInput(\n context,\n varType,\n varName,\n hasValueName,\n valueFromAST(varDefNode.defaultValue, varType),\n false\n );\n }\n\n if (errors.length > 0) {\n throw errors;\n }\n\n const gen = genFn();\n gen(`function getVariables(input) {\n const errors = [];\n const coerced = ${JSON.stringify(coercedValues)}\n ${mainBody}\n if (errors.length > 0) {\n return {errors, coerced: undefined};\n }\n return {errors: undefined, coerced};\n }\n `);\n\n const functionExpression = gen.toString();\n const functionBody = debug\n ? \"return \" +\n formatDebugSource(\n functionExpression,\n debug.compilerOptions.formatSourceCode\n )\n : `\n return ${functionExpression}`;\n const generatedSource = debug\n ? appendSourceURL(\n functionBody,\n createGeneratedSourceName(\n debug.operation.name?.value,\n debug.compilerOptions,\n \"variables\"\n )\n )\n : functionBody;\n\n // eslint-disable-next-line\n return Function.apply(\n null,\n [\"GraphQLJITError\", \"inspect\"]\n .concat(Array.from(dependencies.keys()))\n .concat(generatedSource)\n ).apply(\n null,\n [GraphQLJITError, inspect].concat(Array.from(dependencies.values()))\n );\n}\n\n// Int Scalars represent 32 bits\n// https://graphql.github.io/graphql-spec/June2018/#sec-Int\nconst MAX_32BIT_INT = 2147483647;\nconst MIN_32BIT_INT = -2147483648;\n\nfunction generateInput(\n context: CompilationContext,\n varType: GraphQLInputType,\n varName: string,\n hasValueName: string,\n defaultValue: unknown | undefined,\n wrapInList: boolean\n) {\n const currentOutput = getObjectPath(context.responsePath);\n const currentInput = getObjectPath(context.inputPath);\n const errorLocation = printErrorLocation(\n computeLocations([context.varDefNode])\n );\n\n const gen = genFn();\n gen(`if (${currentInput} == null) {`);\n\n if (isNonNullType(varType)) {\n let nonNullMessage;\n let omittedMessage;\n if (context.errorMessage) {\n const objectPath = printObjectPath(context.responsePath);\n nonNullMessage = `${context.errorMessage} + \\`Expected non-nullable type ${varType} not to be null at ${objectPath}.\\``;\n omittedMessage = `${context.errorMessage} + \\`Field ${objectPath} of required type ${varType} was not provided.\\``;\n } else {\n nonNullMessage = `'Variable \"$${varName}\" of non-null type \"${varType}\" must not be null.'`;\n omittedMessage = `'Variable \"$${varName}\" of required type \"${varType}\" was not provided.'`;\n }\n varType = varType.ofType;\n gen(`\n if (${currentOutput} == null) {\n errors.push(new GraphQLJITError(${hasValueName} ? ${nonNullMessage} : ${omittedMessage}, ${errorLocation}));\n }\n `);\n } else {\n gen(`\n if (${hasValueName}) { ${currentOutput} = null; }\n `);\n if (defaultValue !== undefined) {\n gen(`else { ${currentOutput} = ${JSON.stringify(defaultValue)} }`);\n }\n }\n gen(`} else {`);\n if (isScalarType(varType)) {\n switch (varType.name) {\n case GraphQLID.name:\n gen(`\n if (typeof ${currentInput} === \"string\") {\n ${currentOutput} = ${currentInput};\n } else if (Number.isInteger(${currentInput})) {\n ${currentOutput} = ${currentInput}.toString();\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLString.name:\n gen(`\n if (typeof ${currentInput} === \"string\") {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent a non string value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLBoolean.name:\n gen(`\n if (typeof ${currentInput} === \"boolean\") {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent a non boolean value: ' +\n inspect(${currentInput}), ${errorLocation}));\n }\n `);\n break;\n case GraphQLInt.name:\n gen(`\n if (Number.isInteger(${currentInput})) {\n if (${currentInput} > ${MAX_32BIT_INT} || ${currentInput} < ${MIN_32BIT_INT}) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non 32-bit signed integer value: ' +\n inspect(${currentInput}), ${errorLocation}));\n } else {\n ${currentOutput} = ${currentInput};\n }\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non-integer value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLFloat.name:\n gen(`\n if (Number.isFinite(${currentInput})) {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non numeric value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n default:\n context.dependencies.set(\n `${varType.name}parseValue`,\n varType.parseValue.bind(varType)\n );\n gen(`\n try {\n const parseResult = ${varType.name}parseValue(${currentInput});\n if (parseResult === undefined || parseResult !== parseResult) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation}));\n }\n ${currentOutput} = parseResult;\n } catch (error) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation}, undefined, error)\n );\n }\n `);\n }\n } else if (isEnumType(varType)) {\n context.dependencies.set(\n `${varType.name}getValue`,\n varType.getValue.bind(varType)\n );\n gen(`\n if (typeof ${currentInput} === \"string\") {\n const enumValue = ${varType.name}getValue(${currentInput});\n if (enumValue) {\n ${currentOutput} = enumValue.value;\n } else {\n errors.push(\n new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation})\n );\n }\n } else {\n errors.push(\n new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation})\n );\n }\n `);\n } else if (isListType(varType)) {\n context.errorMessage = `'Variable \"$${varName}\" got invalid value ' + inspect(${currentInput}) + '; '`;\n const hasValueName = hasValue(context.inputPath);\n const index = `idx${context.depth}`;\n\n const subContext = createSubCompilationContext(context);\n subContext.responsePath = addPath(\n subContext.responsePath,\n index,\n \"variable\"\n );\n subContext.inputPath = addPath(subContext.inputPath, index, \"variable\");\n subContext.depth++;\n gen(`\n if (Array.isArray(${currentInput})) {\n ${currentOutput} = [];\n for (let ${index} = 0; ${index} < ${currentInput}.length; ++${index}) {\n const ${hasValueName} =\n ${getObjectPath(subContext.inputPath)} !== undefined;\n ${generateInput(\n subContext,\n varType.ofType,\n varName,\n hasValueName,\n undefined,\n false\n )}\n }\n } else {\n ${generateInput(\n context,\n varType.ofType,\n varName,\n hasValueName,\n undefined,\n true\n )}\n }\n `);\n } else if (isInputType(varType)) {\n gen(`\n if (typeof ${currentInput} !== 'object') {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name} to be an object.', ${errorLocation}));\n } else {\n ${currentOutput} = {};\n `);\n const fields = varType.getFields();\n const allowedFields = [];\n for (const field of Object.values(fields)) {\n const subContext = createSubCompilationContext(context);\n allowedFields.push(field.name);\n const hasValueName = hasValue(addPath(subContext.inputPath, field.name));\n gen(`\n const ${hasValueName} = Object.prototype.hasOwnProperty.call(\n ${getObjectPath(subContext.inputPath)}, \"${field.name}\"\n );\n `);\n subContext.inputPath = addPath(subContext.inputPath, field.name);\n subContext.responsePath = addPath(subContext.responsePath, field.name);\n subContext.errorMessage = `'Variable \"$${varName}\" got invalid value ' + inspect(${currentInput}) + '; '`;\n gen(`\n ${generateInput(\n subContext,\n field.type,\n field.name,\n hasValueName,\n hasDefaultValue(field) ? getDefaultValue(field) : undefined,\n false\n )}\n `);\n }\n\n gen(`\n const allowedFields = ${JSON.stringify(allowedFields)};\n for (const fieldName of Object.keys(${currentInput})) {\n if (!allowedFields.includes(fieldName)) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Field \"' + fieldName + '\" is not defined by type ${\n varType.name\n }.', ${errorLocation}));\n break;\n }\n }\n }`);\n } else {\n /* istanbul ignore next line */\n throw new Error(`unknown type: ${varType}`);\n }\n if (wrapInList) {\n gen(`${currentOutput} = [${currentOutput}];`);\n }\n gen(`}`);\n return gen.toString();\n}\n\nfunction hasValue(path: ObjectPath) {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.push(curr.key);\n curr = curr.prev;\n }\n return `hasValue${flattened.join(\"_\")}`;\n}\n\nfunction printErrorLocation(location: SourceLocation[]) {\n return JSON.stringify(location);\n}\n\nfunction getObjectPath(path: ObjectPath): string {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.unshift({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n let name = flattened[0].key;\n for (let i = 1; i < flattened.length; ++i) {\n name +=\n flattened[i].type === \"literal\"\n ? `[\"${flattened[i].key}\"]`\n : `[${flattened[i].key}]`;\n }\n return name;\n}\n\nfunction printObjectPath(path: ObjectPath) {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.unshift({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n const initialIndex = Math.min(flattened.length - 1, 1);\n let name = \"value\";\n for (let i = initialIndex + 1; i < flattened.length; ++i) {\n name +=\n flattened[i].type === \"literal\"\n ? `.${flattened[i].key}`\n : `[$\\{${flattened[i].key}}]`;\n }\n return name;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../src/variables.ts"],"names":[],"mappings":";;;;;;;AAAA,+CAAsC;AACtC,qCAoBiB;AACjB,qCAAsE;AACtE,yCAA6D;AAC7D,2CAIqB;AACrB,8DAAyC;AACzC,yCAKoB;AAEpB,MAAM,OAAO,GAAG,IAAA,oBAAa,GAAE,CAAC;AAYhC,8BAAqC,CAAM;IACzC,OAAO,CAAC,CAAC,MAAM,CAAC;AAClB,CAAC;AAgBD,SAAS,2BAA2B,CAClC,OAA2B;IAE3B,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;AACxB,CAAC;AACD,gCACE,MAAqB,EACrB,WAAkD,EAClD,KAAuC;IAEvC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,aAAa,GAA2B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,OAAO,GAAuB;YAClC,UAAU;YACV,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,IAAA,gBAAO,EAAC,SAAS,EAAE,OAAO,CAAC;YACtC,YAAY,EAAE,IAAA,gBAAO,EAAC,SAAS,EAAE,SAAS,CAAC;YAC3C,YAAY;SACb,CAAC;QACF,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,MAAM,EAAE,UAAU,CAAC,IAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,IAAI,CAAC,IAAA,qBAAW,EAAC,OAA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GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,OAAO,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACzD,IAAI;YACF,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS;gBAC7B,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBACxB,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { genFn } from \"./generate.js\";\nimport {\n GraphQLBoolean,\n GraphQLError,\n GraphQLFloat,\n GraphQLID,\n type GraphQLInputType,\n GraphQLInt,\n GraphQLSchema,\n GraphQLString,\n isEnumType,\n isInputType,\n isListType,\n isNonNullType,\n isScalarType,\n print,\n type OperationDefinitionNode,\n type SourceLocation,\n typeFromAST,\n valueFromAST,\n type VariableDefinitionNode\n} from \"graphql\";\nimport { addPath, computeLocations, type ObjectPath } from \"./ast.js\";\nimport { GraphQLError as GraphQLJITError } from \"./error.js\";\nimport {\n coerceInputValue,\n getDefaultValue,\n hasDefaultValue\n} from \"./compat.js\";\nimport createInspect from \"./inspect.js\";\nimport {\n appendSourceURL,\n createGeneratedSourceName,\n formatDebugSource,\n type CompilerDebugOptions\n} from \"./debug.js\";\n\nconst inspect = createInspect();\n\ninterface FailedVariableCoercion {\n errors: ReadonlyArray<GraphQLError>;\n}\n\ninterface VariableValues {\n coerced: { [key: string]: any };\n}\n\nexport type CoercedVariableValues = FailedVariableCoercion | VariableValues;\n\nexport function failToParseVariables(x: any): x is FailedVariableCoercion {\n return x.errors;\n}\n\ninterface CompilationContext {\n inputPath: ObjectPath;\n responsePath: ObjectPath;\n depth: number;\n varDefNode: VariableDefinitionNode;\n dependencies: Map<string, (...args: any[]) => any>;\n errorMessage?: string;\n}\n\ninterface VariableCompilationDebugOptions {\n compilerOptions: CompilerDebugOptions;\n operation: OperationDefinitionNode;\n}\n\nfunction createSubCompilationContext(\n context: CompilationContext\n): CompilationContext {\n return { ...context };\n}\nexport function compileVariableParsing(\n schema: GraphQLSchema,\n varDefNodes: ReadonlyArray<VariableDefinitionNode>,\n debug?: VariableCompilationDebugOptions\n): (inputs: { [key: string]: any }) => CoercedVariableValues {\n const errors = [];\n const coercedValues: { [key: string]: any } = Object.create(null);\n\n let mainBody = \"\";\n const dependencies = new Map();\n for (const varDefNode of varDefNodes) {\n const context: CompilationContext = {\n varDefNode,\n depth: 0,\n inputPath: addPath(undefined, \"input\"),\n responsePath: addPath(undefined, \"coerced\"),\n dependencies\n };\n const varName = varDefNode.variable.name.value;\n const varType = typeFromAST(schema, varDefNode.type as any);\n if (!varType || !isInputType(varType)) {\n // Must use input types for variables. This should be caught during\n // validation, however is checked again here for safety.\n errors.push(\n new (GraphQLJITError as any)(\n `Variable \"$${varName}\" expected value of type ` +\n `\"${\n varType || print(varDefNode.type)\n }\" which cannot be used as an input type.`,\n computeLocations([varDefNode.type])\n )\n );\n continue;\n }\n\n // Ensure a constant shape of the input map\n coercedValues[varName] = undefined;\n const hasValueName = hasValue(addPath(context.inputPath, varName));\n mainBody += `const ${hasValueName} = Object.prototype.hasOwnProperty.call(${getObjectPath(\n context.inputPath\n )}, \"${varName}\");\\n`;\n context.inputPath = addPath(context.inputPath, varName);\n context.responsePath = addPath(context.responsePath, varName);\n mainBody += generateInput(\n context,\n varType,\n varName,\n hasValueName,\n valueFromAST(varDefNode.defaultValue, varType),\n false\n );\n }\n\n if (errors.length > 0) {\n throw errors;\n }\n\n const gen = genFn();\n gen(`function getVariables(input) {\n const errors = [];\n const coerced = ${JSON.stringify(coercedValues)}\n ${mainBody}\n if (errors.length > 0) {\n return {errors, coerced: undefined};\n }\n return {errors: undefined, coerced};\n }\n `);\n\n const functionExpression = gen.toString();\n const functionBody = debug\n ? \"return \" +\n formatDebugSource(\n functionExpression,\n debug.compilerOptions.formatSourceCode\n )\n : `\n return ${functionExpression}`;\n const generatedSource = debug\n ? appendSourceURL(\n functionBody,\n createGeneratedSourceName(\n debug.operation.name?.value,\n debug.compilerOptions,\n \"variables\"\n )\n )\n : functionBody;\n\n // eslint-disable-next-line\n return Function.apply(\n null,\n [\"GraphQLJITError\", \"inspect\"]\n .concat(Array.from(dependencies.keys()))\n .concat(generatedSource)\n ).apply(\n null,\n [GraphQLJITError, inspect].concat(Array.from(dependencies.values()))\n );\n}\n\n// Int Scalars represent 32 bits\n// https://graphql.github.io/graphql-spec/June2018/#sec-Int\nconst MAX_32BIT_INT = 2147483647;\nconst MIN_32BIT_INT = -2147483648;\n\nfunction generateInput(\n context: CompilationContext,\n varType: GraphQLInputType,\n varName: string,\n hasValueName: string,\n defaultValue: unknown | undefined,\n wrapInList: boolean\n) {\n const currentOutput = getObjectPath(context.responsePath);\n const currentInput = getObjectPath(context.inputPath);\n const errorLocation = printErrorLocation(\n computeLocations([context.varDefNode])\n );\n\n const gen = genFn();\n gen(`if (${currentInput} == null) {`);\n\n if (isNonNullType(varType)) {\n let nonNullMessage;\n let omittedMessage;\n if (context.errorMessage) {\n const objectPath = printObjectPath(context.responsePath);\n nonNullMessage = `${context.errorMessage} + \\`Expected non-nullable type ${varType} not to be null at ${objectPath}.\\``;\n omittedMessage = `${context.errorMessage} + \\`Field ${objectPath} of required type ${varType} was not provided.\\``;\n } else {\n nonNullMessage = `'Variable \"$${varName}\" of non-null type \"${varType}\" must not be null.'`;\n omittedMessage = `'Variable \"$${varName}\" of required type \"${varType}\" was not provided.'`;\n }\n varType = varType.ofType;\n gen(`\n if (${currentOutput} == null) {\n errors.push(new GraphQLJITError(${hasValueName} ? ${nonNullMessage} : ${omittedMessage}, ${errorLocation}));\n }\n `);\n } else {\n gen(`\n if (${hasValueName}) { ${currentOutput} = null; }\n `);\n if (defaultValue !== undefined) {\n gen(`else { ${currentOutput} = ${JSON.stringify(defaultValue)} }`);\n }\n }\n gen(`} else {`);\n if (isScalarType(varType)) {\n switch (varType.name) {\n case GraphQLID.name:\n gen(`\n if (typeof ${currentInput} === \"string\") {\n ${currentOutput} = ${currentInput};\n } else if (Number.isInteger(${currentInput})) {\n ${currentOutput} = ${currentInput}.toString();\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLString.name:\n gen(`\n if (typeof ${currentInput} === \"string\") {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent a non string value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLBoolean.name:\n gen(`\n if (typeof ${currentInput} === \"boolean\") {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent a non boolean value: ' +\n inspect(${currentInput}), ${errorLocation}));\n }\n `);\n break;\n case GraphQLInt.name:\n gen(`\n if (Number.isInteger(${currentInput})) {\n if (${currentInput} > ${MAX_32BIT_INT} || ${currentInput} < ${MIN_32BIT_INT}) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non 32-bit signed integer value: ' +\n inspect(${currentInput}), ${errorLocation}));\n } else {\n ${currentOutput} = ${currentInput};\n }\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non-integer value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n case GraphQLFloat.name:\n gen(`\n if (Number.isFinite(${currentInput})) {\n ${currentOutput} = ${currentInput};\n } else {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}; ' +\n '${varType.name} cannot represent non numeric value: ' +\n inspect(${currentInput}), ${errorLocation})\n );\n }\n `);\n break;\n default:\n context.dependencies.set(\n `${varType.name}parseValue`,\n (value: unknown) => coerceInputValue(varType, value)\n );\n gen(`\n try {\n const parseResult = ${varType.name}parseValue(${currentInput});\n if (parseResult === undefined || parseResult !== parseResult) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation}));\n }\n ${currentOutput} = parseResult;\n } catch (error) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation}, undefined, error)\n );\n }\n `);\n }\n } else if (isEnumType(varType)) {\n context.dependencies.set(\n `${varType.name}getValue`,\n varType.getValue.bind(varType)\n );\n gen(`\n if (typeof ${currentInput} === \"string\") {\n const enumValue = ${varType.name}getValue(${currentInput});\n if (enumValue) {\n ${currentOutput} = enumValue.value;\n } else {\n errors.push(\n new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation})\n );\n }\n } else {\n errors.push(\n new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name}.', ${errorLocation})\n );\n }\n `);\n } else if (isListType(varType)) {\n context.errorMessage = `'Variable \"$${varName}\" got invalid value ' + inspect(${currentInput}) + '; '`;\n const hasValueName = hasValue(context.inputPath);\n const index = `idx${context.depth}`;\n\n const subContext = createSubCompilationContext(context);\n subContext.responsePath = addPath(\n subContext.responsePath,\n index,\n \"variable\"\n );\n subContext.inputPath = addPath(subContext.inputPath, index, \"variable\");\n subContext.depth++;\n gen(`\n if (Array.isArray(${currentInput})) {\n ${currentOutput} = [];\n for (let ${index} = 0; ${index} < ${currentInput}.length; ++${index}) {\n const ${hasValueName} =\n ${getObjectPath(subContext.inputPath)} !== undefined;\n ${generateInput(\n subContext,\n varType.ofType,\n varName,\n hasValueName,\n undefined,\n false\n )}\n }\n } else {\n ${generateInput(\n context,\n varType.ofType,\n varName,\n hasValueName,\n undefined,\n true\n )}\n }\n `);\n } else if (isInputType(varType)) {\n gen(`\n if (typeof ${currentInput} !== 'object') {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Expected type ${varType.name} to be an object.', ${errorLocation}));\n } else {\n ${currentOutput} = {};\n `);\n const fields = varType.getFields();\n const allowedFields = [];\n for (const field of Object.values(fields)) {\n const subContext = createSubCompilationContext(context);\n allowedFields.push(field.name);\n const hasValueName = hasValue(addPath(subContext.inputPath, field.name));\n gen(`\n const ${hasValueName} = Object.prototype.hasOwnProperty.call(\n ${getObjectPath(subContext.inputPath)}, \"${field.name}\"\n );\n `);\n subContext.inputPath = addPath(subContext.inputPath, field.name);\n subContext.responsePath = addPath(subContext.responsePath, field.name);\n subContext.errorMessage = `'Variable \"$${varName}\" got invalid value ' + inspect(${currentInput}) + '; '`;\n gen(`\n ${generateInput(\n subContext,\n field.type,\n field.name,\n hasValueName,\n hasDefaultValue(field) ? getDefaultValue(field) : undefined,\n false\n )}\n `);\n }\n\n gen(`\n const allowedFields = ${JSON.stringify(allowedFields)};\n for (const fieldName of Object.keys(${currentInput})) {\n if (!allowedFields.includes(fieldName)) {\n errors.push(new GraphQLJITError('Variable \"$${varName}\" got invalid value ' +\n inspect(${currentInput}) + \"; \" +\n 'Field \"' + fieldName + '\" is not defined by type ${\n varType.name\n }.', ${errorLocation}));\n break;\n }\n }\n }`);\n } else {\n /* istanbul ignore next line */\n throw new Error(`unknown type: ${varType}`);\n }\n if (wrapInList) {\n gen(`${currentOutput} = [${currentOutput}];`);\n }\n gen(`}`);\n return gen.toString();\n}\n\nfunction hasValue(path: ObjectPath) {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.push(curr.key);\n curr = curr.prev;\n }\n return `hasValue${flattened.join(\"_\")}`;\n}\n\nfunction printErrorLocation(location: SourceLocation[]) {\n return JSON.stringify(location);\n}\n\nfunction getObjectPath(path: ObjectPath): string {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.unshift({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n let name = flattened[0].key;\n for (let i = 1; i < flattened.length; ++i) {\n name +=\n flattened[i].type === \"literal\"\n ? `[\"${flattened[i].key}\"]`\n : `[${flattened[i].key}]`;\n }\n return name;\n}\n\nfunction printObjectPath(path: ObjectPath) {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.unshift({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n const initialIndex = Math.min(flattened.length - 1, 1);\n let name = \"value\";\n for (let i = initialIndex + 1; i < flattened.length; ++i) {\n name +=\n flattened[i].type === \"literal\"\n ? `.${flattened[i].key}`\n : `[$\\{${flattened[i].key}}]`;\n }\n return name;\n}\n"]}
|
package/dist/esm/ast.js
CHANGED
|
@@ -475,7 +475,7 @@ export function getArgumentDefs(def, node) {
|
|
|
475
475
|
for (const argDef of argDefs) {
|
|
476
476
|
const name = argDef.name;
|
|
477
477
|
if (hasDefaultValue(argDef)) {
|
|
478
|
-
// handle
|
|
478
|
+
// handle v16 defaultValue, and v17 default.value/default.literal
|
|
479
479
|
values[name] = getDefaultValue(argDef);
|
|
480
480
|
}
|
|
481
481
|
const argType = argDef.type;
|
package/dist/esm/ast.js.map
CHANGED
|
@@ -1 +1 @@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D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,SAAS,CAAC,KAAU;IAC3B,2CAA2C;IAC3C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import {\n type ArgumentNode,\n type ASTNode,\n type DirectiveNode,\n type FieldNode,\n type FragmentDefinitionNode,\n type GraphQLArgument,\n GraphQLDirective,\n GraphQLError,\n type GraphQLField,\n GraphQLIncludeDirective,\n type GraphQLInputType,\n GraphQLObjectType,\n GraphQLSkipDirective,\n type InlineFragmentNode,\n isEnumType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isScalarType,\n print,\n type SelectionSetNode,\n type SourceLocation,\n typeFromAST,\n valueFromASTUntyped,\n type ValueNode,\n type VariableNode,\n Kind,\n type SelectionNode,\n type TypeNode,\n isAbstractType,\n Location,\n type ConstValueNode\n} from \"graphql\";\nimport { type CompilationContext, GLOBAL_VARIABLES_NAME } from \"./execution.js\";\nimport createInspect from \"./inspect.js\";\nimport {\n coerceInputLiteral,\n getDefaultValue,\n getGraphQLErrorOptions,\n hasDefaultValue,\n resolveFieldDef\n} from \"./compat.js\";\n\nexport interface JitFieldNode extends FieldNode {\n /**\n * @deprecated Use __internalShouldIncludePath instead\n * @see __internalShouldIncludePath\n */\n __internalShouldInclude?: string[];\n\n // The shouldInclude logic is specific to the current path\n // This is because the same fieldNode can be reached from different paths\n // - for example, the same fragment used in two different places\n __internalShouldIncludePath?: {\n // Key is the stringified ObjectPath,\n // Value is the shouldInclude logic for that path\n [path: string]: string[];\n };\n}\n\nexport interface FieldsAndNodes {\n [key: string]: JitFieldNode[];\n}\n\nconst inspect = createInspect();\n\n/**\n * Given a selectionSet, adds all of the fields in that selection to\n * the passed in map of fields, and returns it at the end.\n *\n * CollectFields requires the \"runtime type\" of an object. For a field which\n * returns an Interface or Union type, the \"runtime type\" will be the actual\n * Object type returned by that field.\n */\nexport function collectFields(\n compilationContext: CompilationContext,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n fields: FieldsAndNodes,\n visitedFragmentNames: { [key: string]: boolean },\n parentResponsePath?: ObjectPath\n): FieldsAndNodes {\n return collectFieldsImpl(\n compilationContext,\n runtimeType,\n selectionSet,\n fields,\n visitedFragmentNames,\n undefined,\n serializeObjectPathForSkipInclude(parentResponsePath)\n );\n}\n\n/**\n * Implementation of collectFields defined above with extra parameters\n * used for recursion and need not be exposed publically\n */\nfunction collectFieldsImpl(\n compilationContext: CompilationContext,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n fields: FieldsAndNodes,\n visitedFragmentNames: { [key: string]: boolean },\n previousShouldInclude: string[] = [],\n parentResponsePath = \"\"\n): FieldsAndNodes {\n interface StackItem {\n selection: SelectionNode;\n parentResponsePath: string;\n previousShouldInclude: string[];\n }\n\n const stack: StackItem[] = [];\n\n // Push in reverse so that stack.pop() will process in document order\n for (let i = selectionSet.selections.length - 1; i >= 0; i--) {\n stack.push({\n selection: selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude\n });\n }\n\n while (stack.length > 0) {\n const { selection, parentResponsePath, previousShouldInclude } =\n stack.pop()!;\n\n switch (selection.kind) {\n case Kind.FIELD: {\n collectFieldsForField({\n compilationContext,\n fields,\n parentResponsePath,\n previousShouldInclude,\n selection\n });\n break;\n }\n\n case Kind.INLINE_FRAGMENT: {\n if (\n !doesFragmentConditionMatch(\n compilationContext,\n selection,\n runtimeType\n )\n ) {\n break;\n }\n\n // current fragment's shouldInclude\n const compiledSkipInclude = compileSkipInclude(\n compilationContext,\n selection\n );\n\n const mergedShouldInclude = joinShouldIncludeCompilations(\n previousShouldInclude,\n [compiledSkipInclude]\n );\n\n // Push in reverse so that stack.pop() will process in document order\n const selectionsLength = selection.selectionSet.selections.length;\n for (let i = selectionsLength - 1; i >= 0; i--) {\n stack.push({\n selection: selection.selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude: mergedShouldInclude\n });\n }\n break;\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n if (visitedFragmentNames[fragName]) {\n break;\n }\n visitedFragmentNames[fragName] = true;\n const fragment = compilationContext.fragments[fragName];\n if (\n !fragment ||\n !doesFragmentConditionMatch(compilationContext, fragment, runtimeType)\n ) {\n break;\n }\n\n // current fragment's shouldInclude\n const compiledSkipInclude = compileSkipInclude(\n compilationContext,\n selection\n );\n\n const mergedShouldInclude = joinShouldIncludeCompilations(\n previousShouldInclude,\n [compiledSkipInclude]\n );\n\n // Push in reverse so that stack.pop() will process in document order\n const selectionsLength = fragment.selectionSet.selections.length;\n for (let i = selectionsLength - 1; i >= 0; i--) {\n stack.push({\n selection: fragment.selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude: mergedShouldInclude\n });\n }\n break;\n }\n }\n }\n\n return fields;\n}\n\nfunction collectFieldsForField({\n compilationContext,\n fields,\n parentResponsePath,\n previousShouldInclude,\n selection\n}: {\n compilationContext: CompilationContext;\n fields: FieldsAndNodes;\n parentResponsePath: string;\n previousShouldInclude: string[];\n selection: FieldNode;\n}) {\n const name = getFieldEntryKey(selection);\n if (!fields[name]) {\n fields[name] = [];\n }\n const fieldNode: JitFieldNode = selection;\n\n // the current path of the field\n // This is used to generate per path skip/include code\n // because the same field can be reached from different paths (e.g. fragment reuse)\n const currentPath = joinSkipIncludePath(\n parentResponsePath,\n\n // use alias(instead of selection.name.value) if available as the responsePath used for lookup uses alias\n name\n );\n\n // `should include`s generated for the current fieldNode\n const compiledSkipInclude = compileSkipInclude(compilationContext, selection);\n\n /**\n * Carry over fragment's skip and include code\n *\n * fieldNode.__internalShouldInclude\n * ---------------------------------\n * When the parent field has a skip or include, the current one\n * should be skipped if the parent is skipped in the path.\n *\n * previousShouldInclude\n * ---------------------\n * `should include`s from fragment spread and inline fragments\n *\n * compileSkipInclude(selection)\n * -----------------------------\n * `should include`s generated for the current fieldNode\n */\n if (compilationContext.options.useExperimentalPathBasedSkipInclude) {\n if (!fieldNode.__internalShouldIncludePath)\n fieldNode.__internalShouldIncludePath = {};\n\n fieldNode.__internalShouldIncludePath[currentPath] =\n joinShouldIncludeCompilations(\n fieldNode.__internalShouldIncludePath?.[currentPath] ?? [],\n previousShouldInclude,\n [compiledSkipInclude]\n );\n } else {\n // @deprecated\n fieldNode.__internalShouldInclude = joinShouldIncludeCompilations(\n fieldNode.__internalShouldInclude ?? [],\n previousShouldInclude,\n [compiledSkipInclude]\n );\n }\n /**\n * We augment the entire subtree as the parent object's skip/include\n * directives influence the child even if the child doesn't have\n * skip/include on it's own.\n *\n * Refer the function definition for example.\n */\n augmentFieldNodeTree(compilationContext, fieldNode, currentPath);\n\n fields[name].push(fieldNode);\n}\n\n/**\n * Augment __internalShouldInclude code for all sub-fields in the\n * tree with @param rootfieldNode as the root.\n *\n * This is required to handle cases where there are multiple paths to\n * the same node. And each of those paths contain different skip/include\n * values.\n *\n * For example,\n *\n * ```\n * {\n * foo @skip(if: $c1) {\n * bar @skip(if: $c2)\n * }\n * ... {\n * foo @skip(if: $c3) {\n * bar\n * }\n * }\n * }\n * ```\n *\n * We decide shouldInclude at runtime per fieldNode. When we handle the\n * field `foo`, the logic is straight forward - it requires one of $c1 or $c3\n * to be false.\n *\n * But, when we handle the field `bar`, and we are in the context of the fieldNode,\n * not enough information is available. This is because, if we only included $c2\n * to decide if bar is included, consider the case -\n *\n * $c1: true, $c2: true, $c3: false\n *\n * If we considered only $c2, we would have skipped bar. But the correct implementation\n * is to include bar, because foo($c3) { bar } is not skipped. The entire sub-tree's\n * logic is required to handle bar.\n *\n * So, to handle this case, we augment the tree at each point to consider the\n * skip/include logic from the parent as well.\n *\n * @param compilationContext {CompilationContext} Required for getFragment by\n * name to handle fragment spread operation.\n *\n * @param rootFieldNode {JitFieldNode} The root field to traverse from for\n * adding __internalShouldInclude to all sub field nodes.\n *\n * @param parentResponsePath {string} The response path of the parent field.\n */\nfunction augmentFieldNodeTree(\n compilationContext: CompilationContext,\n rootFieldNode: JitFieldNode,\n parentResponsePath: string\n) {\n for (const selection of rootFieldNode.selectionSet?.selections ?? []) {\n /**\n * Traverse through sub-selection and combine `shouldInclude`s\n * from parent and current ones.\n */\n interface StackItem {\n parentFieldNode: JitFieldNode;\n selection: SelectionNode;\n comesFromFragmentSpread: boolean;\n parentResponsePath: string;\n }\n\n const stack: StackItem[] = [];\n\n stack.push({\n parentFieldNode: rootFieldNode,\n selection,\n comesFromFragmentSpread: false,\n parentResponsePath\n });\n\n while (stack.length > 0) {\n const {\n parentFieldNode,\n selection,\n comesFromFragmentSpread,\n parentResponsePath\n } = stack.pop()!;\n\n switch (selection.kind) {\n case Kind.FIELD: {\n const jitFieldNode: JitFieldNode = selection;\n const currentPath = joinSkipIncludePath(\n parentResponsePath,\n\n // use alias(instead of selection.name.value) if available as the responsePath used for lookup uses alias\n getFieldEntryKey(jitFieldNode)\n );\n\n if (!comesFromFragmentSpread) {\n if (\n compilationContext.options.useExperimentalPathBasedSkipInclude\n ) {\n if (!jitFieldNode.__internalShouldIncludePath)\n jitFieldNode.__internalShouldIncludePath = {};\n\n jitFieldNode.__internalShouldIncludePath[currentPath] =\n joinShouldIncludeCompilations(\n parentFieldNode.__internalShouldIncludePath?.[\n parentResponsePath\n ] ?? [],\n jitFieldNode.__internalShouldIncludePath?.[currentPath] ?? []\n );\n } else {\n // @deprecated\n jitFieldNode.__internalShouldInclude =\n joinShouldIncludeCompilations(\n parentFieldNode.__internalShouldInclude ?? [],\n jitFieldNode.__internalShouldInclude ?? []\n );\n }\n }\n // go further down the query tree\n for (const selection of jitFieldNode.selectionSet?.selections ?? []) {\n stack.push({\n parentFieldNode: jitFieldNode,\n selection,\n comesFromFragmentSpread: false,\n parentResponsePath: currentPath\n });\n }\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n for (const subSelection of selection.selectionSet.selections) {\n stack.push({\n parentFieldNode,\n selection: subSelection,\n comesFromFragmentSpread: true,\n parentResponsePath\n });\n }\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragment = compilationContext.fragments[selection.name.value];\n for (const subSelection of fragment.selectionSet.selections) {\n stack.push({\n parentFieldNode,\n selection: subSelection,\n comesFromFragmentSpread: true,\n parentResponsePath\n });\n }\n }\n }\n }\n }\n}\n\n/**\n * Joins a list of shouldInclude compiled code into a single logical\n * statement.\n *\n * The operation is `&&` because, it is used to join parent->child\n * relations in the query tree. Note: parent can be either parent field\n * or fragment.\n *\n * For example,\n * {\n * foo @skip(if: $c1) {\n * ... @skip(if: $c2) {\n * bar @skip(if: $c3)\n * }\n * }\n * }\n *\n * Only when a parent is included, the child is included. So, we use `&&`.\n *\n * compilationFor($c1) && compilationFor($c2) && compilationFor($c3)\n *\n * @param compilations\n */\nfunction joinShouldIncludeCompilations(...compilations: string[][]): string[] {\n // remove \"true\" since we are joining with '&&' as `true && X` = `X`\n // This prevents an explosion of `&& true` which could break\n // V8's internal size limit for string.\n //\n // Note: the `true` appears if a field does not have a skip/include directive\n // So, the more nested the query is, the more of unnecessary `&& true`\n // we get.\n //\n // Failing to do this results in [RangeError: invalid array length]\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length\n\n const conditionsSet = new Set<string>();\n for (const conditions of compilations) {\n for (const condition of conditions) {\n if (condition !== \"true\") {\n conditionsSet.add(condition);\n }\n }\n }\n\n return Array.from(conditionsSet);\n}\n\n/**\n * Compiles directives `skip` and `include` and generates the compilation\n * code based on GraphQL specification.\n *\n * @param node {SelectionNode} The selection node (field/fragment/inline-fragment)\n * for which we generate the compiled skipInclude.\n */\nfunction compileSkipInclude(\n compilationContext: CompilationContext,\n node: SelectionNode\n): string {\n // minor optimization to avoid compilation if there are no directives\n if (node.directives == null || node.directives.length < 1) {\n return \"true\";\n }\n\n const { skipValue, includeValue } = compileSkipIncludeDirectiveValues(\n compilationContext,\n node\n );\n\n /**\n * Spec: https://spec.graphql.org/June2018/#sec--include\n *\n * Neither @skip nor @include has precedence over the other.\n * In the case that both the @skip and @include directives\n * are provided in on the same the field or fragment, it must\n * be queried only if the @skip condition is false and the\n * @include condition is true. Stated conversely, the field\n * or fragment must not be queried if either the @skip\n * condition is true or the @include condition is false.\n */\n if (skipValue != null && includeValue != null) {\n return `${skipValue} === false && ${includeValue} === true`;\n } else if (skipValue != null) {\n return `(${skipValue} === false)`;\n } else if (includeValue != null) {\n return `(${includeValue} === true)`;\n } else {\n return `true`;\n }\n}\n\n/**\n * Compile skip or include directive values into JIT compatible\n * runtime code.\n *\n * @param node {SelectionNode}\n */\nfunction compileSkipIncludeDirectiveValues(\n compilationContext: CompilationContext,\n node: SelectionNode\n) {\n const skipDirective = node.directives?.find(\n (it) => it.name.value === GraphQLSkipDirective.name\n );\n const includeDirective = node.directives?.find(\n (it) => it.name.value === GraphQLIncludeDirective.name\n );\n\n const skipValue = skipDirective\n ? compileSkipIncludeDirective(compilationContext, skipDirective)\n : // The null here indicates the absense of the directive\n // which is later used to determine if both skip and include\n // are present\n null;\n const includeValue = includeDirective\n ? compileSkipIncludeDirective(compilationContext, includeDirective)\n : // The null here indicates the absense of the directive\n // which is later used to determine if both skip and include\n // are present\n null;\n\n return { skipValue, includeValue };\n}\n\n/**\n * Compile the skip/include directive node. Resolve variables to it's\n * path from context, resolve scalars to their respective values.\n *\n * @param directive {DirectiveNode}\n */\nfunction compileSkipIncludeDirective(\n compilationContext: CompilationContext,\n directive: DirectiveNode\n) {\n const ifNode = directive.arguments?.find((it) => it.name.value === \"if\");\n if (ifNode == null) {\n throw new GraphQLError(\n `Directive '${directive.name.value}' is missing required arguments: 'if'`,\n getGraphQLErrorOptions([directive])\n );\n }\n\n switch (ifNode.value.kind) {\n case Kind.VARIABLE:\n validateSkipIncludeVariableType(compilationContext, ifNode.value);\n return `${GLOBAL_VARIABLES_NAME}[\"${ifNode.value.name.value}\"]`;\n case Kind.BOOLEAN:\n return `${ifNode.value.value.toString()}`;\n default:\n throw new GraphQLError(\n `Argument 'if' on Directive '${\n directive.name.value\n }' has an invalid value (${valueFromASTUntyped(\n ifNode.value\n )}). Expected type 'Boolean!'`,\n getGraphQLErrorOptions([ifNode])\n );\n }\n}\n\n/**\n * Validate the skip and include directive's argument values at compile time.\n *\n * This validation step is required as these directives are part of an\n * implicit schema in GraphQL.\n *\n * @param compilationContext {CompilationContext}\n * @param variable {VariableNode} the variable used in 'if' argument of the skip/include directive\n */\nfunction validateSkipIncludeVariableType(\n compilationContext: CompilationContext,\n variable: VariableNode\n) {\n const variableDefinition =\n compilationContext.operation.variableDefinitions?.find(\n (it) => it.variable.name.value === variable.name.value\n );\n if (variableDefinition == null) {\n throw new GraphQLError(\n `Variable '${variable.name.value}' is not defined`,\n getGraphQLErrorOptions([variable])\n );\n }\n\n // Part of Spec text: https://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed\n if (\n !(\n // The variable defintion is a Non-nullable Boolean type\n (\n (variableDefinition.type.kind === Kind.NON_NULL_TYPE &&\n variableDefinition.type.type.kind === Kind.NAMED_TYPE &&\n variableDefinition.type.type.name.value === \"Boolean\") ||\n // or the variable definition is a nullable Boolean type with a default value\n (variableDefinition.type.kind === Kind.NAMED_TYPE &&\n variableDefinition.type.name.value === \"Boolean\" &&\n variableDefinition.defaultValue != null)\n )\n )\n ) {\n throw new GraphQLError(\n `Variable '${variable.name.value}' of type '${typeNodeToString(\n variableDefinition.type\n )}' used in position expecting type 'Boolean!'`,\n getGraphQLErrorOptions([variableDefinition])\n );\n }\n}\n\n/**\n * Print the string representation of the TypeNode for error messages\n *\n * @param type {TypeNode} type node to be converted to string representation\n */\nfunction typeNodeToString(type: TypeNode): string {\n switch (type.kind) {\n case Kind.NAMED_TYPE:\n return type.name.value;\n case Kind.NON_NULL_TYPE:\n return `${typeNodeToString(type.type)}!`;\n case Kind.LIST_TYPE:\n return `[${typeNodeToString(type.type)}]`;\n }\n}\n\n/**\n * Determines if a fragment is applicable to the given type.\n */\nfunction doesFragmentConditionMatch(\n compilationContext: CompilationContext,\n fragment: FragmentDefinitionNode | InlineFragmentNode,\n type: GraphQLObjectType\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n const conditionalType = typeFromAST(\n compilationContext.schema,\n typeConditionNode\n );\n if (conditionalType === type) {\n return true;\n }\n if (!conditionalType) {\n return false;\n }\n if (isAbstractType(conditionalType)) {\n return compilationContext.schema.isSubType(conditionalType, type);\n }\n return false;\n}\n\n/**\n * Implements the logic to compute the key of a given field's entry\n */\nfunction getFieldEntryKey(node: FieldNode): string {\n return node.alias ? node.alias.value : node.name.value;\n}\n\nexport { resolveFieldDef };\n\nexport function collectSubfields(\n compilationContext: CompilationContext,\n returnType: GraphQLObjectType,\n fieldNodes: FieldNode[],\n parentResponsePath?: ObjectPath\n): { [key: string]: FieldNode[] } {\n let subFieldNodes = Object.create(null);\n const visitedFragmentNames = Object.create(null);\n for (const fieldNode of fieldNodes) {\n const selectionSet = fieldNode.selectionSet;\n if (selectionSet) {\n subFieldNodes = collectFields(\n compilationContext,\n returnType,\n selectionSet,\n subFieldNodes,\n visitedFragmentNames,\n parentResponsePath\n );\n }\n }\n return subFieldNodes;\n}\n\n// response path is used for identifying\n// the info resolver function as well as the path in errros,\n// the meta type is used for elements that are only to be used for\n// the function name\ntype ResponsePathType = \"variable\" | \"literal\" | \"meta\";\n\nexport interface ObjectPath {\n prev: ObjectPath | undefined;\n key: string;\n type: ResponsePathType;\n}\n\ninterface MissingVariablePath {\n valueNode: VariableNode;\n path?: ObjectPath;\n argument?: { definition: GraphQLArgument; node: ArgumentNode };\n}\n\nexport interface Arguments {\n values: { [argument: string]: any };\n missing: MissingVariablePath[];\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getArgumentDefs(\n def: GraphQLField<any, any> | GraphQLDirective,\n node: FieldNode | DirectiveNode\n): Arguments {\n const values: { [key: string]: any } = {};\n const missing: MissingVariablePath[] = [];\n const argDefs = def.args;\n const argNodes = node.arguments || [];\n const argNodeMap = keyMap(argNodes, (arg) => arg.name.value);\n for (const argDef of argDefs) {\n const name = argDef.name;\n if (hasDefaultValue(argDef)) {\n // handle both v16 defaultValue and v17 default.value\n values[name] = getDefaultValue(argDef);\n }\n const argType = argDef.type;\n const argumentNode = argNodeMap[name];\n let hasVariables = false;\n if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {\n hasVariables = true;\n missing.push({\n valueNode: argumentNode.value,\n path: addPath(undefined, name, \"literal\"),\n argument: { definition: argDef, node: argumentNode }\n });\n } else if (argumentNode) {\n const coercedValue = valueFromAST(argumentNode.value, argType);\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectType validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" of type \"${argType}\" has invalid value ${print(\n argumentNode.value\n )}.`,\n getGraphQLErrorOptions(argumentNode.value)\n );\n }\n\n if (isASTValueWithVariables(coercedValue)) {\n missing.push(\n ...coercedValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, name, \"literal\")\n }))\n );\n }\n values[name] = coercedValue.value;\n }\n if (isNonNullType(argType) && values[name] === undefined && !hasVariables) {\n // If no value or a nullish value was provided to a variable with a\n // non-null type (required), produce an error.\n throw new GraphQLError(\n argumentNode\n ? `Argument \"${name}\" of non-null type ` +\n `\"${argType}\" must not be null.`\n : `Argument \"${name}\" of required type ` +\n `\"${argType}\" was not provided.`,\n getGraphQLErrorOptions(node)\n );\n }\n }\n return { values, missing };\n}\n\ninterface ASTValueWithVariables {\n value: object | string | boolean | symbol | number | null | any[];\n variables: MissingVariablePath[];\n}\n\nfunction isASTValueWithVariables(x: any): x is ASTValueWithVariables {\n return !!x.variables;\n}\n\ninterface ASTValue {\n value: object | string | boolean | symbol | number | null | any[];\n}\n\nexport function valueFromAST(\n valueNode: ValueNode,\n type: GraphQLInputType\n): undefined | ASTValue | ASTValueWithVariables {\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return valueFromAST(valueNode, type.ofType);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return {\n value: null\n };\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n return { value: null, variables: [{ valueNode, path: undefined }] };\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n const variables: MissingVariablePath[] = [];\n const itemNodes = valueNode.values;\n for (let i = 0; i < itemNodes.length; i++) {\n const itemNode = itemNodes[i];\n if (itemNode.kind === Kind.VARIABLE) {\n coercedValues.push(null);\n variables.push({\n valueNode: itemNode,\n path: addPath(undefined, i.toString(), \"literal\")\n });\n } else {\n const itemValue = valueFromAST(itemNode, itemType);\n if (!itemValue) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(itemValue.value);\n if (isASTValueWithVariables(itemValue)) {\n variables.push(\n ...itemValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, i.toString(), \"literal\")\n }))\n );\n }\n }\n }\n return { value: coercedValues, variables };\n }\n // Single item which will be coerced to a list\n const coercedValue = valueFromAST(valueNode, itemType);\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n if (isASTValueWithVariables(coercedValue)) {\n return {\n value: [coercedValue.value],\n variables: coercedValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, \"0\", \"literal\")\n }))\n };\n }\n return { value: [coercedValue.value] };\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n const coercedObj = Object.create(null);\n const variables: MissingVariablePath[] = [];\n const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value);\n const fields = Object.values(type.getFields());\n for (const field of fields) {\n if (hasDefaultValue(field)) {\n coercedObj[field.name] = getDefaultValue(field);\n }\n const fieldNode = fieldNodes[field.name];\n if (!fieldNode) {\n continue;\n }\n const fieldValue = valueFromAST(fieldNode.value, field.type);\n if (!fieldValue) {\n return; // Invalid: intentionally return no value.\n }\n if (isASTValueWithVariables(fieldValue)) {\n variables.push(\n ...fieldValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, field.name, \"literal\")\n }))\n );\n }\n coercedObj[field.name] = fieldValue.value;\n }\n return { value: coercedObj, variables };\n }\n\n if (isEnumType(type)) {\n if (valueNode.kind !== Kind.ENUM) {\n return; // Invalid: intentionally return no value.\n }\n const enumValue = type.getValue(valueNode.value);\n if (!enumValue) {\n return; // Invalid: intentionally return no value.\n }\n return { value: enumValue.value };\n }\n\n if (isScalarType(type)) {\n // Scalars fulfill parsing a literal value via coerceInputLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result: any;\n try {\n // By this point, we've filtered out VARIABLE nodes, so valueNode is a ConstValueNode\n result = coerceInputLiteral(type, valueNode as ConstValueNode);\n } catch (error) {\n return; // Invalid: intentionally return no value.\n }\n if (isInvalid(result)) {\n return; // Invalid: intentionally return no value.\n }\n return { value: result };\n }\n\n // Not reachable. All possible input types have been considered.\n /* istanbul ignore next */\n throw new Error(`Unexpected input type: \"${inspect(type)}\".`);\n}\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' } }\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // { name: 'Jenny', num: '857-6309' }\n * const jennyEntry = entriesByName['Jenny']\n *\n */\nfunction keyMap<T>(\n list: ReadonlyArray<T>,\n keyFn: (item: T) => string\n): { [key: string]: T } {\n return list.reduce(\n // eslint-disable-next-line no-sequences\n (map, item) => ((map[keyFn(item)] = item), map),\n Object.create(null)\n );\n}\n\nexport function computeLocations(nodes: ASTNode[]): SourceLocation[] {\n return nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(getLocation(node.loc));\n }\n return list;\n }, [] as SourceLocation[]);\n}\n\n/**\n * This is an alternate faster implementation of getLocation in graphql-js\n *\n * Optimization:\n * In graphql-js, getLocation is implemented as finding line and column\n * from a given position in the source. Since the use-case in GraphQL-JIT\n * is to find the location of a node, we can directly use the line and\n * column from the startToken of the node's location.\n *\n * @param loc the Node's location\n * @returns the SourceLocation for the position\n */\nfunction getLocation(loc: Location): SourceLocation {\n // If the location already contains line and column, return it directly\n return {\n line: loc.startToken.line,\n column: loc.startToken.column\n };\n}\n\nexport function addPath(\n responsePath: ObjectPath | undefined,\n key: string,\n type: ResponsePathType = \"literal\"\n): ObjectPath {\n return { prev: responsePath, key, type };\n}\n\nexport function flattenPath(\n path: ObjectPath\n): Array<{ key: string; type: ResponsePathType }> {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.push({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n return flattened;\n}\n\n/**\n * Serialize a path for use in the skip/include directives.\n *\n * @param path The path to serialize\n * @returns The path serialized as a string, with the root path first.\n */\nexport function serializeObjectPathForSkipInclude(\n path: ObjectPath | undefined\n) {\n let serialized = \"\";\n let curr = path;\n while (curr) {\n if (curr.type === \"literal\") {\n serialized = joinSkipIncludePath(curr.key, serialized);\n }\n curr = curr.prev;\n }\n return serialized;\n}\n\n/**\n * join two path segments to a dot notation, handling empty strings\n *\n * @param a path segment\n * @param b path segment\n * @returns combined path in dot notation\n */\nexport function joinSkipIncludePath(a: string, b: string) {\n if (a) {\n if (b) {\n return `${a}.${b}`;\n }\n return a;\n }\n return b;\n}\n\nfunction isInvalid(value: any): boolean {\n // eslint-disable-next-line no-self-compare\n return value === undefined || value !== value;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources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,CAAC,KAAU;IAC3B,2CAA2C;IAC3C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC;AAChD,CAAC","sourcesContent":["import {\n type ArgumentNode,\n type ASTNode,\n type DirectiveNode,\n type FieldNode,\n type FragmentDefinitionNode,\n type GraphQLArgument,\n GraphQLDirective,\n GraphQLError,\n type GraphQLField,\n GraphQLIncludeDirective,\n type GraphQLInputType,\n GraphQLObjectType,\n GraphQLSkipDirective,\n type InlineFragmentNode,\n isEnumType,\n isInputObjectType,\n isListType,\n isNonNullType,\n isScalarType,\n print,\n type SelectionSetNode,\n type SourceLocation,\n typeFromAST,\n valueFromASTUntyped,\n type ValueNode,\n type VariableNode,\n Kind,\n type SelectionNode,\n type TypeNode,\n isAbstractType,\n Location,\n type ConstValueNode\n} from \"graphql\";\nimport { type CompilationContext, GLOBAL_VARIABLES_NAME } from \"./execution.js\";\nimport createInspect from \"./inspect.js\";\nimport {\n coerceInputLiteral,\n getDefaultValue,\n getGraphQLErrorOptions,\n hasDefaultValue,\n resolveFieldDef\n} from \"./compat.js\";\n\nexport interface JitFieldNode extends FieldNode {\n /**\n * @deprecated Use __internalShouldIncludePath instead\n * @see __internalShouldIncludePath\n */\n __internalShouldInclude?: string[];\n\n // The shouldInclude logic is specific to the current path\n // This is because the same fieldNode can be reached from different paths\n // - for example, the same fragment used in two different places\n __internalShouldIncludePath?: {\n // Key is the stringified ObjectPath,\n // Value is the shouldInclude logic for that path\n [path: string]: string[];\n };\n}\n\nexport interface FieldsAndNodes {\n [key: string]: JitFieldNode[];\n}\n\nconst inspect = createInspect();\n\n/**\n * Given a selectionSet, adds all of the fields in that selection to\n * the passed in map of fields, and returns it at the end.\n *\n * CollectFields requires the \"runtime type\" of an object. For a field which\n * returns an Interface or Union type, the \"runtime type\" will be the actual\n * Object type returned by that field.\n */\nexport function collectFields(\n compilationContext: CompilationContext,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n fields: FieldsAndNodes,\n visitedFragmentNames: { [key: string]: boolean },\n parentResponsePath?: ObjectPath\n): FieldsAndNodes {\n return collectFieldsImpl(\n compilationContext,\n runtimeType,\n selectionSet,\n fields,\n visitedFragmentNames,\n undefined,\n serializeObjectPathForSkipInclude(parentResponsePath)\n );\n}\n\n/**\n * Implementation of collectFields defined above with extra parameters\n * used for recursion and need not be exposed publically\n */\nfunction collectFieldsImpl(\n compilationContext: CompilationContext,\n runtimeType: GraphQLObjectType,\n selectionSet: SelectionSetNode,\n fields: FieldsAndNodes,\n visitedFragmentNames: { [key: string]: boolean },\n previousShouldInclude: string[] = [],\n parentResponsePath = \"\"\n): FieldsAndNodes {\n interface StackItem {\n selection: SelectionNode;\n parentResponsePath: string;\n previousShouldInclude: string[];\n }\n\n const stack: StackItem[] = [];\n\n // Push in reverse so that stack.pop() will process in document order\n for (let i = selectionSet.selections.length - 1; i >= 0; i--) {\n stack.push({\n selection: selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude\n });\n }\n\n while (stack.length > 0) {\n const { selection, parentResponsePath, previousShouldInclude } =\n stack.pop()!;\n\n switch (selection.kind) {\n case Kind.FIELD: {\n collectFieldsForField({\n compilationContext,\n fields,\n parentResponsePath,\n previousShouldInclude,\n selection\n });\n break;\n }\n\n case Kind.INLINE_FRAGMENT: {\n if (\n !doesFragmentConditionMatch(\n compilationContext,\n selection,\n runtimeType\n )\n ) {\n break;\n }\n\n // current fragment's shouldInclude\n const compiledSkipInclude = compileSkipInclude(\n compilationContext,\n selection\n );\n\n const mergedShouldInclude = joinShouldIncludeCompilations(\n previousShouldInclude,\n [compiledSkipInclude]\n );\n\n // Push in reverse so that stack.pop() will process in document order\n const selectionsLength = selection.selectionSet.selections.length;\n for (let i = selectionsLength - 1; i >= 0; i--) {\n stack.push({\n selection: selection.selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude: mergedShouldInclude\n });\n }\n break;\n }\n\n case Kind.FRAGMENT_SPREAD: {\n const fragName = selection.name.value;\n if (visitedFragmentNames[fragName]) {\n break;\n }\n visitedFragmentNames[fragName] = true;\n const fragment = compilationContext.fragments[fragName];\n if (\n !fragment ||\n !doesFragmentConditionMatch(compilationContext, fragment, runtimeType)\n ) {\n break;\n }\n\n // current fragment's shouldInclude\n const compiledSkipInclude = compileSkipInclude(\n compilationContext,\n selection\n );\n\n const mergedShouldInclude = joinShouldIncludeCompilations(\n previousShouldInclude,\n [compiledSkipInclude]\n );\n\n // Push in reverse so that stack.pop() will process in document order\n const selectionsLength = fragment.selectionSet.selections.length;\n for (let i = selectionsLength - 1; i >= 0; i--) {\n stack.push({\n selection: fragment.selectionSet.selections[i],\n parentResponsePath,\n previousShouldInclude: mergedShouldInclude\n });\n }\n break;\n }\n }\n }\n\n return fields;\n}\n\nfunction collectFieldsForField({\n compilationContext,\n fields,\n parentResponsePath,\n previousShouldInclude,\n selection\n}: {\n compilationContext: CompilationContext;\n fields: FieldsAndNodes;\n parentResponsePath: string;\n previousShouldInclude: string[];\n selection: FieldNode;\n}) {\n const name = getFieldEntryKey(selection);\n if (!fields[name]) {\n fields[name] = [];\n }\n const fieldNode: JitFieldNode = selection;\n\n // the current path of the field\n // This is used to generate per path skip/include code\n // because the same field can be reached from different paths (e.g. fragment reuse)\n const currentPath = joinSkipIncludePath(\n parentResponsePath,\n\n // use alias(instead of selection.name.value) if available as the responsePath used for lookup uses alias\n name\n );\n\n // `should include`s generated for the current fieldNode\n const compiledSkipInclude = compileSkipInclude(compilationContext, selection);\n\n /**\n * Carry over fragment's skip and include code\n *\n * fieldNode.__internalShouldInclude\n * ---------------------------------\n * When the parent field has a skip or include, the current one\n * should be skipped if the parent is skipped in the path.\n *\n * previousShouldInclude\n * ---------------------\n * `should include`s from fragment spread and inline fragments\n *\n * compileSkipInclude(selection)\n * -----------------------------\n * `should include`s generated for the current fieldNode\n */\n if (compilationContext.options.useExperimentalPathBasedSkipInclude) {\n if (!fieldNode.__internalShouldIncludePath)\n fieldNode.__internalShouldIncludePath = {};\n\n fieldNode.__internalShouldIncludePath[currentPath] =\n joinShouldIncludeCompilations(\n fieldNode.__internalShouldIncludePath?.[currentPath] ?? [],\n previousShouldInclude,\n [compiledSkipInclude]\n );\n } else {\n // @deprecated\n fieldNode.__internalShouldInclude = joinShouldIncludeCompilations(\n fieldNode.__internalShouldInclude ?? [],\n previousShouldInclude,\n [compiledSkipInclude]\n );\n }\n /**\n * We augment the entire subtree as the parent object's skip/include\n * directives influence the child even if the child doesn't have\n * skip/include on it's own.\n *\n * Refer the function definition for example.\n */\n augmentFieldNodeTree(compilationContext, fieldNode, currentPath);\n\n fields[name].push(fieldNode);\n}\n\n/**\n * Augment __internalShouldInclude code for all sub-fields in the\n * tree with @param rootfieldNode as the root.\n *\n * This is required to handle cases where there are multiple paths to\n * the same node. And each of those paths contain different skip/include\n * values.\n *\n * For example,\n *\n * ```\n * {\n * foo @skip(if: $c1) {\n * bar @skip(if: $c2)\n * }\n * ... {\n * foo @skip(if: $c3) {\n * bar\n * }\n * }\n * }\n * ```\n *\n * We decide shouldInclude at runtime per fieldNode. When we handle the\n * field `foo`, the logic is straight forward - it requires one of $c1 or $c3\n * to be false.\n *\n * But, when we handle the field `bar`, and we are in the context of the fieldNode,\n * not enough information is available. This is because, if we only included $c2\n * to decide if bar is included, consider the case -\n *\n * $c1: true, $c2: true, $c3: false\n *\n * If we considered only $c2, we would have skipped bar. But the correct implementation\n * is to include bar, because foo($c3) { bar } is not skipped. The entire sub-tree's\n * logic is required to handle bar.\n *\n * So, to handle this case, we augment the tree at each point to consider the\n * skip/include logic from the parent as well.\n *\n * @param compilationContext {CompilationContext} Required for getFragment by\n * name to handle fragment spread operation.\n *\n * @param rootFieldNode {JitFieldNode} The root field to traverse from for\n * adding __internalShouldInclude to all sub field nodes.\n *\n * @param parentResponsePath {string} The response path of the parent field.\n */\nfunction augmentFieldNodeTree(\n compilationContext: CompilationContext,\n rootFieldNode: JitFieldNode,\n parentResponsePath: string\n) {\n for (const selection of rootFieldNode.selectionSet?.selections ?? []) {\n /**\n * Traverse through sub-selection and combine `shouldInclude`s\n * from parent and current ones.\n */\n interface StackItem {\n parentFieldNode: JitFieldNode;\n selection: SelectionNode;\n comesFromFragmentSpread: boolean;\n parentResponsePath: string;\n }\n\n const stack: StackItem[] = [];\n\n stack.push({\n parentFieldNode: rootFieldNode,\n selection,\n comesFromFragmentSpread: false,\n parentResponsePath\n });\n\n while (stack.length > 0) {\n const {\n parentFieldNode,\n selection,\n comesFromFragmentSpread,\n parentResponsePath\n } = stack.pop()!;\n\n switch (selection.kind) {\n case Kind.FIELD: {\n const jitFieldNode: JitFieldNode = selection;\n const currentPath = joinSkipIncludePath(\n parentResponsePath,\n\n // use alias(instead of selection.name.value) if available as the responsePath used for lookup uses alias\n getFieldEntryKey(jitFieldNode)\n );\n\n if (!comesFromFragmentSpread) {\n if (\n compilationContext.options.useExperimentalPathBasedSkipInclude\n ) {\n if (!jitFieldNode.__internalShouldIncludePath)\n jitFieldNode.__internalShouldIncludePath = {};\n\n jitFieldNode.__internalShouldIncludePath[currentPath] =\n joinShouldIncludeCompilations(\n parentFieldNode.__internalShouldIncludePath?.[\n parentResponsePath\n ] ?? [],\n jitFieldNode.__internalShouldIncludePath?.[currentPath] ?? []\n );\n } else {\n // @deprecated\n jitFieldNode.__internalShouldInclude =\n joinShouldIncludeCompilations(\n parentFieldNode.__internalShouldInclude ?? [],\n jitFieldNode.__internalShouldInclude ?? []\n );\n }\n }\n // go further down the query tree\n for (const selection of jitFieldNode.selectionSet?.selections ?? []) {\n stack.push({\n parentFieldNode: jitFieldNode,\n selection,\n comesFromFragmentSpread: false,\n parentResponsePath: currentPath\n });\n }\n break;\n }\n case Kind.INLINE_FRAGMENT: {\n for (const subSelection of selection.selectionSet.selections) {\n stack.push({\n parentFieldNode,\n selection: subSelection,\n comesFromFragmentSpread: true,\n parentResponsePath\n });\n }\n break;\n }\n case Kind.FRAGMENT_SPREAD: {\n const fragment = compilationContext.fragments[selection.name.value];\n for (const subSelection of fragment.selectionSet.selections) {\n stack.push({\n parentFieldNode,\n selection: subSelection,\n comesFromFragmentSpread: true,\n parentResponsePath\n });\n }\n }\n }\n }\n }\n}\n\n/**\n * Joins a list of shouldInclude compiled code into a single logical\n * statement.\n *\n * The operation is `&&` because, it is used to join parent->child\n * relations in the query tree. Note: parent can be either parent field\n * or fragment.\n *\n * For example,\n * {\n * foo @skip(if: $c1) {\n * ... @skip(if: $c2) {\n * bar @skip(if: $c3)\n * }\n * }\n * }\n *\n * Only when a parent is included, the child is included. So, we use `&&`.\n *\n * compilationFor($c1) && compilationFor($c2) && compilationFor($c3)\n *\n * @param compilations\n */\nfunction joinShouldIncludeCompilations(...compilations: string[][]): string[] {\n // remove \"true\" since we are joining with '&&' as `true && X` = `X`\n // This prevents an explosion of `&& true` which could break\n // V8's internal size limit for string.\n //\n // Note: the `true` appears if a field does not have a skip/include directive\n // So, the more nested the query is, the more of unnecessary `&& true`\n // we get.\n //\n // Failing to do this results in [RangeError: invalid array length]\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length\n\n const conditionsSet = new Set<string>();\n for (const conditions of compilations) {\n for (const condition of conditions) {\n if (condition !== \"true\") {\n conditionsSet.add(condition);\n }\n }\n }\n\n return Array.from(conditionsSet);\n}\n\n/**\n * Compiles directives `skip` and `include` and generates the compilation\n * code based on GraphQL specification.\n *\n * @param node {SelectionNode} The selection node (field/fragment/inline-fragment)\n * for which we generate the compiled skipInclude.\n */\nfunction compileSkipInclude(\n compilationContext: CompilationContext,\n node: SelectionNode\n): string {\n // minor optimization to avoid compilation if there are no directives\n if (node.directives == null || node.directives.length < 1) {\n return \"true\";\n }\n\n const { skipValue, includeValue } = compileSkipIncludeDirectiveValues(\n compilationContext,\n node\n );\n\n /**\n * Spec: https://spec.graphql.org/June2018/#sec--include\n *\n * Neither @skip nor @include has precedence over the other.\n * In the case that both the @skip and @include directives\n * are provided in on the same the field or fragment, it must\n * be queried only if the @skip condition is false and the\n * @include condition is true. Stated conversely, the field\n * or fragment must not be queried if either the @skip\n * condition is true or the @include condition is false.\n */\n if (skipValue != null && includeValue != null) {\n return `${skipValue} === false && ${includeValue} === true`;\n } else if (skipValue != null) {\n return `(${skipValue} === false)`;\n } else if (includeValue != null) {\n return `(${includeValue} === true)`;\n } else {\n return `true`;\n }\n}\n\n/**\n * Compile skip or include directive values into JIT compatible\n * runtime code.\n *\n * @param node {SelectionNode}\n */\nfunction compileSkipIncludeDirectiveValues(\n compilationContext: CompilationContext,\n node: SelectionNode\n) {\n const skipDirective = node.directives?.find(\n (it) => it.name.value === GraphQLSkipDirective.name\n );\n const includeDirective = node.directives?.find(\n (it) => it.name.value === GraphQLIncludeDirective.name\n );\n\n const skipValue = skipDirective\n ? compileSkipIncludeDirective(compilationContext, skipDirective)\n : // The null here indicates the absense of the directive\n // which is later used to determine if both skip and include\n // are present\n null;\n const includeValue = includeDirective\n ? compileSkipIncludeDirective(compilationContext, includeDirective)\n : // The null here indicates the absense of the directive\n // which is later used to determine if both skip and include\n // are present\n null;\n\n return { skipValue, includeValue };\n}\n\n/**\n * Compile the skip/include directive node. Resolve variables to it's\n * path from context, resolve scalars to their respective values.\n *\n * @param directive {DirectiveNode}\n */\nfunction compileSkipIncludeDirective(\n compilationContext: CompilationContext,\n directive: DirectiveNode\n) {\n const ifNode = directive.arguments?.find((it) => it.name.value === \"if\");\n if (ifNode == null) {\n throw new GraphQLError(\n `Directive '${directive.name.value}' is missing required arguments: 'if'`,\n getGraphQLErrorOptions([directive])\n );\n }\n\n switch (ifNode.value.kind) {\n case Kind.VARIABLE:\n validateSkipIncludeVariableType(compilationContext, ifNode.value);\n return `${GLOBAL_VARIABLES_NAME}[\"${ifNode.value.name.value}\"]`;\n case Kind.BOOLEAN:\n return `${ifNode.value.value.toString()}`;\n default:\n throw new GraphQLError(\n `Argument 'if' on Directive '${\n directive.name.value\n }' has an invalid value (${valueFromASTUntyped(\n ifNode.value\n )}). Expected type 'Boolean!'`,\n getGraphQLErrorOptions([ifNode])\n );\n }\n}\n\n/**\n * Validate the skip and include directive's argument values at compile time.\n *\n * This validation step is required as these directives are part of an\n * implicit schema in GraphQL.\n *\n * @param compilationContext {CompilationContext}\n * @param variable {VariableNode} the variable used in 'if' argument of the skip/include directive\n */\nfunction validateSkipIncludeVariableType(\n compilationContext: CompilationContext,\n variable: VariableNode\n) {\n const variableDefinition =\n compilationContext.operation.variableDefinitions?.find(\n (it) => it.variable.name.value === variable.name.value\n );\n if (variableDefinition == null) {\n throw new GraphQLError(\n `Variable '${variable.name.value}' is not defined`,\n getGraphQLErrorOptions([variable])\n );\n }\n\n // Part of Spec text: https://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed\n if (\n !(\n // The variable defintion is a Non-nullable Boolean type\n (\n (variableDefinition.type.kind === Kind.NON_NULL_TYPE &&\n variableDefinition.type.type.kind === Kind.NAMED_TYPE &&\n variableDefinition.type.type.name.value === \"Boolean\") ||\n // or the variable definition is a nullable Boolean type with a default value\n (variableDefinition.type.kind === Kind.NAMED_TYPE &&\n variableDefinition.type.name.value === \"Boolean\" &&\n variableDefinition.defaultValue != null)\n )\n )\n ) {\n throw new GraphQLError(\n `Variable '${variable.name.value}' of type '${typeNodeToString(\n variableDefinition.type\n )}' used in position expecting type 'Boolean!'`,\n getGraphQLErrorOptions([variableDefinition])\n );\n }\n}\n\n/**\n * Print the string representation of the TypeNode for error messages\n *\n * @param type {TypeNode} type node to be converted to string representation\n */\nfunction typeNodeToString(type: TypeNode): string {\n switch (type.kind) {\n case Kind.NAMED_TYPE:\n return type.name.value;\n case Kind.NON_NULL_TYPE:\n return `${typeNodeToString(type.type)}!`;\n case Kind.LIST_TYPE:\n return `[${typeNodeToString(type.type)}]`;\n }\n}\n\n/**\n * Determines if a fragment is applicable to the given type.\n */\nfunction doesFragmentConditionMatch(\n compilationContext: CompilationContext,\n fragment: FragmentDefinitionNode | InlineFragmentNode,\n type: GraphQLObjectType\n): boolean {\n const typeConditionNode = fragment.typeCondition;\n if (!typeConditionNode) {\n return true;\n }\n const conditionalType = typeFromAST(\n compilationContext.schema,\n typeConditionNode\n );\n if (conditionalType === type) {\n return true;\n }\n if (!conditionalType) {\n return false;\n }\n if (isAbstractType(conditionalType)) {\n return compilationContext.schema.isSubType(conditionalType, type);\n }\n return false;\n}\n\n/**\n * Implements the logic to compute the key of a given field's entry\n */\nfunction getFieldEntryKey(node: FieldNode): string {\n return node.alias ? node.alias.value : node.name.value;\n}\n\nexport { resolveFieldDef };\n\nexport function collectSubfields(\n compilationContext: CompilationContext,\n returnType: GraphQLObjectType,\n fieldNodes: FieldNode[],\n parentResponsePath?: ObjectPath\n): { [key: string]: FieldNode[] } {\n let subFieldNodes = Object.create(null);\n const visitedFragmentNames = Object.create(null);\n for (const fieldNode of fieldNodes) {\n const selectionSet = fieldNode.selectionSet;\n if (selectionSet) {\n subFieldNodes = collectFields(\n compilationContext,\n returnType,\n selectionSet,\n subFieldNodes,\n visitedFragmentNames,\n parentResponsePath\n );\n }\n }\n return subFieldNodes;\n}\n\n// response path is used for identifying\n// the info resolver function as well as the path in errros,\n// the meta type is used for elements that are only to be used for\n// the function name\ntype ResponsePathType = \"variable\" | \"literal\" | \"meta\";\n\nexport interface ObjectPath {\n prev: ObjectPath | undefined;\n key: string;\n type: ResponsePathType;\n}\n\ninterface MissingVariablePath {\n valueNode: VariableNode;\n path?: ObjectPath;\n argument?: { definition: GraphQLArgument; node: ArgumentNode };\n}\n\nexport interface Arguments {\n values: { [argument: string]: any };\n missing: MissingVariablePath[];\n}\n\n/**\n * Prepares an object map of argument values given a list of argument\n * definitions and list of argument AST nodes.\n *\n * Note: The returned value is a plain Object with a prototype, since it is\n * exposed to user code. Care should be taken to not pull values from the\n * Object prototype.\n */\nexport function getArgumentDefs(\n def: GraphQLField<any, any> | GraphQLDirective,\n node: FieldNode | DirectiveNode\n): Arguments {\n const values: { [key: string]: any } = {};\n const missing: MissingVariablePath[] = [];\n const argDefs = def.args;\n const argNodes = node.arguments || [];\n const argNodeMap = keyMap(argNodes, (arg) => arg.name.value);\n for (const argDef of argDefs) {\n const name = argDef.name;\n if (hasDefaultValue(argDef)) {\n // handle v16 defaultValue, and v17 default.value/default.literal\n values[name] = getDefaultValue(argDef);\n }\n const argType = argDef.type;\n const argumentNode = argNodeMap[name];\n let hasVariables = false;\n if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {\n hasVariables = true;\n missing.push({\n valueNode: argumentNode.value,\n path: addPath(undefined, name, \"literal\"),\n argument: { definition: argDef, node: argumentNode }\n });\n } else if (argumentNode) {\n const coercedValue = valueFromAST(argumentNode.value, argType);\n if (coercedValue === undefined) {\n // Note: ValuesOfCorrectType validation should catch this before\n // execution. This is a runtime check to ensure execution does not\n // continue with an invalid argument value.\n throw new GraphQLError(\n `Argument \"${name}\" of type \"${argType}\" has invalid value ${print(\n argumentNode.value\n )}.`,\n getGraphQLErrorOptions(argumentNode.value)\n );\n }\n\n if (isASTValueWithVariables(coercedValue)) {\n missing.push(\n ...coercedValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, name, \"literal\")\n }))\n );\n }\n values[name] = coercedValue.value;\n }\n if (isNonNullType(argType) && values[name] === undefined && !hasVariables) {\n // If no value or a nullish value was provided to a variable with a\n // non-null type (required), produce an error.\n throw new GraphQLError(\n argumentNode\n ? `Argument \"${name}\" of non-null type ` +\n `\"${argType}\" must not be null.`\n : `Argument \"${name}\" of required type ` +\n `\"${argType}\" was not provided.`,\n getGraphQLErrorOptions(node)\n );\n }\n }\n return { values, missing };\n}\n\ninterface ASTValueWithVariables {\n value: object | string | boolean | symbol | number | null | any[];\n variables: MissingVariablePath[];\n}\n\nfunction isASTValueWithVariables(x: any): x is ASTValueWithVariables {\n return !!x.variables;\n}\n\ninterface ASTValue {\n value: object | string | boolean | symbol | number | null | any[];\n}\n\nexport function valueFromAST(\n valueNode: ValueNode,\n type: GraphQLInputType\n): undefined | ASTValue | ASTValueWithVariables {\n if (isNonNullType(type)) {\n if (valueNode.kind === Kind.NULL) {\n return; // Invalid: intentionally return no value.\n }\n return valueFromAST(valueNode, type.ofType);\n }\n\n if (valueNode.kind === Kind.NULL) {\n // This is explicitly returning the value null.\n return {\n value: null\n };\n }\n\n if (valueNode.kind === Kind.VARIABLE) {\n return { value: null, variables: [{ valueNode, path: undefined }] };\n }\n\n if (isListType(type)) {\n const itemType = type.ofType;\n if (valueNode.kind === Kind.LIST) {\n const coercedValues = [];\n const variables: MissingVariablePath[] = [];\n const itemNodes = valueNode.values;\n for (let i = 0; i < itemNodes.length; i++) {\n const itemNode = itemNodes[i];\n if (itemNode.kind === Kind.VARIABLE) {\n coercedValues.push(null);\n variables.push({\n valueNode: itemNode,\n path: addPath(undefined, i.toString(), \"literal\")\n });\n } else {\n const itemValue = valueFromAST(itemNode, itemType);\n if (!itemValue) {\n return; // Invalid: intentionally return no value.\n }\n coercedValues.push(itemValue.value);\n if (isASTValueWithVariables(itemValue)) {\n variables.push(\n ...itemValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, i.toString(), \"literal\")\n }))\n );\n }\n }\n }\n return { value: coercedValues, variables };\n }\n // Single item which will be coerced to a list\n const coercedValue = valueFromAST(valueNode, itemType);\n if (coercedValue === undefined) {\n return; // Invalid: intentionally return no value.\n }\n if (isASTValueWithVariables(coercedValue)) {\n return {\n value: [coercedValue.value],\n variables: coercedValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, \"0\", \"literal\")\n }))\n };\n }\n return { value: [coercedValue.value] };\n }\n\n if (isInputObjectType(type)) {\n if (valueNode.kind !== Kind.OBJECT) {\n return; // Invalid: intentionally return no value.\n }\n const coercedObj = Object.create(null);\n const variables: MissingVariablePath[] = [];\n const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value);\n const fields = Object.values(type.getFields());\n for (const field of fields) {\n if (hasDefaultValue(field)) {\n coercedObj[field.name] = getDefaultValue(field);\n }\n const fieldNode = fieldNodes[field.name];\n if (!fieldNode) {\n continue;\n }\n const fieldValue = valueFromAST(fieldNode.value, field.type);\n if (!fieldValue) {\n return; // Invalid: intentionally return no value.\n }\n if (isASTValueWithVariables(fieldValue)) {\n variables.push(\n ...fieldValue.variables.map(({ valueNode, path }) => ({\n valueNode,\n path: addPath(path, field.name, \"literal\")\n }))\n );\n }\n coercedObj[field.name] = fieldValue.value;\n }\n return { value: coercedObj, variables };\n }\n\n if (isEnumType(type)) {\n if (valueNode.kind !== Kind.ENUM) {\n return; // Invalid: intentionally return no value.\n }\n const enumValue = type.getValue(valueNode.value);\n if (!enumValue) {\n return; // Invalid: intentionally return no value.\n }\n return { value: enumValue.value };\n }\n\n if (isScalarType(type)) {\n // Scalars fulfill parsing a literal value via coerceInputLiteral().\n // Invalid values represent a failure to parse correctly, in which case\n // no value is returned.\n let result: any;\n try {\n // By this point, we've filtered out VARIABLE nodes, so valueNode is a ConstValueNode\n result = coerceInputLiteral(type, valueNode as ConstValueNode);\n } catch (error) {\n return; // Invalid: intentionally return no value.\n }\n if (isInvalid(result)) {\n return; // Invalid: intentionally return no value.\n }\n return { value: result };\n }\n\n // Not reachable. All possible input types have been considered.\n /* istanbul ignore next */\n throw new Error(`Unexpected input type: \"${inspect(type)}\".`);\n}\n\n/**\n * Creates a keyed JS object from an array, given a function to produce the keys\n * for each value in the array.\n *\n * This provides a convenient lookup for the array items if the key function\n * produces unique results.\n *\n * const phoneBook = [\n * { name: 'Jon', num: '555-1234' },\n * { name: 'Jenny', num: '867-5309' }\n * ]\n *\n * // { Jon: { name: 'Jon', num: '555-1234' },\n * // Jenny: { name: 'Jenny', num: '867-5309' } }\n * const entriesByName = keyMap(\n * phoneBook,\n * entry => entry.name\n * )\n *\n * // { name: 'Jenny', num: '857-6309' }\n * const jennyEntry = entriesByName['Jenny']\n *\n */\nfunction keyMap<T>(\n list: ReadonlyArray<T>,\n keyFn: (item: T) => string\n): { [key: string]: T } {\n return list.reduce(\n // eslint-disable-next-line no-sequences\n (map, item) => ((map[keyFn(item)] = item), map),\n Object.create(null)\n );\n}\n\nexport function computeLocations(nodes: ASTNode[]): SourceLocation[] {\n return nodes.reduce((list, node) => {\n if (node.loc) {\n list.push(getLocation(node.loc));\n }\n return list;\n }, [] as SourceLocation[]);\n}\n\n/**\n * This is an alternate faster implementation of getLocation in graphql-js\n *\n * Optimization:\n * In graphql-js, getLocation is implemented as finding line and column\n * from a given position in the source. Since the use-case in GraphQL-JIT\n * is to find the location of a node, we can directly use the line and\n * column from the startToken of the node's location.\n *\n * @param loc the Node's location\n * @returns the SourceLocation for the position\n */\nfunction getLocation(loc: Location): SourceLocation {\n // If the location already contains line and column, return it directly\n return {\n line: loc.startToken.line,\n column: loc.startToken.column\n };\n}\n\nexport function addPath(\n responsePath: ObjectPath | undefined,\n key: string,\n type: ResponsePathType = \"literal\"\n): ObjectPath {\n return { prev: responsePath, key, type };\n}\n\nexport function flattenPath(\n path: ObjectPath\n): Array<{ key: string; type: ResponsePathType }> {\n const flattened = [];\n let curr: ObjectPath | undefined = path;\n while (curr) {\n flattened.push({ key: curr.key, type: curr.type });\n curr = curr.prev;\n }\n return flattened;\n}\n\n/**\n * Serialize a path for use in the skip/include directives.\n *\n * @param path The path to serialize\n * @returns The path serialized as a string, with the root path first.\n */\nexport function serializeObjectPathForSkipInclude(\n path: ObjectPath | undefined\n) {\n let serialized = \"\";\n let curr = path;\n while (curr) {\n if (curr.type === \"literal\") {\n serialized = joinSkipIncludePath(curr.key, serialized);\n }\n curr = curr.prev;\n }\n return serialized;\n}\n\n/**\n * join two path segments to a dot notation, handling empty strings\n *\n * @param a path segment\n * @param b path segment\n * @returns combined path in dot notation\n */\nexport function joinSkipIncludePath(a: string, b: string) {\n if (a) {\n if (b) {\n return `${a}.${b}`;\n }\n return a;\n }\n return b;\n}\n\nfunction isInvalid(value: any): boolean {\n // eslint-disable-next-line no-self-compare\n return value === undefined || value !== value;\n}\n"]}
|
package/dist/esm/compat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLError, type FieldNode, type GraphQLField, type ASTNode, type OperationDefinitionNode, type GraphQLObjectType, type GraphQLFormattedError, type ConstValueNode, GraphQLScalarType } from "graphql";
|
|
1
|
+
import { GraphQLSchema, GraphQLError, type FieldNode, type GraphQLField, type ASTNode, type OperationDefinitionNode, type GraphQLObjectType, type GraphQLFormattedError, type ConstValueNode, type GraphQLInputType, type GraphQLEnumType, GraphQLScalarType } from "graphql";
|
|
2
2
|
import { type Maybe } from "./types.js";
|
|
3
3
|
import { type CompilationContext } from "./execution.js";
|
|
4
4
|
/**
|
|
@@ -34,31 +34,37 @@ export declare function getGraphQLErrorOptions(nodes: Maybe<ReadonlyArray<ASTNod
|
|
|
34
34
|
* the sub-selection-set for objects.
|
|
35
35
|
*/
|
|
36
36
|
export declare function resolveFieldDef(compilationContext: CompilationContext, parentType: GraphQLObjectType, fieldNodes: FieldNode[]): Maybe<GraphQLField<any, any>>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* Programmatic schemas still use `arg.defaultValue`.
|
|
40
|
-
* This helper normalizes both to a single value.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getDefaultValue(argOrField: {
|
|
37
|
+
interface DefaultCarrier {
|
|
38
|
+
type: GraphQLInputType;
|
|
43
39
|
defaultValue?: unknown;
|
|
44
40
|
default?: {
|
|
45
41
|
value?: unknown;
|
|
46
|
-
literal?:
|
|
42
|
+
literal?: ConstValueNode;
|
|
47
43
|
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* v17 SDL-built schemas store defaults as `default = { literal }` (an AST
|
|
47
|
+
* node that must be coerced against the type); programmatic v17 schemas use
|
|
48
|
+
* `default = { value }`, and v16 and lower use `defaultValue`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDefaultValue(argOrField: DefaultCarrier): unknown;
|
|
51
|
+
export declare function hasDefaultValue(argOrField: DefaultCarrier): boolean;
|
|
56
52
|
/**
|
|
57
53
|
* v17 deprecates parseLiteral in favor of coerceInputLiteral for custom scalars
|
|
58
54
|
* However, custom scalars may still only define parseLiteral, so we check
|
|
59
55
|
* for the method's existence rather than just the version.
|
|
60
56
|
*/
|
|
61
57
|
export declare function coerceInputLiteral(type: GraphQLScalarType<unknown, unknown>, valueNode: ConstValueNode): any;
|
|
58
|
+
/**
|
|
59
|
+
* v17 prefers `coerceOutputValue` over the legacy `serialize`, and the two
|
|
60
|
+
* can differ when both are defined. Custom scalars may define only one.
|
|
61
|
+
*/
|
|
62
|
+
export declare function coerceOutputValue(type: GraphQLScalarType<unknown, unknown> | GraphQLEnumType, value: unknown): unknown;
|
|
63
|
+
/**
|
|
64
|
+
* v17 prefers `coerceInputValue` over the legacy `parseValue`, and the two
|
|
65
|
+
* can differ when both are defined. Custom scalars may define only one.
|
|
66
|
+
*/
|
|
67
|
+
export declare function coerceInputValue(type: GraphQLScalarType<unknown, unknown> | GraphQLEnumType, value: unknown): unknown;
|
|
62
68
|
/**
|
|
63
69
|
* V17 removes execution context
|
|
64
70
|
* This is a minimal interface to support the execution context for v16 and v17+
|
|
@@ -68,3 +74,4 @@ export interface ExecutionContext {
|
|
|
68
74
|
completed: boolean;
|
|
69
75
|
errorPropagation: boolean;
|
|
70
76
|
}
|
|
77
|
+
export {};
|
package/dist/esm/compat.js
CHANGED
|
@@ -72,14 +72,17 @@ export function resolveFieldDef(compilationContext, parentType, fieldNodes) {
|
|
|
72
72
|
return compilationContext.schema.getField(parentType, fieldName);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* v17
|
|
76
|
-
*
|
|
77
|
-
*
|
|
75
|
+
* v17 SDL-built schemas store defaults as `default = { literal }` (an AST
|
|
76
|
+
* node that must be coerced against the type); programmatic v17 schemas use
|
|
77
|
+
* `default = { value }`, and v16 and lower use `defaultValue`.
|
|
78
78
|
*/
|
|
79
79
|
export function getDefaultValue(argOrField) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const def = argOrField.default;
|
|
81
|
+
if (def !== undefined) {
|
|
82
|
+
if (def.literal !== undefined) {
|
|
83
|
+
return graphql.coerceInputLiteral(def.literal, argOrField.type);
|
|
84
|
+
}
|
|
85
|
+
return def.value;
|
|
83
86
|
}
|
|
84
87
|
return argOrField.defaultValue;
|
|
85
88
|
}
|
|
@@ -99,4 +102,20 @@ export function coerceInputLiteral(type, valueNode) {
|
|
|
99
102
|
}
|
|
100
103
|
return type.parseLiteral(valueNode, {});
|
|
101
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* v17 prefers `coerceOutputValue` over the legacy `serialize`, and the two
|
|
107
|
+
* can differ when both are defined. Custom scalars may define only one.
|
|
108
|
+
*/
|
|
109
|
+
export function coerceOutputValue(type, value) {
|
|
110
|
+
const t = type;
|
|
111
|
+
return t.coerceOutputValue ? t.coerceOutputValue(value) : t.serialize(value);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* v17 prefers `coerceInputValue` over the legacy `parseValue`, and the two
|
|
115
|
+
* can differ when both are defined. Custom scalars may define only one.
|
|
116
|
+
*/
|
|
117
|
+
export function coerceInputValue(type, value) {
|
|
118
|
+
const t = type;
|
|
119
|
+
return t.coerceInputValue ? t.coerceInputValue(value) : t.parseValue(value);
|
|
120
|
+
}
|
|
102
121
|
//# sourceMappingURL=compat.js.map
|
package/dist/esm/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../../src/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAGL,WAAW,
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../../src/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAGL,WAAW,EAWX,kBAAkB,EAClB,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,IAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,OAAQ,IAAY,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAA2D,EAC3D,KAAc;IAEd,MAAM,CAAC,GAAG,IAAW,CAAC;IACtB,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAA2D,EAC3D,KAAc;IAEd,MAAM,CAAC,GAAG,IAAW,CAAC;IACtB,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import * as graphql from \"graphql\";\nimport {\n GraphQLSchema,\n GraphQLError,\n versionInfo,\n type FieldNode,\n type GraphQLField,\n type ASTNode,\n type OperationDefinitionNode,\n type GraphQLObjectType,\n type GraphQLFormattedError,\n type ConstValueNode,\n type GraphQLInputType,\n type GraphQLEnumType,\n GraphQLScalarType,\n SchemaMetaFieldDef,\n TypeMetaFieldDef,\n TypeNameMetaFieldDef\n} from \"graphql\";\nimport { type Maybe } from \"./types.js\";\nimport { type CompilationContext } from \"./execution.js\";\n\n/**\n * A helper file to support backward compatibility for different versions of graphql-js.\n */\n\n/**\n * v15 does not have schema.getRootType\n * v16 has both\n * v17 will not have getOperationRootType\n *\n * To support all these 3 versions of graphql-js, at least for migration, this helper\n * would be useful.\n *\n * This can be removed once we drop support for v15.\n *\n * GraphQL v17 would remove getOperationRootType.\n */\nexport function getOperationRootType(\n schema: GraphQLSchema,\n operation: OperationDefinitionNode\n): GraphQLObjectType {\n if (versionInfo.major < 16) {\n return (graphql as any).getOperationRootType(schema, operation);\n }\n\n const type = (schema as any).getRootType(operation.operation);\n\n if (!type) {\n throw new Error(`No root type for operation ${operation.operation}`);\n }\n\n return type;\n}\n\n/**\n * v16 and lower versions don't have .toJSON method on GraphQLError\n * v17 does have .toJSON and doesn't have \"formatError\" export anymore\n */\nexport function formatError(error: GraphQLError): GraphQLFormattedError {\n if (versionInfo.major < 16) {\n return (graphql as any).formatError(error);\n }\n\n return (error as any).toJSON();\n}\n\n/**\n * v17 dropped support for positional arguments in GraphQLError constructor\n * https://github.com/graphql/graphql-js/pull/3577\n */\nexport function getGraphQLErrorOptions(\n nodes: Maybe<ReadonlyArray<ASTNode> | ASTNode>\n): ConstructorParameters<typeof GraphQLError>[1] {\n if (versionInfo.major < 16) {\n return nodes as any;\n }\n\n return { nodes } as any;\n}\n\n/**\n * Resolves the field on the given source object. In particular, this\n * figures out the value that the field returns by calling its resolve function,\n * then calls completeValue to complete promises, serialize scalars, or execute\n * the sub-selection-set for objects.\n */\nexport function resolveFieldDef(\n compilationContext: CompilationContext,\n parentType: GraphQLObjectType,\n fieldNodes: FieldNode[]\n): Maybe<GraphQLField<any, any>> {\n const fieldNode = fieldNodes[0];\n const fieldName = fieldNode.name.value;\n\n if (versionInfo.major < 17) {\n const schema = compilationContext.schema;\n if (\n fieldName === SchemaMetaFieldDef.name &&\n schema.getQueryType() === parentType\n ) {\n return SchemaMetaFieldDef;\n }\n if (\n fieldName === TypeMetaFieldDef.name &&\n schema.getQueryType() === parentType\n ) {\n return TypeMetaFieldDef;\n }\n if (fieldName === TypeNameMetaFieldDef.name) {\n return TypeNameMetaFieldDef;\n }\n return parentType.getFields()[fieldName];\n }\n\n return (compilationContext.schema as any).getField(parentType, fieldName);\n}\n\ninterface DefaultCarrier {\n type: GraphQLInputType;\n defaultValue?: unknown;\n default?: { value?: unknown; literal?: ConstValueNode };\n}\n\n/**\n * v17 SDL-built schemas store defaults as `default = { literal }` (an AST\n * node that must be coerced against the type); programmatic v17 schemas use\n * `default = { value }`, and v16 and lower use `defaultValue`.\n */\nexport function getDefaultValue(argOrField: DefaultCarrier): unknown {\n const def = argOrField.default;\n if (def !== undefined) {\n if (def.literal !== undefined) {\n return (graphql as any).coerceInputLiteral(def.literal, argOrField.type);\n }\n return def.value;\n }\n return argOrField.defaultValue;\n}\n\nexport function hasDefaultValue(argOrField: DefaultCarrier): boolean {\n return (\n argOrField.default !== undefined || argOrField.defaultValue !== undefined\n );\n}\n\n/**\n * v17 deprecates parseLiteral in favor of coerceInputLiteral for custom scalars\n * However, custom scalars may still only define parseLiteral, so we check\n * for the method's existence rather than just the version.\n */\nexport function coerceInputLiteral(\n type: GraphQLScalarType<unknown, unknown>,\n valueNode: ConstValueNode\n): any {\n // Use coerceInputLiteral if available (built-in scalars in v17+)\n // Otherwise fall back to parseLiteral (custom scalars, or v16)\n if ((type as any).coerceInputLiteral) {\n return (type as any).coerceInputLiteral(valueNode);\n }\n\n return (type as any).parseLiteral(valueNode, {});\n}\n\n/**\n * v17 prefers `coerceOutputValue` over the legacy `serialize`, and the two\n * can differ when both are defined. Custom scalars may define only one.\n */\nexport function coerceOutputValue(\n type: GraphQLScalarType<unknown, unknown> | GraphQLEnumType,\n value: unknown\n): unknown {\n const t = type as any;\n return t.coerceOutputValue ? t.coerceOutputValue(value) : t.serialize(value);\n}\n\n/**\n * v17 prefers `coerceInputValue` over the legacy `parseValue`, and the two\n * can differ when both are defined. Custom scalars may define only one.\n */\nexport function coerceInputValue(\n type: GraphQLScalarType<unknown, unknown> | GraphQLEnumType,\n value: unknown\n): unknown {\n const t = type as any;\n return t.coerceInputValue ? t.coerceInputValue(value) : t.parseValue(value);\n}\n\n/**\n * V17 removes execution context\n * This is a minimal interface to support the execution context for v16 and v17+\n */\nexport interface ExecutionContext {\n errors: Array<GraphQLError> | undefined;\n completed: boolean;\n errorPropagation: boolean;\n}\n"]}
|
package/dist/esm/execution.d.ts
CHANGED
|
@@ -63,6 +63,9 @@ export interface ExecutionContext {
|
|
|
63
63
|
resolveInfos: {
|
|
64
64
|
[key: string]: any;
|
|
65
65
|
};
|
|
66
|
+
literals: {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
};
|
|
66
69
|
}
|
|
67
70
|
interface DeferredField {
|
|
68
71
|
name: string;
|
|
@@ -102,6 +105,9 @@ export interface CompilationContext extends GraphQLContext {
|
|
|
102
105
|
resolveInfos: {
|
|
103
106
|
[key: string]: any;
|
|
104
107
|
};
|
|
108
|
+
literals: {
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
};
|
|
105
111
|
deferred: DeferredField[];
|
|
106
112
|
options: CompilerOptions;
|
|
107
113
|
depth: number;
|