@graphitation/supermassive
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -45,48 +46,53 @@ var __defProps = Object.defineProperties; | ||
const typeInfo = new import_graphql.TypeInfo(schema); | ||
return (0, import_graphql.visit)(document, (0, import_graphql.visitWithTypeInfo)(typeInfo, { | ||
Argument: { | ||
leave(node) { | ||
const argument = typeInfo.getArgument(); | ||
if (argument) { | ||
const typeNode = generateTypeNode(argument.type); | ||
const newNode = __spreadProps(__spreadValues({}, node), { | ||
__type: typeNode, | ||
__defaultValue: argument.defaultValue ? (0, import_graphql.parseValue)(JSON.stringify(argument.defaultValue)) : void 0 | ||
}); | ||
return newNode; | ||
return (0, import_graphql.visit)( | ||
document, | ||
(0, import_graphql.visitWithTypeInfo)(typeInfo, { | ||
Argument: { | ||
leave(node) { | ||
const argument = typeInfo.getArgument(); | ||
if (argument) { | ||
const typeNode = generateTypeNode(argument.type); | ||
const newNode = __spreadProps(__spreadValues({}, node), { | ||
__type: typeNode, | ||
__defaultValue: argument.defaultValue ? (0, import_graphql.parseValue)(JSON.stringify(argument.defaultValue)) : void 0 | ||
}); | ||
return newNode; | ||
} | ||
} | ||
} | ||
}, | ||
Field: { | ||
leave(node, _key, _parent, _path, ancestors) { | ||
const type = typeInfo.getType(); | ||
if (type) { | ||
const typeNode = generateTypeNode(type); | ||
const newNode = __spreadProps(__spreadValues({}, node), { | ||
__type: typeNode | ||
}, | ||
Field: { | ||
leave(node, _key, _parent, _path, ancestors) { | ||
const type = typeInfo.getType(); | ||
if (type) { | ||
const typeNode = generateTypeNode(type); | ||
const newNode = __spreadProps(__spreadValues({}, node), { | ||
__type: typeNode | ||
}); | ||
return newNode; | ||
} | ||
const path = []; | ||
ancestors.forEach((ancestorOrArray) => { | ||
let ancestor; | ||
if (!Array.isArray(ancestorOrArray)) { | ||
ancestor = ancestorOrArray; | ||
if (ancestor && ancestor.kind === import_graphql.Kind.FIELD) { | ||
path.push(ancestor.name.value); | ||
} else if (ancestor && ancestor.kind === import_graphql.Kind.OPERATION_DEFINITION) { | ||
let name; | ||
if (ancestor.name) { | ||
name = `${ancestor.operation} ${ancestor.name.value}`; | ||
} else { | ||
name = ancestor.operation; | ||
} | ||
path.push(name); | ||
} | ||
} | ||
}); | ||
return newNode; | ||
throw new Error( | ||
`Cannot find type for field: ${path.join(".")}.${node.name.value}` | ||
); | ||
} | ||
const path = []; | ||
ancestors.forEach((ancestorOrArray) => { | ||
let ancestor; | ||
if (!Array.isArray(ancestorOrArray)) { | ||
ancestor = ancestorOrArray; | ||
if (ancestor && ancestor.kind === import_graphql.Kind.FIELD) { | ||
path.push(ancestor.name.value); | ||
} else if (ancestor && ancestor.kind === import_graphql.Kind.OPERATION_DEFINITION) { | ||
let name; | ||
if (ancestor.name) { | ||
name = `${ancestor.operation} ${ancestor.name.value}`; | ||
} else { | ||
name = ancestor.operation; | ||
} | ||
path.push(name); | ||
} | ||
} | ||
}); | ||
throw new Error(`Cannot find type for field: ${path.join(".")}.${node.name.value}`); | ||
} | ||
} | ||
})); | ||
}) | ||
); | ||
} | ||
@@ -93,0 +99,0 @@ function generateTypeNode(type) { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
@@ -15,3 +16,10 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __async = (__this, __arguments, generator) => { | ||
@@ -49,5 +57,8 @@ return new Promise((resolve, reject) => { | ||
var import_values = require("../values"); | ||
const query = import_fs.default.readFileSync(import_path.default.join(__dirname, "./fixtures/query1.graphql"), { | ||
encoding: "utf-8" | ||
}); | ||
const query = import_fs.default.readFileSync( | ||
import_path.default.join(__dirname, "./fixtures/query1.graphql"), | ||
{ | ||
encoding: "utf-8" | ||
} | ||
); | ||
const parsedQuery = (0, import_graphql.parse)(query); | ||
@@ -54,0 +65,0 @@ const compiledQuery = (0, import_graphql_jit.compileQuery)(import_swapi_schema.default, parsedQuery); |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
@@ -19,3 +20,10 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -33,5 +41,7 @@ var swapi_schema_exports = {}; | ||
var import_resolvers = __toESM(require("./resolvers")); | ||
const typeDefs = (0, import_graphql.parse)((0, import_fs.readFileSync)((0, import_path.join)(__dirname, "./schema.graphql"), { | ||
encoding: "utf-8" | ||
})); | ||
const typeDefs = (0, import_graphql.parse)( | ||
(0, import_fs.readFileSync)((0, import_path.join)(__dirname, "./schema.graphql"), { | ||
encoding: "utf-8" | ||
}) | ||
); | ||
var swapi_schema_default = (0, import_schema.makeExecutableSchema)({ | ||
@@ -38,0 +48,0 @@ typeDefs, |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
@@ -19,3 +20,10 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -22,0 +30,0 @@ var models_exports = {}; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -155,9 +156,23 @@ var __defProps = Object.defineProperties; | ||
const result = [ | ||
...searchFilmsByTitle(parent, { search }, { models }, info).map((r) => (r.__typename = "Film") && r), | ||
...searchPeopleByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Person") && r), | ||
...searchPlanetsByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Planet") && r), | ||
...searchSpeciesByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Species") && r), | ||
...searchStarshipsByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Starship") && r), | ||
...searchTransportsByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Transport") && r), | ||
...searchVehiclesByName(parent, { search }, { models }, info).map((r) => (r.__typename = "Vehicle") && r) | ||
...searchFilmsByTitle(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Film") && r | ||
), | ||
...searchPeopleByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Person") && r | ||
), | ||
...searchPlanetsByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Planet") && r | ||
), | ||
...searchSpeciesByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Species") && r | ||
), | ||
...searchStarshipsByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Starship") && r | ||
), | ||
...searchTransportsByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Transport") && r | ||
), | ||
...searchVehiclesByName(parent, { search }, { models }, info).map( | ||
(r) => (r.__typename = "Vehicle") && r | ||
) | ||
]; | ||
@@ -164,0 +179,0 @@ return result; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -48,3 +49,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
} | ||
collectFields(resolvers, fragments, variableValues, runtimeTypeName, selection.selectionSet, fields, visitedFragmentNames); | ||
collectFields( | ||
resolvers, | ||
fragments, | ||
variableValues, | ||
runtimeTypeName, | ||
selection.selectionSet, | ||
fields, | ||
visitedFragmentNames | ||
); | ||
break; | ||
@@ -62,3 +71,11 @@ } | ||
} | ||
collectFields(resolvers, fragments, variableValues, runtimeTypeName, fragment.selectionSet, fields, visitedFragmentNames); | ||
collectFields( | ||
resolvers, | ||
fragments, | ||
variableValues, | ||
runtimeTypeName, | ||
fragment.selectionSet, | ||
fields, | ||
visitedFragmentNames | ||
); | ||
break; | ||
@@ -75,7 +92,17 @@ } | ||
} | ||
const skip = (0, import_values.getDirectiveValues)(import_directives.GraphQLSkipDirective, node, resolvers, variableValues); | ||
const skip = (0, import_values.getDirectiveValues)( | ||
import_directives.GraphQLSkipDirective, | ||
node, | ||
resolvers, | ||
variableValues | ||
); | ||
if ((skip == null ? void 0 : skip.if) === true) { | ||
return false; | ||
} | ||
const include = (0, import_values.getDirectiveValues)(import_directives.GraphQLIncludeDirective, node, resolvers, variableValues); | ||
const include = (0, import_values.getDirectiveValues)( | ||
import_directives.GraphQLIncludeDirective, | ||
node, | ||
resolvers, | ||
variableValues | ||
); | ||
if ((include == null ? void 0 : include.if) === false) { | ||
@@ -101,9 +128,12 @@ return false; | ||
if ((0, import_definition.isInterfaceResolverType)(resolver)) { | ||
const result = resolver.__implementedBy.reduce((acc, item) => { | ||
if (!abstractTypes.has(item)) { | ||
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]); | ||
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item)); | ||
} | ||
return acc; | ||
}, []); | ||
const result = resolver.__implementedBy.reduce( | ||
(acc, item) => { | ||
if (!abstractTypes.has(item)) { | ||
const newTypes = /* @__PURE__ */ new Set([...abstractTypes, item]); | ||
acc.push(...abstractTypes, ...getSubTypes(resolvers, newTypes, item)); | ||
} | ||
return acc; | ||
}, | ||
[] | ||
); | ||
return /* @__PURE__ */ new Set([...result]); | ||
@@ -110,0 +140,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -40,10 +41,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
function argsToArgsConfig(args) { | ||
return (0, import_keyValMap.keyValMap)(args, (arg) => arg.name, (arg) => ({ | ||
description: arg.description, | ||
type: arg.type, | ||
defaultValue: arg.defaultValue, | ||
deprecationReason: arg.deprecationReason, | ||
extensions: arg.extensions, | ||
astNode: arg.astNode | ||
})); | ||
return (0, import_keyValMap.keyValMap)( | ||
args, | ||
(arg) => arg.name, | ||
(arg) => ({ | ||
description: arg.description, | ||
type: arg.type, | ||
defaultValue: arg.defaultValue, | ||
deprecationReason: arg.deprecationReason, | ||
extensions: arg.extensions, | ||
astNode: arg.astNode | ||
}) | ||
); | ||
} | ||
@@ -50,0 +55,0 @@ function isInterfaceResolverType(resolver) { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -44,3 +45,5 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
if (!isDirective(directive)) { | ||
throw new Error(`Expected ${(0, import_inspect.inspect)(directive)} to be a GraphQL directive.`); | ||
throw new Error( | ||
`Expected ${(0, import_inspect.inspect)(directive)} to be a GraphQL directive.` | ||
); | ||
} | ||
@@ -59,5 +62,11 @@ return directive; | ||
(0, import_devAssert.devAssert)(config.name, "Directive must be named."); | ||
(0, import_devAssert.devAssert)(Array.isArray(config.locations), `@${config.name} locations must be an Array.`); | ||
(0, import_devAssert.devAssert)( | ||
Array.isArray(config.locations), | ||
`@${config.name} locations must be an Array.` | ||
); | ||
const args = (_b = config.args) != null ? _b : {}; | ||
(0, import_devAssert.devAssert)((0, import_isObjectLike.isObjectLike)(args) && !Array.isArray(args), `@${config.name} args must be an object with argument names as keys.`); | ||
(0, import_devAssert.devAssert)( | ||
(0, import_isObjectLike.isObjectLike)(args) && !Array.isArray(args), | ||
`@${config.name} args must be an object with argument names as keys.` | ||
); | ||
this.args = (0, import_definition.defineArguments)(args); | ||
@@ -117,38 +126,44 @@ } | ||
const DEFAULT_DEPRECATION_REASON = "No longer supported"; | ||
const GraphQLDeprecatedDirective = new GraphQLDirective({ | ||
name: "deprecated", | ||
description: "Marks an element of a GraphQL schema as no longer supported.", | ||
locations: [ | ||
import_graphql.DirectiveLocation.FIELD_DEFINITION, | ||
import_graphql.DirectiveLocation.ARGUMENT_DEFINITION, | ||
import_graphql.DirectiveLocation.INPUT_FIELD_DEFINITION, | ||
import_graphql.DirectiveLocation.ENUM_VALUE | ||
], | ||
args: { | ||
reason: { | ||
type: import_graphql.GraphQLString, | ||
description: "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).", | ||
defaultValue: DEFAULT_DEPRECATION_REASON | ||
const GraphQLDeprecatedDirective = new GraphQLDirective( | ||
{ | ||
name: "deprecated", | ||
description: "Marks an element of a GraphQL schema as no longer supported.", | ||
locations: [ | ||
import_graphql.DirectiveLocation.FIELD_DEFINITION, | ||
import_graphql.DirectiveLocation.ARGUMENT_DEFINITION, | ||
import_graphql.DirectiveLocation.INPUT_FIELD_DEFINITION, | ||
import_graphql.DirectiveLocation.ENUM_VALUE | ||
], | ||
args: { | ||
reason: { | ||
type: import_graphql.GraphQLString, | ||
description: "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).", | ||
defaultValue: DEFAULT_DEPRECATION_REASON | ||
} | ||
} | ||
} | ||
}); | ||
const GraphQLSpecifiedByDirective = new GraphQLDirective({ | ||
name: "specifiedBy", | ||
description: "Exposes a URL that specifies the behaviour of this scalar.", | ||
locations: [import_graphql.DirectiveLocation.SCALAR], | ||
args: { | ||
url: { | ||
type: new import_graphql.GraphQLNonNull(import_graphql.GraphQLString), | ||
description: "The URL that specifies the behaviour of this scalar." | ||
); | ||
const GraphQLSpecifiedByDirective = new GraphQLDirective( | ||
{ | ||
name: "specifiedBy", | ||
description: "Exposes a URL that specifies the behaviour of this scalar.", | ||
locations: [import_graphql.DirectiveLocation.SCALAR], | ||
args: { | ||
url: { | ||
type: new import_graphql.GraphQLNonNull(import_graphql.GraphQLString), | ||
description: "The URL that specifies the behaviour of this scalar." | ||
} | ||
} | ||
} | ||
}); | ||
const specifiedDirectives = Object.freeze([ | ||
GraphQLIncludeDirective, | ||
GraphQLSkipDirective, | ||
GraphQLDeprecatedDirective, | ||
GraphQLSpecifiedByDirective | ||
]); | ||
); | ||
const specifiedDirectives = Object.freeze( | ||
[ | ||
GraphQLIncludeDirective, | ||
GraphQLSkipDirective, | ||
GraphQLDeprecatedDirective, | ||
GraphQLSpecifiedByDirective | ||
] | ||
); | ||
function isSpecifiedDirective(directive) { | ||
return specifiedDirectives.some(({ name }) => name === directive.name); | ||
} |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -58,3 +59,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
assertValidExecutionArguments(document, variableValues); | ||
const exeContext = buildExecutionContext(combinedResolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); | ||
const exeContext = buildExecutionContext( | ||
combinedResolvers, | ||
document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver, | ||
typeResolver | ||
); | ||
if (!("resolvers" in exeContext)) { | ||
@@ -69,3 +79,5 @@ return { errors: exeContext }; | ||
if ((0, import_isPromise.isPromise)(data)) { | ||
return data.then((resolved) => buildResponse(exeContext, resolved)); | ||
return data.then( | ||
(resolved) => buildResponse(exeContext, resolved) | ||
); | ||
} | ||
@@ -76,3 +88,6 @@ return exeContext.errors.length === 0 ? { data } : { errors: exeContext.errors, data }; | ||
(0, import_devAssert.devAssert)(document, "Must provide document."); | ||
(0, import_devAssert.devAssert)(rawVariableValues == null || (0, import_isObjectLike.isObjectLike)(rawVariableValues), "Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided."); | ||
(0, import_devAssert.devAssert)( | ||
rawVariableValues == null || (0, import_isObjectLike.isObjectLike)(rawVariableValues), | ||
"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided." | ||
); | ||
} | ||
@@ -89,3 +104,5 @@ function buildExecutionContext(resolvers, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) { | ||
return [ | ||
new import_graphql.GraphQLError("Must provide operation name if query contains multiple operations.") | ||
new import_graphql.GraphQLError( | ||
"Must provide operation name if query contains multiple operations." | ||
) | ||
]; | ||
@@ -110,3 +127,8 @@ } | ||
const variableDefinitions = (_b = operation.variableDefinitions) != null ? _b : []; | ||
const coercedVariableValues = (0, import_values.getVariableValues)(resolvers, variableDefinitions, rawVariableValues != null ? rawVariableValues : {}, { maxErrors: 50 }); | ||
const coercedVariableValues = (0, import_values.getVariableValues)( | ||
resolvers, | ||
variableDefinitions, | ||
rawVariableValues != null ? rawVariableValues : {}, | ||
{ maxErrors: 50 } | ||
); | ||
if (coercedVariableValues.errors) { | ||
@@ -129,3 +151,11 @@ return coercedVariableValues.errors; | ||
const typeName = getOperationRootTypeName(operation); | ||
const fields = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, typeName, operation.selectionSet, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set()); | ||
const fields = (0, import_collectFields.collectFields)( | ||
exeContext.resolvers, | ||
exeContext.fragments, | ||
exeContext.variableValues, | ||
typeName, | ||
operation.selectionSet, | ||
/* @__PURE__ */ new Map(), | ||
/* @__PURE__ */ new Set() | ||
); | ||
const path = void 0; | ||
@@ -147,17 +177,27 @@ try { | ||
function executeFieldsSerially(exeContext, parentTypeName, sourceValue, path, fields) { | ||
return (0, import_promiseReduce.promiseReduce)(fields.entries(), (results, [responseName, fieldNodes]) => { | ||
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName); | ||
const result = executeField(exeContext, parentTypeName, sourceValue, fieldNodes, fieldPath); | ||
if (result === void 0) { | ||
return (0, import_promiseReduce.promiseReduce)( | ||
fields.entries(), | ||
(results, [responseName, fieldNodes]) => { | ||
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName); | ||
const result = executeField( | ||
exeContext, | ||
parentTypeName, | ||
sourceValue, | ||
fieldNodes, | ||
fieldPath | ||
); | ||
if (result === void 0) { | ||
return results; | ||
} | ||
if ((0, import_isPromise.isPromise)(result)) { | ||
return result.then((resolvedResult) => { | ||
results[responseName] = resolvedResult; | ||
return results; | ||
}); | ||
} | ||
results[responseName] = result; | ||
return results; | ||
} | ||
if ((0, import_isPromise.isPromise)(result)) { | ||
return result.then((resolvedResult) => { | ||
results[responseName] = resolvedResult; | ||
return results; | ||
}); | ||
} | ||
results[responseName] = result; | ||
return results; | ||
}, /* @__PURE__ */ Object.create(null)); | ||
}, | ||
/* @__PURE__ */ Object.create(null) | ||
); | ||
} | ||
@@ -169,3 +209,9 @@ function executeFields(exeContext, parentTypeName, sourceValue, path, fields) { | ||
const fieldPath = (0, import_Path.addPath)(path, responseName, parentTypeName); | ||
const result = executeField(exeContext, parentTypeName, sourceValue, fieldNodes, fieldPath); | ||
const result = executeField( | ||
exeContext, | ||
parentTypeName, | ||
sourceValue, | ||
fieldNodes, | ||
fieldPath | ||
); | ||
if (result !== void 0) { | ||
@@ -210,5 +256,17 @@ results[responseName] = result; | ||
} | ||
const info = buildResolveInfo(exeContext, fieldName, fieldNodes, parentTypeName, returnTypeName, returnTypeNode, path); | ||
const info = buildResolveInfo( | ||
exeContext, | ||
fieldName, | ||
fieldNodes, | ||
parentTypeName, | ||
returnTypeName, | ||
returnTypeNode, | ||
path | ||
); | ||
try { | ||
const args = (0, import_values.getArgumentValues)(exeContext.resolvers, fieldNodes[0], exeContext.variableValues); | ||
const args = (0, import_values.getArgumentValues)( | ||
exeContext.resolvers, | ||
fieldNodes[0], | ||
exeContext.variableValues | ||
); | ||
const contextValue = exeContext.contextValue; | ||
@@ -218,9 +276,29 @@ const result = resolveFn(source, args, contextValue, info); | ||
if ((0, import_isPromise.isPromise)(result)) { | ||
completed = result.then((resolved) => completeValue(exeContext, returnTypeNode, fieldNodes, info, path, resolved)); | ||
completed = result.then( | ||
(resolved) => completeValue( | ||
exeContext, | ||
returnTypeNode, | ||
fieldNodes, | ||
info, | ||
path, | ||
resolved | ||
) | ||
); | ||
} else { | ||
completed = completeValue(exeContext, returnTypeNode, fieldNodes, info, path, result); | ||
completed = completeValue( | ||
exeContext, | ||
returnTypeNode, | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
} | ||
if ((0, import_isPromise.isPromise)(completed)) { | ||
return completed.then(void 0, (rawError) => { | ||
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(path)); | ||
const error = (0, import_graphql.locatedError)( | ||
rawError, | ||
fieldNodes, | ||
(0, import_Path.pathToArray)(path) | ||
); | ||
return handleFieldError(error, returnTypeNode, exeContext); | ||
@@ -231,3 +309,7 @@ }); | ||
} catch (rawError) { | ||
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(path)); | ||
const error = (0, import_graphql.locatedError)( | ||
rawError, | ||
fieldNodes, | ||
(0, import_Path.pathToArray)(path) | ||
); | ||
return handleFieldError(error, returnTypeNode, exeContext); | ||
@@ -262,5 +344,14 @@ } | ||
if (returnTypeNode.kind === import_graphql.Kind.NON_NULL_TYPE) { | ||
const completed = completeValue(exeContext, returnTypeNode.type, fieldNodes, info, path, result); | ||
const completed = completeValue( | ||
exeContext, | ||
returnTypeNode.type, | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
if (completed === null) { | ||
throw new Error(`Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.`); | ||
throw new Error( | ||
`Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.` | ||
); | ||
} | ||
@@ -273,3 +364,10 @@ return completed; | ||
if (returnTypeNode.kind === import_graphql.Kind.LIST_TYPE) { | ||
return completeListValue(exeContext, returnTypeNode.type, fieldNodes, info, path, result); | ||
return completeListValue( | ||
exeContext, | ||
returnTypeNode.type, | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
} | ||
@@ -287,12 +385,31 @@ const returnTypeName = returnTypeNode.name.value; | ||
if ((0, import_definition.isUnionResolverType)(returnType) || (0, import_definition.isInterfaceResolverType)(returnType)) { | ||
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result); | ||
return completeAbstractValue( | ||
exeContext, | ||
returnType, | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
} | ||
if (typeof returnType === "object") { | ||
return completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path, result); | ||
return completeObjectValue( | ||
exeContext, | ||
returnTypeName, | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
} | ||
(0, import_invariant.invariant)(false, "Cannot complete value of unexpected output type: " + (0, import_inspect.inspect)(returnType)); | ||
(0, import_invariant.invariant)( | ||
false, | ||
"Cannot complete value of unexpected output type: " + (0, import_inspect.inspect)(returnType) | ||
); | ||
} | ||
function completeListValue(exeContext, returnTypeNode, fieldNodes, info, path, result) { | ||
if (!(0, import_isIterableObject.isIterableObject)(result)) { | ||
throw new import_graphql.GraphQLError(`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".`); | ||
throw new import_graphql.GraphQLError( | ||
`Expected Iterable, but did not find one for field "${info.parentTypeName}.${info.fieldName}".` | ||
); | ||
} | ||
@@ -305,5 +422,21 @@ let containsPromise = false; | ||
if ((0, import_isPromise.isPromise)(item)) { | ||
completedItem = item.then((resolved) => completeValue(exeContext, returnTypeNode, fieldNodes, info, itemPath, resolved)); | ||
completedItem = item.then( | ||
(resolved) => completeValue( | ||
exeContext, | ||
returnTypeNode, | ||
fieldNodes, | ||
info, | ||
itemPath, | ||
resolved | ||
) | ||
); | ||
} else { | ||
completedItem = completeValue(exeContext, returnTypeNode, fieldNodes, info, itemPath, item); | ||
completedItem = completeValue( | ||
exeContext, | ||
returnTypeNode, | ||
fieldNodes, | ||
info, | ||
itemPath, | ||
item | ||
); | ||
} | ||
@@ -313,3 +446,7 @@ if ((0, import_isPromise.isPromise)(completedItem)) { | ||
return completedItem.then(void 0, (rawError) => { | ||
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(itemPath)); | ||
const error = (0, import_graphql.locatedError)( | ||
rawError, | ||
fieldNodes, | ||
(0, import_Path.pathToArray)(itemPath) | ||
); | ||
return handleFieldError(error, returnTypeNode, exeContext); | ||
@@ -320,3 +457,7 @@ }); | ||
} catch (rawError) { | ||
const error = (0, import_graphql.locatedError)(rawError, fieldNodes, (0, import_Path.pathToArray)(itemPath)); | ||
const error = (0, import_graphql.locatedError)( | ||
rawError, | ||
fieldNodes, | ||
(0, import_Path.pathToArray)(itemPath) | ||
); | ||
return handleFieldError(error, returnTypeNode, exeContext); | ||
@@ -330,3 +471,5 @@ } | ||
if (serializedResult === void 0) { | ||
throw new Error(`Expected a value of type "${(0, import_inspect.inspect)(returnType)}" but received: ${(0, import_inspect.inspect)(result)}`); | ||
throw new Error( | ||
`Expected a value of type "${(0, import_inspect.inspect)(returnType)}" but received: ${(0, import_inspect.inspect)(result)}` | ||
); | ||
} | ||
@@ -341,15 +484,39 @@ return serializedResult; | ||
if ((0, import_isPromise.isPromise)(runtimeTypeName)) { | ||
return runtimeTypeName.then((resolvedRuntimeTypeName) => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeTypeName, exeContext), fieldNodes, info, path, result)); | ||
return runtimeTypeName.then( | ||
(resolvedRuntimeTypeName) => completeObjectValue( | ||
exeContext, | ||
ensureValidRuntimeType(resolvedRuntimeTypeName, exeContext), | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
) | ||
); | ||
} | ||
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeTypeName, exeContext), fieldNodes, info, path, result); | ||
return completeObjectValue( | ||
exeContext, | ||
ensureValidRuntimeType(runtimeTypeName, exeContext), | ||
fieldNodes, | ||
info, | ||
path, | ||
result | ||
); | ||
} | ||
function ensureValidRuntimeType(runtimeTypeName, exeContext) { | ||
if (typeof runtimeTypeName !== "string") { | ||
throw new import_graphql.GraphQLError(`Could not determine runtime type for abstract type ${runtimeTypeName}`); | ||
throw new import_graphql.GraphQLError( | ||
`Could not determine runtime type for abstract type ${runtimeTypeName}` | ||
); | ||
} | ||
const runtimeType = exeContext.resolvers[runtimeTypeName]; | ||
if (!runtimeType) { | ||
throw new import_graphql.GraphQLError(`Type "${runtimeTypeName}" does not exist inside the schema.`); | ||
throw new import_graphql.GraphQLError( | ||
`Type "${runtimeTypeName}" does not exist inside the schema.` | ||
); | ||
} else if (runtimeType instanceof import_graphql.GraphQLScalarType || runtimeType instanceof import_graphql.GraphQLEnumType || runtimeType instanceof import_graphql.GraphQLInputObjectType || runtimeType.__resolveType) { | ||
throw new import_graphql.GraphQLError(`Given runtime object "${getRuntimeTypeInstanceName(runtimeType)}" type is not a possible type for "${runtimeTypeName}".`); | ||
throw new import_graphql.GraphQLError( | ||
`Given runtime object "${getRuntimeTypeInstanceName( | ||
runtimeType | ||
)}" type is not a possible type for "${runtimeTypeName}".` | ||
); | ||
} else { | ||
@@ -375,7 +542,14 @@ return runtimeTypeName; | ||
function completeObjectValue(exeContext, returnTypeName, fieldNodes, info, path, result) { | ||
const subFieldNodes = collectSubfields(exeContext, returnTypeName, fieldNodes); | ||
const subFieldNodes = collectSubfields( | ||
exeContext, | ||
returnTypeName, | ||
fieldNodes | ||
); | ||
return executeFields(exeContext, returnTypeName, result, path, subFieldNodes); | ||
} | ||
function invalidReturnTypeError(returnType, result, fieldNodes) { | ||
return new import_graphql.GraphQLError(`Expected value of type "${returnType.name}" but got: ${(0, import_inspect.inspect)(result)}.`, fieldNodes); | ||
return new import_graphql.GraphQLError( | ||
`Expected value of type "${returnType.name}" but got: ${(0, import_inspect.inspect)(result)}.`, | ||
fieldNodes | ||
); | ||
} | ||
@@ -387,3 +561,11 @@ function collectSubfields(exeContext, returnTypeName, fieldNodes) { | ||
if (node.selectionSet) { | ||
subFieldNodes = (0, import_collectFields.collectFields)(exeContext.resolvers, exeContext.fragments, exeContext.variableValues, returnTypeName, node.selectionSet, subFieldNodes, visitedFragmentNames); | ||
subFieldNodes = (0, import_collectFields.collectFields)( | ||
exeContext.resolvers, | ||
exeContext.fragments, | ||
exeContext.variableValues, | ||
returnTypeName, | ||
node.selectionSet, | ||
subFieldNodes, | ||
visitedFragmentNames | ||
); | ||
} | ||
@@ -390,0 +572,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -60,3 +61,5 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
} | ||
implementedBy[node.name.value].push(astNode.name.value); | ||
implementedBy[node.name.value].push( | ||
astNode.name.value | ||
); | ||
}); | ||
@@ -63,0 +66,0 @@ result[astNode.name.value] = {}; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -69,3 +70,5 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
} | ||
const properties = entries.map(([key, value]) => key + ": " + formatValue(value, seenValues)); | ||
const properties = entries.map( | ||
([key, value]) => key + ": " + formatValue(value, seenValues) | ||
); | ||
return "{ " + properties.join(", ") + " }"; | ||
@@ -72,0 +75,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -24,5 +25,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var import_inspect = require("./inspect"); | ||
const instanceOf = false ? function instanceOf2(value, constructor) { | ||
return value instanceof constructor; | ||
} : function instanceOf3(value, constructor) { | ||
const instanceOf = false ? ( | ||
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') | ||
function instanceOf2(value, constructor) { | ||
return value instanceof constructor; | ||
} | ||
) : function instanceOf3(value, constructor) { | ||
var _a; | ||
@@ -34,6 +38,13 @@ if (value instanceof constructor) { | ||
const className = constructor.prototype[Symbol.toStringTag]; | ||
const valueClassName = Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_a = value.constructor) == null ? void 0 : _a.name; | ||
const valueClassName = ( | ||
// We still need to support constructor's name to detect conflicts with older versions of this library. | ||
Symbol.toStringTag in value ? ( | ||
// @ts-expect-error TS bug see, https://github.com/microsoft/TypeScript/issues/38009 | ||
value[Symbol.toStringTag] | ||
) : (_a = value.constructor) == null ? void 0 : _a.name | ||
); | ||
if (className === valueClassName) { | ||
const stringifiedValue = (0, import_inspect.inspect)(value); | ||
throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm. | ||
throw new Error( | ||
`Cannot use ${className} "${stringifiedValue}" from another module or realm. | ||
@@ -49,3 +60,4 @@ Ensure that there is only one instance of "graphql" in the node_modules | ||
version used in the function from another could produce confusing and | ||
spurious results.`); | ||
spurious results.` | ||
); | ||
} | ||
@@ -52,0 +64,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -26,4 +27,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
if (!booleanCondition) { | ||
throw new Error(message != null ? message : "Unexpected invariant triggered."); | ||
throw new Error( | ||
message != null ? message : "Unexpected invariant triggered." | ||
); | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -24,3 +25,5 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
function printPathArray(path) { | ||
return path.map((key) => typeof key === "number" ? "[" + key.toString() + "]" : "." + key).join(""); | ||
return path.map( | ||
(key) => typeof key === "number" ? "[" + key.toString() + "]" : "." + key | ||
).join(""); | ||
} |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -80,3 +81,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
const cost = a[i - 1] === b[j - 1] ? 0 : 1; | ||
let currentCell = Math.min(upRow[j] + 1, currentRow[j - 1] + 1, upRow[j - 1] + cost); | ||
let currentCell = Math.min( | ||
upRow[j] + 1, | ||
// delete | ||
currentRow[j - 1] + 1, | ||
// insert | ||
upRow[j - 1] + cost | ||
// substitute | ||
); | ||
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { | ||
@@ -83,0 +91,0 @@ const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -68,3 +69,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
const combinedResolvers = (0, import_mergeResolvers.mergeResolvers)(resolvers, schemaResolvers); | ||
const resultOrStream = yield createSourceEventStream(combinedResolvers, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); | ||
const resultOrStream = yield createSourceEventStream( | ||
combinedResolvers, | ||
document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
subscribeFieldResolver | ||
); | ||
if (!(0, import_isAsyncIterable.isAsyncIterable)(resultOrStream)) { | ||
@@ -90,3 +99,11 @@ return resultOrStream; | ||
try { | ||
const exeContext = (0, import_executeWithoutSchema.buildExecutionContext)(resolvers, document, rootValue, contextValue, variableValues, operationName, fieldResolver); | ||
const exeContext = (0, import_executeWithoutSchema.buildExecutionContext)( | ||
resolvers, | ||
document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver | ||
); | ||
if (!("resolvers" in exeContext)) { | ||
@@ -97,3 +114,5 @@ return { errors: exeContext }; | ||
if (!(0, import_isAsyncIterable.isAsyncIterable)(eventStream)) { | ||
throw new Error(`Subscription field must return Async Iterable. Received: ${(0, import_inspect.inspect)(eventStream)}.`); | ||
throw new Error( | ||
`Subscription field must return Async Iterable. Received: ${(0, import_inspect.inspect)(eventStream)}.` | ||
); | ||
} | ||
@@ -119,3 +138,11 @@ return eventStream; | ||
const typeName = (0, import_executeWithoutSchema.getOperationRootTypeName)(operation); | ||
const fields = (0, import_collectFields.collectFields)(resolvers, fragments, variableValues, typeName, operation.selectionSet, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Set()); | ||
const fields = (0, import_collectFields.collectFields)( | ||
resolvers, | ||
fragments, | ||
variableValues, | ||
typeName, | ||
operation.selectionSet, | ||
/* @__PURE__ */ new Map(), | ||
/* @__PURE__ */ new Set() | ||
); | ||
const [responseName, fieldNodes] = [...fields.entries()][0]; | ||
@@ -146,3 +173,11 @@ const fieldName = fieldNodes[0].name.value; | ||
const path = (0, import_Path.addPath)(void 0, responseName, typeName); | ||
const info = (0, import_executeWithoutSchema.buildResolveInfo)(exeContext, fieldName, fieldNodes, typeName, returnTypeName, returnTypeNode, path); | ||
const info = (0, import_executeWithoutSchema.buildResolveInfo)( | ||
exeContext, | ||
fieldName, | ||
fieldNodes, | ||
typeName, | ||
returnTypeName, | ||
returnTypeNode, | ||
path | ||
); | ||
try { | ||
@@ -157,5 +192,9 @@ const args = (0, import_values.getArgumentValues)(resolvers, fieldNodes[0], variableValues); | ||
} catch (error) { | ||
throw (0, import_graphql.locatedError)(error, fieldNodes, (0, import_Path.pathToArray)(path)); | ||
throw (0, import_graphql.locatedError)( | ||
error, | ||
fieldNodes, | ||
(0, import_Path.pathToArray)(path) | ||
); | ||
} | ||
}); | ||
} |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -2,0 +3,0 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -34,8 +35,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
try { | ||
const coerced = coerceVariableValues(resolvers, varDefNodes, inputs, (error) => { | ||
if (maxErrors != null && errors.length >= maxErrors) { | ||
throw new import_graphql.GraphQLError("Too many errors processing variables, error limit reached. Execution aborted."); | ||
const coerced = coerceVariableValues( | ||
resolvers, | ||
varDefNodes, | ||
inputs, | ||
(error) => { | ||
if (maxErrors != null && errors.length >= maxErrors) { | ||
throw new import_graphql.GraphQLError( | ||
"Too many errors processing variables, error limit reached. Execution aborted." | ||
); | ||
} | ||
errors.push(error); | ||
} | ||
errors.push(error); | ||
}); | ||
); | ||
if (errors.length === 0) { | ||
@@ -57,3 +65,8 @@ return { coerced }; | ||
const varTypeStr = (0, import_inspect.inspect)(varType); | ||
onError(new import_graphql.GraphQLError(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, varDefNode.type)); | ||
onError( | ||
new import_graphql.GraphQLError( | ||
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, | ||
varDefNode.type | ||
) | ||
); | ||
continue; | ||
@@ -63,6 +76,14 @@ } | ||
if (varDefNode.defaultValue) { | ||
coercedValues[varName] = (0, import_graphql.valueFromAST)(varDefNode.defaultValue, varType); | ||
coercedValues[varName] = (0, import_graphql.valueFromAST)( | ||
varDefNode.defaultValue, | ||
varType | ||
); | ||
} else if ((0, import_graphql.isNonNullType)(varType)) { | ||
const varTypeStr = (0, import_graphql.print)(varDefNode.type); | ||
onError(new import_graphql.GraphQLError(`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, varDefNode)); | ||
onError( | ||
new import_graphql.GraphQLError( | ||
`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, | ||
varDefNode | ||
) | ||
); | ||
} | ||
@@ -74,12 +95,30 @@ continue; | ||
const varTypeStr = (0, import_inspect.inspect)(varType); | ||
onError(new import_graphql.GraphQLError(`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, varDefNode)); | ||
onError( | ||
new import_graphql.GraphQLError( | ||
`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, | ||
varDefNode | ||
) | ||
); | ||
continue; | ||
} | ||
coercedValues[varName] = (0, import_graphql.coerceInputValue)(value, varType, (path, invalidValue, error) => { | ||
let prefix = `Variable "$${varName}" got invalid value ` + (0, import_inspect.inspect)(invalidValue); | ||
if (path.length > 0) { | ||
prefix += ` at "${varName}${(0, import_printPathArray.printPathArray)(path)}"`; | ||
coercedValues[varName] = (0, import_graphql.coerceInputValue)( | ||
value, | ||
varType, | ||
(path, invalidValue, error) => { | ||
let prefix = `Variable "$${varName}" got invalid value ` + (0, import_inspect.inspect)(invalidValue); | ||
if (path.length > 0) { | ||
prefix += ` at "${varName}${(0, import_printPathArray.printPathArray)(path)}"`; | ||
} | ||
onError( | ||
new import_graphql.GraphQLError( | ||
prefix + "; " + error.message, | ||
varDefNode, | ||
void 0, | ||
void 0, | ||
void 0, | ||
error.originalError | ||
) | ||
); | ||
} | ||
onError(new import_graphql.GraphQLError(prefix + "; " + error.message, varDefNode, void 0, void 0, void 0, error.originalError)); | ||
}); | ||
); | ||
} | ||
@@ -92,3 +131,6 @@ return coercedValues; | ||
const argumentNodes = (_a = node.arguments) != null ? _a : []; | ||
const argNodeMap = (0, import_keyMap.keyMap)(argumentNodes, (arg) => arg.name.value); | ||
const argNodeMap = (0, import_keyMap.keyMap)( | ||
argumentNodes, | ||
(arg) => arg.name.value | ||
); | ||
for (const argumentNode of argumentNodes) { | ||
@@ -100,3 +142,8 @@ const name = argumentNode.name.value; | ||
console.log(argType, (0, import_graphql.isInputType)(argType)); | ||
throw new import_graphql.GraphQLError(`Argument "$${name}" expected value of type "${(0, import_inspect.inspect)(argType)}" which cannot be used as an input type.`, argumentNode); | ||
throw new import_graphql.GraphQLError( | ||
`Argument "$${name}" expected value of type "${(0, import_inspect.inspect)( | ||
argType | ||
)}" which cannot be used as an input type.`, | ||
argumentNode | ||
); | ||
} | ||
@@ -111,3 +158,6 @@ let valueNode = argumentNode.value; | ||
} else if ((0, import_graphql.isNonNullType)(argType)) { | ||
throw new import_graphql.GraphQLError(`Argument "${name}" of required type "${(0, import_inspect.inspect)(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`, valueNode); | ||
throw new import_graphql.GraphQLError( | ||
`Argument "${name}" of required type "${(0, import_inspect.inspect)(argType)}" was provided the variable "$${variableName}" which was not provided a runtime value.`, | ||
valueNode | ||
); | ||
} | ||
@@ -118,5 +168,14 @@ continue; | ||
} | ||
const coercedValue = (0, import_graphql.valueFromAST)(valueNode, argType, variableValues); | ||
const coercedValue = (0, import_graphql.valueFromAST)( | ||
valueNode, | ||
argType, | ||
variableValues | ||
); | ||
if (coercedValue === void 0) { | ||
throw new import_graphql.GraphQLError(`Argument "${name}" has invalid value ${(0, import_graphql.print)(valueNode)}.`, valueNode); | ||
throw new import_graphql.GraphQLError( | ||
`Argument "${name}" has invalid value ${(0, import_graphql.print)( | ||
valueNode | ||
)}.`, | ||
valueNode | ||
); | ||
} | ||
@@ -129,3 +188,5 @@ coercedValues[name] = coercedValue; | ||
var _a; | ||
const directiveNode = (_a = node.directives) == null ? void 0 : _a.find((directive) => directive.name.value === directiveDef.name); | ||
const directiveNode = (_a = node.directives) == null ? void 0 : _a.find( | ||
(directive) => directive.name.value === directiveDef.name | ||
); | ||
if (directiveNode) { | ||
@@ -132,0 +193,0 @@ return getArgumentValues(resolvers, directiveNode, variableValues); |
{ | ||
"name": "@graphitation/supermassive", | ||
"license": "MIT", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"main": "./lib/index", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333150
7284