From 9b5df35e2e1428fe068a36f729e6c594a2a6e76e Mon Sep 17 00:00:00 2001 From: Sherlo Bot Date: Thu, 20 Jun 2024 14:56:16 +0000 Subject: [PATCH] Version updates and builds for ${NEW_VERSION_NUMBER} --- examples/expo-example/package.json | 6 +- lerna.json | 2 +- packages/action/package.json | 4 +- packages/action/release/index.js | 40044 +++++++++++++---- packages/cli/package.json | 2 +- packages/react-native-storybook/package.json | 2 +- yarn.lock | 32 +- 7 files changed, 32363 insertions(+), 7729 deletions(-) diff --git a/examples/expo-example/package.json b/examples/expo-example/package.json index 9105c1a8..1d4bd5d9 100644 --- a/examples/expo-example/package.json +++ b/examples/expo-example/package.json @@ -1,6 +1,6 @@ { "name": "@sherlo/expo-example", - "version": "1.0.15", + "version": "1.0.16", "private": true, "main": "index.ts", "scripts": { @@ -52,8 +52,8 @@ }, "devDependencies": { "@babel/core": "^7.20.0", - "@sherlo/cli": "^1.0.15", - "@sherlo/react-native-storybook": "^1.0.15", + "@sherlo/cli": "^1.0.16", + "@sherlo/react-native-storybook": "^1.0.16", "@storybook/addon-actions": "^7.6.10", "@storybook/addon-controls": "^7.6.10", "@storybook/addon-designs": "^7.0.9", diff --git a/lerna.json b/lerna.json index beace86a..79aa431f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "npmClient": "yarn", - "version": "1.0.15", + "version": "1.0.16", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/action/package.json b/packages/action/package.json index a8f52605..3192eaed 100644 --- a/packages/action/package.json +++ b/packages/action/package.json @@ -1,6 +1,6 @@ { "name": "@sherlo/action", - "version": "1.0.15", + "version": "1.0.16", "description": "A github action that uploads provided iOS & Android builds to Sherlo and starts a test run", "license": "MIT", "author": "Sherlo", @@ -28,7 +28,7 @@ "dependencies": { "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", - "@sherlo/cli": "^1.0.15" + "@sherlo/cli": "^1.0.16" }, "devDependencies": { "@types/jest": "^26.0.15", diff --git a/packages/action/release/index.js b/packages/action/release/index.js index 8a5a497c..c38d535e 100644 --- a/packages/action/release/index.js +++ b/packages/action/release/index.js @@ -6422,6 +6422,23378 @@ function isLoopbackAddress(host) { } //# sourceMappingURL=proxy.js.map +/***/ }), + +/***/ 66807: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLError = void 0; +exports.formatError = formatError; +exports.printError = printError; + +var _isObjectLike = __nccwpck_require__(63457); + +var _location = __nccwpck_require__(61336); + +var _printLocation = __nccwpck_require__(29983); + +function toNormalizedOptions(args) { + const firstArg = args[0]; + + if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) { + return { + nodes: firstArg, + source: args[1], + positions: args[2], + path: args[3], + originalError: args[4], + extensions: args[5], + }; + } + + return firstArg; +} +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ + +class GraphQLError extends Error { + /** + * An array of `{ line, column }` locations within the source GraphQL document + * which correspond to this error. + * + * Errors during validation often contain multiple locations, for example to + * point out two things with the same name. Errors during execution include a + * single location, the field which produced the error. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array describing the JSON-path into the execution response which + * corresponds to this error. Only included for errors during execution. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + + /** + * The source GraphQL document for the first location of this error. + * + * Note that if this Error represents more than one node, the source may not + * represent nodes after the first node. + */ + + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + + /** + * The original error thrown from a field resolver during execution. + */ + + /** + * Extension fields to add to the formatted error. + */ + + /** + * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead. + */ + constructor(message, ...rawArgs) { + var _this$nodes, _nodeLocations$, _ref; + + const { nodes, source, positions, path, originalError, extensions } = + toNormalizedOptions(rawArgs); + super(message); + this.name = 'GraphQLError'; + this.path = path !== null && path !== void 0 ? path : undefined; + this.originalError = + originalError !== null && originalError !== void 0 + ? originalError + : undefined; // Compute list of blame nodes. + + this.nodes = undefinedIfEmpty( + Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined, + ); + const nodeLocations = undefinedIfEmpty( + (_this$nodes = this.nodes) === null || _this$nodes === void 0 + ? void 0 + : _this$nodes.map((node) => node.loc).filter((loc) => loc != null), + ); // Compute locations in the source for the given nodes/positions. + + this.source = + source !== null && source !== void 0 + ? source + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : (_nodeLocations$ = nodeLocations[0]) === null || + _nodeLocations$ === void 0 + ? void 0 + : _nodeLocations$.source; + this.positions = + positions !== null && positions !== void 0 + ? positions + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => loc.start); + this.locations = + positions && source + ? positions.map((pos) => (0, _location.getLocation)(source, pos)) + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => + (0, _location.getLocation)(loc.source, loc.start), + ); + const originalExtensions = (0, _isObjectLike.isObjectLike)( + originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions, + ) + ? originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions + : undefined; + this.extensions = + (_ref = + extensions !== null && extensions !== void 0 + ? extensions + : originalExtensions) !== null && _ref !== void 0 + ? _ref + : Object.create(null); // Only properties prescribed by the spec should be enumerable. + // Keep the rest as non-enumerable. + + Object.defineProperties(this, { + message: { + writable: true, + enumerable: true, + }, + name: { + enumerable: false, + }, + nodes: { + enumerable: false, + }, + source: { + enumerable: false, + }, + positions: { + enumerable: false, + }, + originalError: { + enumerable: false, + }, + }); // Include (non-enumerable) stack trace. + + /* c8 ignore start */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + + if ( + originalError !== null && + originalError !== void 0 && + originalError.stack + ) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + } else if (Error.captureStackTrace) { + Error.captureStackTrace(this, GraphQLError); + } else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + /* c8 ignore stop */ + } + + get [Symbol.toStringTag]() { + return 'GraphQLError'; + } + + toString() { + let output = this.message; + + if (this.nodes) { + for (const node of this.nodes) { + if (node.loc) { + output += '\n\n' + (0, _printLocation.printLocation)(node.loc); + } + } + } else if (this.source && this.locations) { + for (const location of this.locations) { + output += + '\n\n' + + (0, _printLocation.printSourceLocation)(this.source, location); + } + } + + return output; + } + + toJSON() { + const formattedError = { + message: this.message, + }; + + if (this.locations != null) { + formattedError.locations = this.locations; + } + + if (this.path != null) { + formattedError.path = this.path; + } + + if (this.extensions != null && Object.keys(this.extensions).length > 0) { + formattedError.extensions = this.extensions; + } + + return formattedError; + } +} + +exports.GraphQLError = GraphQLError; + +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +/** + * See: https://spec.graphql.org/draft/#sec-Errors + */ + +/** + * Prints a GraphQLError to a string, representing useful location information + * about the error's position in the source. + * + * @deprecated Please use `error.toString` instead. Will be removed in v17 + */ +function printError(error) { + return error.toString(); +} +/** + * Given a GraphQLError, format it according to the rules described by the + * Response Format, Errors section of the GraphQL Specification. + * + * @deprecated Please use `error.toJSON` instead. Will be removed in v17 + */ + +function formatError(error) { + return error.toJSON(); +} + + +/***/ }), + +/***/ 17651: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "GraphQLError", ({ + enumerable: true, + get: function () { + return _GraphQLError.GraphQLError; + }, +})); +Object.defineProperty(exports, "formatError", ({ + enumerable: true, + get: function () { + return _GraphQLError.formatError; + }, +})); +Object.defineProperty(exports, "locatedError", ({ + enumerable: true, + get: function () { + return _locatedError.locatedError; + }, +})); +Object.defineProperty(exports, "printError", ({ + enumerable: true, + get: function () { + return _GraphQLError.printError; + }, +})); +Object.defineProperty(exports, "syntaxError", ({ + enumerable: true, + get: function () { + return _syntaxError.syntaxError; + }, +})); + +var _GraphQLError = __nccwpck_require__(66807); + +var _syntaxError = __nccwpck_require__(53373); + +var _locatedError = __nccwpck_require__(61317); + + +/***/ }), + +/***/ 61317: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.locatedError = locatedError; + +var _toError = __nccwpck_require__(56552); + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Given an arbitrary value, presumably thrown while attempting to execute a + * GraphQL operation, produce a new GraphQLError aware of the location in the + * document responsible for the original Error. + */ +function locatedError(rawOriginalError, nodes, path) { + var _nodes; + + const originalError = (0, _toError.toError)(rawOriginalError); // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + + if (isLocatedGraphQLError(originalError)) { + return originalError; + } + + return new _GraphQLError.GraphQLError(originalError.message, { + nodes: + (_nodes = originalError.nodes) !== null && _nodes !== void 0 + ? _nodes + : nodes, + source: originalError.source, + positions: originalError.positions, + path, + originalError, + }); +} + +function isLocatedGraphQLError(error) { + return Array.isArray(error.path); +} + + +/***/ }), + +/***/ 53373: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.syntaxError = syntaxError; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Produces a GraphQLError representing a syntax error, containing useful + * descriptive information about the syntax error's position in the source. + */ +function syntaxError(source, position, description) { + return new _GraphQLError.GraphQLError(`Syntax Error: ${description}`, { + source, + positions: [position], + }); +} + + +/***/ }), + +/***/ 54808: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.collectFields = collectFields; +exports.collectSubfields = collectSubfields; + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _typeFromAST = __nccwpck_require__(73461); + +var _values = __nccwpck_require__(30848); + +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ +function collectFields( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, +) { + const fields = new Map(); + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + new Set(), + ); + return fields; +} +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ + +function collectSubfields( + schema, + fragments, + variableValues, + returnType, + fieldNodes, +) { + const subFieldNodes = new Map(); + const visitedFragmentNames = new Set(); + + for (const node of fieldNodes) { + if (node.selectionSet) { + collectFieldsImpl( + schema, + fragments, + variableValues, + returnType, + node.selectionSet, + subFieldNodes, + visitedFragmentNames, + ); + } + } + + return subFieldNodes; +} + +function collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + visitedFragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _kinds.Kind.FIELD: { + if (!shouldIncludeNode(variableValues, selection)) { + continue; + } + + const name = getFieldEntryKey(selection); + const fieldList = fields.get(name); + + if (fieldList !== undefined) { + fieldList.push(selection); + } else { + fields.set(name, [selection]); + } + + break; + } + + case _kinds.Kind.INLINE_FRAGMENT: { + if ( + !shouldIncludeNode(variableValues, selection) || + !doesFragmentConditionMatch(schema, selection, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selection.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + + case _kinds.Kind.FRAGMENT_SPREAD: { + const fragName = selection.name.value; + + if ( + visitedFragmentNames.has(fragName) || + !shouldIncludeNode(variableValues, selection) + ) { + continue; + } + + visitedFragmentNames.add(fragName); + const fragment = fragments[fragName]; + + if ( + !fragment || + !doesFragmentConditionMatch(schema, fragment, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + fragment.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + } + } +} +/** + * Determines if a field should be included based on the `@include` and `@skip` + * directives, where `@skip` has higher precedence than `@include`. + */ + +function shouldIncludeNode(variableValues, node) { + const skip = (0, _values.getDirectiveValues)( + _directives.GraphQLSkipDirective, + node, + variableValues, + ); + + if ((skip === null || skip === void 0 ? void 0 : skip.if) === true) { + return false; + } + + const include = (0, _values.getDirectiveValues)( + _directives.GraphQLIncludeDirective, + node, + variableValues, + ); + + if ( + (include === null || include === void 0 ? void 0 : include.if) === false + ) { + return false; + } + + return true; +} +/** + * Determines if a fragment is applicable to the given type. + */ + +function doesFragmentConditionMatch(schema, fragment, type) { + const typeConditionNode = fragment.typeCondition; + + if (!typeConditionNode) { + return true; + } + + const conditionalType = (0, _typeFromAST.typeFromAST)( + schema, + typeConditionNode, + ); + + if (conditionalType === type) { + return true; + } + + if ((0, _definition.isAbstractType)(conditionalType)) { + return schema.isSubType(conditionalType, type); + } + + return false; +} +/** + * Implements the logic to compute the key of a given field's entry + */ + +function getFieldEntryKey(node) { + return node.alias ? node.alias.value : node.name.value; +} + + +/***/ }), + +/***/ 11184: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidExecutionArguments = assertValidExecutionArguments; +exports.buildExecutionContext = buildExecutionContext; +exports.buildResolveInfo = buildResolveInfo; +exports.defaultTypeResolver = exports.defaultFieldResolver = void 0; +exports.execute = execute; +exports.executeSync = executeSync; +exports.getFieldDef = getFieldDef; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _isIterableObject = __nccwpck_require__(45988); + +var _isObjectLike = __nccwpck_require__(63457); + +var _isPromise = __nccwpck_require__(68362); + +var _memoize = __nccwpck_require__(66997); + +var _Path = __nccwpck_require__(80333); + +var _promiseForObject = __nccwpck_require__(55982); + +var _promiseReduce = __nccwpck_require__(40490); + +var _GraphQLError = __nccwpck_require__(66807); + +var _locatedError = __nccwpck_require__(61317); + +var _ast = __nccwpck_require__(20727); + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +var _introspection = __nccwpck_require__(98029); + +var _validate = __nccwpck_require__(95929); + +var _collectFields = __nccwpck_require__(54808); + +var _values = __nccwpck_require__(30848); + +/** + * A memoized collection of relevant subfields with regard to the return + * type. Memoizing ensures the subfields are not repeatedly calculated, which + * saves overhead when resolving lists of values. + */ +const collectSubfields = (0, _memoize.memoize3)( + (exeContext, returnType, fieldNodes) => + (0, _collectFields.collectSubfields)( + exeContext.schema, + exeContext.fragments, + exeContext.variableValues, + returnType, + fieldNodes, + ), +); +/** + * Terminology + * + * "Definitions" are the generic name for top-level statements in the document. + * Examples of this include: + * 1) Operations (such as a query) + * 2) Fragments + * + * "Operations" are a generic name for requests in the document. + * Examples of this include: + * 1) query, + * 2) mutation + * + * "Selections" are the definitions that can appear legally and at + * single level of the query. These include: + * 1) field references e.g `a` + * 2) fragment "spreads" e.g. `...c` + * 3) inline fragment "spreads" e.g. `...on Type { a }` + */ + +/** + * Data that must be available at all points during query execution. + * + * Namely, schema of the type system that is currently executing, + * and the fragments defined in the query document + */ + +/** + * Implements the "Executing requests" section of the GraphQL specification. + * + * Returns either a synchronous ExecutionResult (if all encountered resolvers + * are synchronous), or a Promise of an ExecutionResult that will eventually be + * resolved and never rejected. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + */ +function execute(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0, _devAssert.devAssert)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { schema, document, variableValues, rootValue } = args; // If arguments are missing or incorrect, throw an error. + + assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + + const exeContext = buildExecutionContext(args); // Return early errors if execution context failed. + + if (!('schema' in exeContext)) { + return { + errors: exeContext, + }; + } // Return a Promise that will eventually resolve to the data described by + // The "Response" section of the GraphQL specification. + // + // If errors are encountered while executing a GraphQL field, only that + // field and its descendants will be omitted, and sibling fields will still + // be executed. An execution which encounters errors will still result in a + // resolved Promise. + // + // Errors from sub-fields of a NonNull type may propagate to the top level, + // at which point we still log the error and null the parent field, which + // in this case is the entire response. + + try { + const { operation } = exeContext; + const result = executeOperation(exeContext, operation, rootValue); + + if ((0, _isPromise.isPromise)(result)) { + return result.then( + (data) => buildResponse(data, exeContext.errors), + (error) => { + exeContext.errors.push(error); + return buildResponse(null, exeContext.errors); + }, + ); + } + + return buildResponse(result, exeContext.errors); + } catch (error) { + exeContext.errors.push(error); + return buildResponse(null, exeContext.errors); + } +} +/** + * Also implements the "Executing requests" section of the GraphQL specification. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ + +function executeSync(args) { + const result = execute(args); // Assert that the execution was synchronous. + + if ((0, _isPromise.isPromise)(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + + return result; +} +/** + * Given a completed execution context and data, build the `{ errors, data }` + * response defined by the "Response" section of the GraphQL specification. + */ + +function buildResponse(data, errors) { + return errors.length === 0 + ? { + data, + } + : { + errors, + data, + }; +} +/** + * Essential assertions before executing to provide developer feedback for + * improper use of the GraphQL library. + * + * @internal + */ + +function assertValidExecutionArguments(schema, document, rawVariableValues) { + document || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for execution is invalid, throw an error. + + (0, _validate.assertValidSchema)(schema); // Variables, if provided, must be an object. + + rawVariableValues == null || + (0, _isObjectLike.isObjectLike)(rawVariableValues) || + (0, _devAssert.devAssert)( + false, + '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.', + ); +} +/** + * Constructs a ExecutionContext object from the arguments passed to + * execute, which we will pass throughout the other execution methods. + * + * Throws a GraphQLError if a valid execution context cannot be created. + * + * @internal + */ + +function buildExecutionContext(args) { + var _definition$name, _operation$variableDe; + + const { + schema, + document, + rootValue, + contextValue, + variableValues: rawVariableValues, + operationName, + fieldResolver, + typeResolver, + subscribeFieldResolver, + } = args; + let operation; + const fragments = Object.create(null); + + for (const definition of document.definitions) { + switch (definition.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + if (operationName == null) { + if (operation !== undefined) { + return [ + new _GraphQLError.GraphQLError( + 'Must provide operation name if query contains multiple operations.', + ), + ]; + } + + operation = definition; + } else if ( + ((_definition$name = definition.name) === null || + _definition$name === void 0 + ? void 0 + : _definition$name.value) === operationName + ) { + operation = definition; + } + + break; + + case _kinds.Kind.FRAGMENT_DEFINITION: + fragments[definition.name.value] = definition; + break; + + default: // ignore non-executable definitions + } + } + + if (!operation) { + if (operationName != null) { + return [ + new _GraphQLError.GraphQLError( + `Unknown operation named "${operationName}".`, + ), + ]; + } + + return [new _GraphQLError.GraphQLError('Must provide an operation.')]; + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const variableDefinitions = + (_operation$variableDe = operation.variableDefinitions) !== null && + _operation$variableDe !== void 0 + ? _operation$variableDe + : []; + const coercedVariableValues = (0, _values.getVariableValues)( + schema, + variableDefinitions, + rawVariableValues !== null && rawVariableValues !== void 0 + ? rawVariableValues + : {}, + { + maxErrors: 50, + }, + ); + + if (coercedVariableValues.errors) { + return coercedVariableValues.errors; + } + + return { + schema, + fragments, + rootValue, + contextValue, + operation, + variableValues: coercedVariableValues.coerced, + fieldResolver: + fieldResolver !== null && fieldResolver !== void 0 + ? fieldResolver + : defaultFieldResolver, + typeResolver: + typeResolver !== null && typeResolver !== void 0 + ? typeResolver + : defaultTypeResolver, + subscribeFieldResolver: + subscribeFieldResolver !== null && subscribeFieldResolver !== void 0 + ? subscribeFieldResolver + : defaultFieldResolver, + errors: [], + }; +} +/** + * Implements the "Executing operations" section of the spec. + */ + +function executeOperation(exeContext, operation, rootValue) { + const rootType = exeContext.schema.getRootType(operation.operation); + + if (rootType == null) { + throw new _GraphQLError.GraphQLError( + `Schema is not configured to execute ${operation.operation} operation.`, + { + nodes: operation, + }, + ); + } + + const rootFields = (0, _collectFields.collectFields)( + exeContext.schema, + exeContext.fragments, + exeContext.variableValues, + rootType, + operation.selectionSet, + ); + const path = undefined; + + switch (operation.operation) { + case _ast.OperationTypeNode.QUERY: + return executeFields(exeContext, rootType, rootValue, path, rootFields); + + case _ast.OperationTypeNode.MUTATION: + return executeFieldsSerially( + exeContext, + rootType, + rootValue, + path, + rootFields, + ); + + case _ast.OperationTypeNode.SUBSCRIPTION: + // TODO: deprecate `subscribe` and move all logic here + // Temporary solution until we finish merging execute and subscribe together + return executeFields(exeContext, rootType, rootValue, path, rootFields); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that must be executed serially. + */ + +function executeFieldsSerially( + exeContext, + parentType, + sourceValue, + path, + fields, +) { + return (0, _promiseReduce.promiseReduce)( + fields.entries(), + (results, [responseName, fieldNodes]) => { + const fieldPath = (0, _Path.addPath)(path, responseName, parentType.name); + const result = executeField( + exeContext, + parentType, + sourceValue, + fieldNodes, + fieldPath, + ); + + if (result === undefined) { + return results; + } + + if ((0, _isPromise.isPromise)(result)) { + return result.then((resolvedResult) => { + results[responseName] = resolvedResult; + return results; + }); + } + + results[responseName] = result; + return results; + }, + Object.create(null), + ); +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that may be executed in parallel. + */ + +function executeFields(exeContext, parentType, sourceValue, path, fields) { + const results = Object.create(null); + let containsPromise = false; + + for (const [responseName, fieldNodes] of fields.entries()) { + const fieldPath = (0, _Path.addPath)(path, responseName, parentType.name); + const result = executeField( + exeContext, + parentType, + sourceValue, + fieldNodes, + fieldPath, + ); + + if (result !== undefined) { + results[responseName] = result; + + if ((0, _isPromise.isPromise)(result)) { + containsPromise = true; + } + } + } // If there are no promises, we can just return the object + + if (!containsPromise) { + return results; + } // Otherwise, results is a map from field name to the result of resolving that + // field, which is possibly a promise. Return a promise that will return this + // same map, but with any promises replaced with the values they resolved to. + + return (0, _promiseForObject.promiseForObject)(results); +} +/** + * Implements the "Executing fields" section of the spec + * In particular, this function figures out the value that the field returns by + * calling its resolve function, then calls completeValue to complete promises, + * serialize scalars, or execute the sub-selection-set for objects. + */ + +function executeField(exeContext, parentType, source, fieldNodes, path) { + var _fieldDef$resolve; + + const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]); + + if (!fieldDef) { + return; + } + + const returnType = fieldDef.type; + const resolveFn = + (_fieldDef$resolve = fieldDef.resolve) !== null && + _fieldDef$resolve !== void 0 + ? _fieldDef$resolve + : exeContext.fieldResolver; + const info = buildResolveInfo( + exeContext, + fieldDef, + fieldNodes, + parentType, + path, + ); // Get the resolve function, regardless of if its result is normal or abrupt (error). + + try { + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + // TODO: find a way to memoize, in case this field is within a List type. + const args = (0, _values.getArgumentValues)( + fieldDef, + fieldNodes[0], + exeContext.variableValues, + ); // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + + const contextValue = exeContext.contextValue; + const result = resolveFn(source, args, contextValue, info); + let completed; + + if ((0, _isPromise.isPromise)(result)) { + completed = result.then((resolved) => + completeValue(exeContext, returnType, fieldNodes, info, path, resolved), + ); + } else { + completed = completeValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } + + if ((0, _isPromise.isPromise)(completed)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + return completed.then(undefined, (rawError) => { + const error = (0, _locatedError.locatedError)( + rawError, + fieldNodes, + (0, _Path.pathToArray)(path), + ); + return handleFieldError(error, returnType, exeContext); + }); + } + + return completed; + } catch (rawError) { + const error = (0, _locatedError.locatedError)( + rawError, + fieldNodes, + (0, _Path.pathToArray)(path), + ); + return handleFieldError(error, returnType, exeContext); + } +} +/** + * @internal + */ + +function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) { + // The resolve function's optional fourth argument is a collection of + // information about the current execution state. + return { + fieldName: fieldDef.name, + fieldNodes, + returnType: fieldDef.type, + parentType, + path, + schema: exeContext.schema, + fragments: exeContext.fragments, + rootValue: exeContext.rootValue, + operation: exeContext.operation, + variableValues: exeContext.variableValues, + }; +} + +function handleFieldError(error, returnType, exeContext) { + // If the field type is non-nullable, then it is resolved without any + // protection from errors, however it still properly locates the error. + if ((0, _definition.isNonNullType)(returnType)) { + throw error; + } // Otherwise, error protection is applied, logging the error and resolving + // a null value for this field if one is encountered. + + exeContext.errors.push(error); + return null; +} +/** + * Implements the instructions for completeValue as defined in the + * "Value Completion" section of the spec. + * + * If the field type is Non-Null, then this recursively completes the value + * for the inner type. It throws a field error if that completion returns null, + * as per the "Nullability" section of the spec. + * + * If the field type is a List, then this recursively completes the value + * for the inner type on each item in the list. + * + * If the field type is a Scalar or Enum, ensures the completed value is a legal + * value of the type by calling the `serialize` method of GraphQL type + * definition. + * + * If the field is an abstract type, determine the runtime type of the value + * and then complete based on that type + * + * Otherwise, the field type expects a sub-selection set, and will complete the + * value by executing all sub-selections. + */ + +function completeValue(exeContext, returnType, fieldNodes, info, path, result) { + // If result is an Error, throw a located error. + if (result instanceof Error) { + throw result; + } // If field type is NonNull, complete for inner type, and throw field error + // if result is null. + + if ((0, _definition.isNonNullType)(returnType)) { + const completed = completeValue( + exeContext, + returnType.ofType, + fieldNodes, + info, + path, + result, + ); + + if (completed === null) { + throw new Error( + `Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`, + ); + } + + return completed; + } // If result value is null or undefined then return null. + + if (result == null) { + return null; + } // If field type is List, complete each item in the list with the inner type + + if ((0, _definition.isListType)(returnType)) { + return completeListValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } // If field type is a leaf type, Scalar or Enum, serialize to a valid value, + // returning null if serialization is not possible. + + if ((0, _definition.isLeafType)(returnType)) { + return completeLeafValue(returnType, result); + } // If field type is an abstract type, Interface or Union, determine the + // runtime Object type and complete for that type. + + if ((0, _definition.isAbstractType)(returnType)) { + return completeAbstractValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } // If field type is Object, execute and complete all sub-selections. + + if ((0, _definition.isObjectType)(returnType)) { + return completeObjectValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } + /* c8 ignore next 6 */ + // Not reachable, all possible output types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Cannot complete value of unexpected output type: ' + + (0, _inspect.inspect)(returnType), + ); +} +/** + * Complete a list value by completing each item in the list with the + * inner type + */ + +function completeListValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + if (!(0, _isIterableObject.isIterableObject)(result)) { + throw new _GraphQLError.GraphQLError( + `Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`, + ); + } // This is specified as a simple map, however we're optimizing the path + // where the list contains no Promises by avoiding creating another Promise. + + const itemType = returnType.ofType; + let containsPromise = false; + const completedResults = Array.from(result, (item, index) => { + // No need to modify the info object containing the path, + // since from here on it is not ever accessed by resolver functions. + const itemPath = (0, _Path.addPath)(path, index, undefined); + + try { + let completedItem; + + if ((0, _isPromise.isPromise)(item)) { + completedItem = item.then((resolved) => + completeValue( + exeContext, + itemType, + fieldNodes, + info, + itemPath, + resolved, + ), + ); + } else { + completedItem = completeValue( + exeContext, + itemType, + fieldNodes, + info, + itemPath, + item, + ); + } + + if ((0, _isPromise.isPromise)(completedItem)) { + containsPromise = true; // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + + return completedItem.then(undefined, (rawError) => { + const error = (0, _locatedError.locatedError)( + rawError, + fieldNodes, + (0, _Path.pathToArray)(itemPath), + ); + return handleFieldError(error, itemType, exeContext); + }); + } + + return completedItem; + } catch (rawError) { + const error = (0, _locatedError.locatedError)( + rawError, + fieldNodes, + (0, _Path.pathToArray)(itemPath), + ); + return handleFieldError(error, itemType, exeContext); + } + }); + return containsPromise ? Promise.all(completedResults) : completedResults; +} +/** + * Complete a Scalar or Enum by serializing to a valid value, returning + * null if serialization is not possible. + */ + +function completeLeafValue(returnType, result) { + const serializedResult = returnType.serialize(result); + + if (serializedResult == null) { + throw new Error( + `Expected \`${(0, _inspect.inspect)(returnType)}.serialize(${(0, + _inspect.inspect)(result)})\` to ` + + `return non-nullable value, returned: ${(0, _inspect.inspect)( + serializedResult, + )}`, + ); + } + + return serializedResult; +} +/** + * Complete a value of an abstract type by determining the runtime object type + * of that value, then complete the value for that type. + */ + +function completeAbstractValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + var _returnType$resolveTy; + + const resolveTypeFn = + (_returnType$resolveTy = returnType.resolveType) !== null && + _returnType$resolveTy !== void 0 + ? _returnType$resolveTy + : exeContext.typeResolver; + const contextValue = exeContext.contextValue; + const runtimeType = resolveTypeFn(result, contextValue, info, returnType); + + if ((0, _isPromise.isPromise)(runtimeType)) { + return runtimeType.then((resolvedRuntimeType) => + completeObjectValue( + exeContext, + ensureValidRuntimeType( + resolvedRuntimeType, + exeContext, + returnType, + fieldNodes, + info, + result, + ), + fieldNodes, + info, + path, + result, + ), + ); + } + + return completeObjectValue( + exeContext, + ensureValidRuntimeType( + runtimeType, + exeContext, + returnType, + fieldNodes, + info, + result, + ), + fieldNodes, + info, + path, + result, + ); +} + +function ensureValidRuntimeType( + runtimeTypeName, + exeContext, + returnType, + fieldNodes, + info, + result, +) { + if (runtimeTypeName == null) { + throw new _GraphQLError.GraphQLError( + `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`, + fieldNodes, + ); + } // releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType` + // TODO: remove in 17.0.0 release + + if ((0, _definition.isObjectType)(runtimeTypeName)) { + throw new _GraphQLError.GraphQLError( + 'Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.', + ); + } + + if (typeof runtimeTypeName !== 'string') { + throw new _GraphQLError.GraphQLError( + `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` + + `value ${(0, _inspect.inspect)(result)}, received "${(0, + _inspect.inspect)(runtimeTypeName)}".`, + ); + } + + const runtimeType = exeContext.schema.getType(runtimeTypeName); + + if (runtimeType == null) { + throw new _GraphQLError.GraphQLError( + `Abstract type "${returnType.name}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`, + { + nodes: fieldNodes, + }, + ); + } + + if (!(0, _definition.isObjectType)(runtimeType)) { + throw new _GraphQLError.GraphQLError( + `Abstract type "${returnType.name}" was resolved to a non-object type "${runtimeTypeName}".`, + { + nodes: fieldNodes, + }, + ); + } + + if (!exeContext.schema.isSubType(returnType, runtimeType)) { + throw new _GraphQLError.GraphQLError( + `Runtime Object type "${runtimeType.name}" is not a possible type for "${returnType.name}".`, + { + nodes: fieldNodes, + }, + ); + } + + return runtimeType; +} +/** + * Complete an Object value by executing all sub-selections. + */ + +function completeObjectValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + // Collect sub-fields to execute to complete this value. + const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes); // If there is an isTypeOf predicate function, call it with the + // current result. If isTypeOf returns false, then raise an error rather + // than continuing execution. + + if (returnType.isTypeOf) { + const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info); + + if ((0, _isPromise.isPromise)(isTypeOf)) { + return isTypeOf.then((resolvedIsTypeOf) => { + if (!resolvedIsTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldNodes); + } + + return executeFields( + exeContext, + returnType, + result, + path, + subFieldNodes, + ); + }); + } + + if (!isTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldNodes); + } + } + + return executeFields(exeContext, returnType, result, path, subFieldNodes); +} + +function invalidReturnTypeError(returnType, result, fieldNodes) { + return new _GraphQLError.GraphQLError( + `Expected value of type "${returnType.name}" but got: ${(0, + _inspect.inspect)(result)}.`, + { + nodes: fieldNodes, + }, + ); +} +/** + * If a resolveType function is not given, then a default resolve behavior is + * used which attempts two strategies: + * + * First, See if the provided value has a `__typename` field defined, if so, use + * that value as name of the resolved type. + * + * Otherwise, test each possible type for the abstract type by calling + * isTypeOf for the object being coerced, returning the first type that matches. + */ + +const defaultTypeResolver = function (value, contextValue, info, abstractType) { + // First, look for `__typename`. + if ( + (0, _isObjectLike.isObjectLike)(value) && + typeof value.__typename === 'string' + ) { + return value.__typename; + } // Otherwise, test each possible type. + + const possibleTypes = info.schema.getPossibleTypes(abstractType); + const promisedIsTypeOfResults = []; + + for (let i = 0; i < possibleTypes.length; i++) { + const type = possibleTypes[i]; + + if (type.isTypeOf) { + const isTypeOfResult = type.isTypeOf(value, contextValue, info); + + if ((0, _isPromise.isPromise)(isTypeOfResult)) { + promisedIsTypeOfResults[i] = isTypeOfResult; + } else if (isTypeOfResult) { + return type.name; + } + } + } + + if (promisedIsTypeOfResults.length) { + return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => { + for (let i = 0; i < isTypeOfResults.length; i++) { + if (isTypeOfResults[i]) { + return possibleTypes[i].name; + } + } + }); + } +}; +/** + * If a resolve function is not given, then a default resolve behavior is used + * which takes the property of the source object of the same name as the field + * and returns it as the result, or if it's a function, returns the result + * of calling that function while passing along args and context value. + */ + +exports.defaultTypeResolver = defaultTypeResolver; + +const defaultFieldResolver = function (source, args, contextValue, info) { + // ensure source is a value for which property access is acceptable. + if ((0, _isObjectLike.isObjectLike)(source) || typeof source === 'function') { + const property = source[info.fieldName]; + + if (typeof property === 'function') { + return source[info.fieldName](args, contextValue, info); + } + + return property; + } +}; +/** + * This method looks up the field on the given type definition. + * It has special casing for the three introspection fields, + * __schema, __type and __typename. __typename is special because + * it can always be queried as a field, even in situations where no + * other fields are allowed, like on a Union. __schema and __type + * could get automatically added to the query type, but that would + * require mutating type definitions, which would cause issues. + * + * @internal + */ + +exports.defaultFieldResolver = defaultFieldResolver; + +function getFieldDef(schema, parentType, fieldNode) { + const fieldName = fieldNode.name.value; + + if ( + fieldName === _introspection.SchemaMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.SchemaMetaFieldDef; + } else if ( + fieldName === _introspection.TypeMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.TypeMetaFieldDef; + } else if (fieldName === _introspection.TypeNameMetaFieldDef.name) { + return _introspection.TypeNameMetaFieldDef; + } + + return parentType.getFields()[fieldName]; +} + + +/***/ }), + +/***/ 40005: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "createSourceEventStream", ({ + enumerable: true, + get: function () { + return _subscribe.createSourceEventStream; + }, +})); +Object.defineProperty(exports, "defaultFieldResolver", ({ + enumerable: true, + get: function () { + return _execute.defaultFieldResolver; + }, +})); +Object.defineProperty(exports, "defaultTypeResolver", ({ + enumerable: true, + get: function () { + return _execute.defaultTypeResolver; + }, +})); +Object.defineProperty(exports, "execute", ({ + enumerable: true, + get: function () { + return _execute.execute; + }, +})); +Object.defineProperty(exports, "executeSync", ({ + enumerable: true, + get: function () { + return _execute.executeSync; + }, +})); +Object.defineProperty(exports, "getArgumentValues", ({ + enumerable: true, + get: function () { + return _values.getArgumentValues; + }, +})); +Object.defineProperty(exports, "getDirectiveValues", ({ + enumerable: true, + get: function () { + return _values.getDirectiveValues; + }, +})); +Object.defineProperty(exports, "getVariableValues", ({ + enumerable: true, + get: function () { + return _values.getVariableValues; + }, +})); +Object.defineProperty(exports, "responsePathAsArray", ({ + enumerable: true, + get: function () { + return _Path.pathToArray; + }, +})); +Object.defineProperty(exports, "subscribe", ({ + enumerable: true, + get: function () { + return _subscribe.subscribe; + }, +})); + +var _Path = __nccwpck_require__(80333); + +var _execute = __nccwpck_require__(11184); + +var _subscribe = __nccwpck_require__(90965); + +var _values = __nccwpck_require__(30848); + + +/***/ }), + +/***/ 57061: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.mapAsyncIterator = mapAsyncIterator; + +/** + * Given an AsyncIterable and a callback function, return an AsyncIterator + * which produces values mapped via calling the callback function. + */ +function mapAsyncIterator(iterable, callback) { + const iterator = iterable[Symbol.asyncIterator](); + + async function mapResult(result) { + if (result.done) { + return result; + } + + try { + return { + value: await callback(result.value), + done: false, + }; + } catch (error) { + /* c8 ignore start */ + // FIXME: add test case + if (typeof iterator.return === 'function') { + try { + await iterator.return(); + } catch (_e) { + /* ignore error */ + } + } + + throw error; + /* c8 ignore stop */ + } + } + + return { + async next() { + return mapResult(await iterator.next()); + }, + + async return() { + // If iterator.return() does not exist, then type R must be undefined. + return typeof iterator.return === 'function' + ? mapResult(await iterator.return()) + : { + value: undefined, + done: true, + }; + }, + + async throw(error) { + if (typeof iterator.throw === 'function') { + return mapResult(await iterator.throw(error)); + } + + throw error; + }, + + [Symbol.asyncIterator]() { + return this; + }, + }; +} + + +/***/ }), + +/***/ 90965: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.createSourceEventStream = createSourceEventStream; +exports.subscribe = subscribe; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _isAsyncIterable = __nccwpck_require__(96607); + +var _Path = __nccwpck_require__(80333); + +var _GraphQLError = __nccwpck_require__(66807); + +var _locatedError = __nccwpck_require__(61317); + +var _collectFields = __nccwpck_require__(54808); + +var _execute = __nccwpck_require__(11184); + +var _mapAsyncIterator = __nccwpck_require__(57061); + +var _values = __nccwpck_require__(30848); + +/** + * Implements the "Subscribe" algorithm described in the GraphQL specification. + * + * Returns a Promise which resolves to either an AsyncIterator (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to an AsyncIterator, which + * yields a stream of ExecutionResults representing the response stream. + * + * Accepts either an object with named arguments, or individual arguments. + */ +async function subscribe(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0, _devAssert.devAssert)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const resultOrStream = await createSourceEventStream(args); + + if (!(0, _isAsyncIterable.isAsyncIterable)(resultOrStream)) { + return resultOrStream; + } // For each payload yielded from a subscription, map it over the normal + // GraphQL `execute` function, with `payload` as the rootValue. + // This implements the "MapSourceToResponseEvent" algorithm described in + // the GraphQL specification. The `execute` function provides the + // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the + // "ExecuteQuery" algorithm, for which `execute` is also used. + + const mapSourceToResponse = (payload) => + (0, _execute.execute)({ ...args, rootValue: payload }); // Map every source value to a ExecutionResult value as described above. + + return (0, _mapAsyncIterator.mapAsyncIterator)( + resultOrStream, + mapSourceToResponse, + ); +} + +function toNormalizedArgs(args) { + const firstArg = args[0]; + + if (firstArg && 'document' in firstArg) { + return firstArg; + } + + return { + schema: firstArg, + // FIXME: when underlying TS bug fixed, see https://github.com/microsoft/TypeScript/issues/31613 + document: args[1], + rootValue: args[2], + contextValue: args[3], + variableValues: args[4], + operationName: args[5], + subscribeFieldResolver: args[6], + }; +} +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns a Promise which resolves to either an AsyncIterable (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to the AsyncIterable for the + * event stream returned by the resolver. + * + * A Source Event Stream represents a sequence of events, each of which triggers + * a GraphQL execution for that event. + * + * This may be useful when hosting the stateful subscription service in a + * different process or machine than the stateless GraphQL execution engine, + * or otherwise separating these two steps. For more on this, see the + * "Supporting Subscriptions at Scale" information in the GraphQL specification. + */ + +async function createSourceEventStream(...rawArgs) { + const args = toNormalizedArgs(rawArgs); + const { schema, document, variableValues } = args; // If arguments are missing or incorrectly typed, this is an internal + // developer mistake which should throw an early error. + + (0, _execute.assertValidExecutionArguments)(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + + const exeContext = (0, _execute.buildExecutionContext)(args); // Return early errors if execution context failed. + + if (!('schema' in exeContext)) { + return { + errors: exeContext, + }; + } + + try { + const eventStream = await executeSubscription(exeContext); // Assert field returned an event stream, otherwise yield an error. + + if (!(0, _isAsyncIterable.isAsyncIterable)(eventStream)) { + throw new Error( + 'Subscription field must return Async Iterable. ' + + `Received: ${(0, _inspect.inspect)(eventStream)}.`, + ); + } + + return eventStream; + } catch (error) { + // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data. + // Otherwise treat the error as a system-class error and re-throw it. + if (error instanceof _GraphQLError.GraphQLError) { + return { + errors: [error], + }; + } + + throw error; + } +} + +async function executeSubscription(exeContext) { + const { schema, fragments, operation, variableValues, rootValue } = + exeContext; + const rootType = schema.getSubscriptionType(); + + if (rootType == null) { + throw new _GraphQLError.GraphQLError( + 'Schema is not configured to execute subscription operation.', + { + nodes: operation, + }, + ); + } + + const rootFields = (0, _collectFields.collectFields)( + schema, + fragments, + variableValues, + rootType, + operation.selectionSet, + ); + const [responseName, fieldNodes] = [...rootFields.entries()][0]; + const fieldDef = (0, _execute.getFieldDef)(schema, rootType, fieldNodes[0]); + + if (!fieldDef) { + const fieldName = fieldNodes[0].name.value; + throw new _GraphQLError.GraphQLError( + `The subscription field "${fieldName}" is not defined.`, + { + nodes: fieldNodes, + }, + ); + } + + const path = (0, _Path.addPath)(undefined, responseName, rootType.name); + const info = (0, _execute.buildResolveInfo)( + exeContext, + fieldDef, + fieldNodes, + rootType, + path, + ); + + try { + var _fieldDef$subscribe; + + // Implements the "ResolveFieldEventStream" algorithm from GraphQL specification. + // It differs from "ResolveFieldValue" due to providing a different `resolveFn`. + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + const args = (0, _values.getArgumentValues)( + fieldDef, + fieldNodes[0], + variableValues, + ); // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + + const contextValue = exeContext.contextValue; // Call the `subscribe()` resolver or the default resolver to produce an + // AsyncIterable yielding raw payloads. + + const resolveFn = + (_fieldDef$subscribe = fieldDef.subscribe) !== null && + _fieldDef$subscribe !== void 0 + ? _fieldDef$subscribe + : exeContext.subscribeFieldResolver; + const eventStream = await resolveFn(rootValue, args, contextValue, info); + + if (eventStream instanceof Error) { + throw eventStream; + } + + return eventStream; + } catch (error) { + throw (0, _locatedError.locatedError)( + error, + fieldNodes, + (0, _Path.pathToArray)(path), + ); + } +} + + +/***/ }), + +/***/ 30848: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getArgumentValues = getArgumentValues; +exports.getDirectiveValues = getDirectiveValues; +exports.getVariableValues = getVariableValues; + +var _inspect = __nccwpck_require__(17819); + +var _keyMap = __nccwpck_require__(35053); + +var _printPathArray = __nccwpck_require__(49802); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _coerceInputValue = __nccwpck_require__(71623); + +var _typeFromAST = __nccwpck_require__(73461); + +var _valueFromAST = __nccwpck_require__(81172); + +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getVariableValues(schema, varDefNodes, inputs, options) { + const errors = []; + const maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors; + + try { + const coerced = coerceVariableValues( + schema, + varDefNodes, + inputs, + (error) => { + if (maxErrors != null && errors.length >= maxErrors) { + throw new _GraphQLError.GraphQLError( + 'Too many errors processing variables, error limit reached. Execution aborted.', + ); + } + + errors.push(error); + }, + ); + + if (errors.length === 0) { + return { + coerced, + }; + } + } catch (error) { + errors.push(error); + } + + return { + errors, + }; +} + +function coerceVariableValues(schema, varDefNodes, inputs, onError) { + const coercedValues = {}; + + for (const varDefNode of varDefNodes) { + const varName = varDefNode.variable.name.value; + const varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type); + + if (!(0, _definition.isInputType)(varType)) { + // Must use input types for variables. This should be caught during + // validation, however is checked again here for safety. + const varTypeStr = (0, _printer.print)(varDefNode.type); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, + { + nodes: varDefNode.type, + }, + ), + ); + continue; + } + + if (!hasOwnProperty(inputs, varName)) { + if (varDefNode.defaultValue) { + coercedValues[varName] = (0, _valueFromAST.valueFromAST)( + varDefNode.defaultValue, + varType, + ); + } else if ((0, _definition.isNonNullType)(varType)) { + const varTypeStr = (0, _inspect.inspect)(varType); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, + { + nodes: varDefNode, + }, + ), + ); + } + + continue; + } + + const value = inputs[varName]; + + if (value === null && (0, _definition.isNonNullType)(varType)) { + const varTypeStr = (0, _inspect.inspect)(varType); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, + { + nodes: varDefNode, + }, + ), + ); + continue; + } + + coercedValues[varName] = (0, _coerceInputValue.coerceInputValue)( + value, + varType, + (path, invalidValue, error) => { + let prefix = + `Variable "$${varName}" got invalid value ` + + (0, _inspect.inspect)(invalidValue); + + if (path.length > 0) { + prefix += ` at "${varName}${(0, _printPathArray.printPathArray)( + path, + )}"`; + } + + onError( + new _GraphQLError.GraphQLError(prefix + '; ' + error.message, { + nodes: varDefNode, + originalError: error.originalError, + }), + ); + }, + ); + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getArgumentValues(def, node, variableValues) { + var _node$arguments; + + const coercedValues = {}; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 + ? _node$arguments + : []; + const argNodeMap = (0, _keyMap.keyMap)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const argDef of def.args) { + const name = argDef.name; + const argType = argDef.type; + const argumentNode = argNodeMap[name]; + + if (!argumentNode) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of required type "${(0, _inspect.inspect)( + argType, + )}" ` + 'was not provided.', + { + nodes: node, + }, + ); + } + + continue; + } + + const valueNode = argumentNode.value; + let isNull = valueNode.kind === _kinds.Kind.NULL; + + if (valueNode.kind === _kinds.Kind.VARIABLE) { + const variableName = valueNode.name.value; + + if ( + variableValues == null || + !hasOwnProperty(variableValues, variableName) + ) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of required type "${(0, _inspect.inspect)( + argType, + )}" ` + + `was provided the variable "$${variableName}" which was not provided a runtime value.`, + { + nodes: valueNode, + }, + ); + } + + continue; + } + + isNull = variableValues[variableName] == null; + } + + if (isNull && (0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of non-null type "${(0, _inspect.inspect)( + argType, + )}" ` + 'must not be null.', + { + nodes: valueNode, + }, + ); + } + + const coercedValue = (0, _valueFromAST.valueFromAST)( + valueNode, + argType, + variableValues, + ); + + if (coercedValue === undefined) { + // Note: ValuesOfCorrectTypeRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + throw new _GraphQLError.GraphQLError( + `Argument "${name}" has invalid value ${(0, _printer.print)( + valueNode, + )}.`, + { + nodes: valueNode, + }, + ); + } + + coercedValues[name] = coercedValue; + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getDirectiveValues(directiveDef, node, variableValues) { + var _node$directives; + + const directiveNode = + (_node$directives = node.directives) === null || _node$directives === void 0 + ? void 0 + : _node$directives.find( + (directive) => directive.name.value === directiveDef.name, + ); + + if (directiveNode) { + return getArgumentValues(directiveDef, directiveNode, variableValues); + } +} + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + +/***/ }), + +/***/ 95063: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.graphql = graphql; +exports.graphqlSync = graphqlSync; + +var _devAssert = __nccwpck_require__(60645); + +var _isPromise = __nccwpck_require__(68362); + +var _parser = __nccwpck_require__(39927); + +var _validate = __nccwpck_require__(95929); + +var _validate2 = __nccwpck_require__(17329); + +var _execute = __nccwpck_require__(11184); + +function graphql(args) { + // Always return a Promise for a consistent API. + return new Promise((resolve) => resolve(graphqlImpl(args))); +} +/** + * The graphqlSync function also fulfills GraphQL operations by parsing, + * validating, and executing a GraphQL document along side a GraphQL schema. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ + +function graphqlSync(args) { + const result = graphqlImpl(args); // Assert that the execution was synchronous. + + if ((0, _isPromise.isPromise)(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + + return result; +} + +function graphqlImpl(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0, _devAssert.devAssert)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { + schema, + source, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + } = args; // Validate Schema + + const schemaValidationErrors = (0, _validate.validateSchema)(schema); + + if (schemaValidationErrors.length > 0) { + return { + errors: schemaValidationErrors, + }; + } // Parse + + let document; + + try { + document = (0, _parser.parse)(source); + } catch (syntaxError) { + return { + errors: [syntaxError], + }; + } // Validate + + const validationErrors = (0, _validate2.validate)(schema, document); + + if (validationErrors.length > 0) { + return { + errors: validationErrors, + }; + } // Execute + + return (0, _execute.execute)({ + schema, + document, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + }); +} + + +/***/ }), + +/***/ 24916: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "BREAK", ({ + enumerable: true, + get: function () { + return _index2.BREAK; + }, +})); +Object.defineProperty(exports, "BreakingChangeType", ({ + enumerable: true, + get: function () { + return _index6.BreakingChangeType; + }, +})); +Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", ({ + enumerable: true, + get: function () { + return _index.DEFAULT_DEPRECATION_REASON; + }, +})); +Object.defineProperty(exports, "DangerousChangeType", ({ + enumerable: true, + get: function () { + return _index6.DangerousChangeType; + }, +})); +Object.defineProperty(exports, "DirectiveLocation", ({ + enumerable: true, + get: function () { + return _index2.DirectiveLocation; + }, +})); +Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ + enumerable: true, + get: function () { + return _index4.ExecutableDefinitionsRule; + }, +})); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _index4.FieldsOnCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", ({ + enumerable: true, + get: function () { + return _index4.FragmentsOnCompositeTypesRule; + }, +})); +Object.defineProperty(exports, "GRAPHQL_MAX_INT", ({ + enumerable: true, + get: function () { + return _index.GRAPHQL_MAX_INT; + }, +})); +Object.defineProperty(exports, "GRAPHQL_MIN_INT", ({ + enumerable: true, + get: function () { + return _index.GRAPHQL_MIN_INT; + }, +})); +Object.defineProperty(exports, "GraphQLBoolean", ({ + enumerable: true, + get: function () { + return _index.GraphQLBoolean; + }, +})); +Object.defineProperty(exports, "GraphQLDeprecatedDirective", ({ + enumerable: true, + get: function () { + return _index.GraphQLDeprecatedDirective; + }, +})); +Object.defineProperty(exports, "GraphQLDirective", ({ + enumerable: true, + get: function () { + return _index.GraphQLDirective; + }, +})); +Object.defineProperty(exports, "GraphQLEnumType", ({ + enumerable: true, + get: function () { + return _index.GraphQLEnumType; + }, +})); +Object.defineProperty(exports, "GraphQLError", ({ + enumerable: true, + get: function () { + return _index5.GraphQLError; + }, +})); +Object.defineProperty(exports, "GraphQLFloat", ({ + enumerable: true, + get: function () { + return _index.GraphQLFloat; + }, +})); +Object.defineProperty(exports, "GraphQLID", ({ + enumerable: true, + get: function () { + return _index.GraphQLID; + }, +})); +Object.defineProperty(exports, "GraphQLIncludeDirective", ({ + enumerable: true, + get: function () { + return _index.GraphQLIncludeDirective; + }, +})); +Object.defineProperty(exports, "GraphQLInputObjectType", ({ + enumerable: true, + get: function () { + return _index.GraphQLInputObjectType; + }, +})); +Object.defineProperty(exports, "GraphQLInt", ({ + enumerable: true, + get: function () { + return _index.GraphQLInt; + }, +})); +Object.defineProperty(exports, "GraphQLInterfaceType", ({ + enumerable: true, + get: function () { + return _index.GraphQLInterfaceType; + }, +})); +Object.defineProperty(exports, "GraphQLList", ({ + enumerable: true, + get: function () { + return _index.GraphQLList; + }, +})); +Object.defineProperty(exports, "GraphQLNonNull", ({ + enumerable: true, + get: function () { + return _index.GraphQLNonNull; + }, +})); +Object.defineProperty(exports, "GraphQLObjectType", ({ + enumerable: true, + get: function () { + return _index.GraphQLObjectType; + }, +})); +Object.defineProperty(exports, "GraphQLScalarType", ({ + enumerable: true, + get: function () { + return _index.GraphQLScalarType; + }, +})); +Object.defineProperty(exports, "GraphQLSchema", ({ + enumerable: true, + get: function () { + return _index.GraphQLSchema; + }, +})); +Object.defineProperty(exports, "GraphQLSkipDirective", ({ + enumerable: true, + get: function () { + return _index.GraphQLSkipDirective; + }, +})); +Object.defineProperty(exports, "GraphQLSpecifiedByDirective", ({ + enumerable: true, + get: function () { + return _index.GraphQLSpecifiedByDirective; + }, +})); +Object.defineProperty(exports, "GraphQLString", ({ + enumerable: true, + get: function () { + return _index.GraphQLString; + }, +})); +Object.defineProperty(exports, "GraphQLUnionType", ({ + enumerable: true, + get: function () { + return _index.GraphQLUnionType; + }, +})); +Object.defineProperty(exports, "Kind", ({ + enumerable: true, + get: function () { + return _index2.Kind; + }, +})); +Object.defineProperty(exports, "KnownArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _index4.KnownArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownDirectivesRule", ({ + enumerable: true, + get: function () { + return _index4.KnownDirectivesRule; + }, +})); +Object.defineProperty(exports, "KnownFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _index4.KnownFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownTypeNamesRule", ({ + enumerable: true, + get: function () { + return _index4.KnownTypeNamesRule; + }, +})); +Object.defineProperty(exports, "Lexer", ({ + enumerable: true, + get: function () { + return _index2.Lexer; + }, +})); +Object.defineProperty(exports, "Location", ({ + enumerable: true, + get: function () { + return _index2.Location; + }, +})); +Object.defineProperty(exports, "LoneAnonymousOperationRule", ({ + enumerable: true, + get: function () { + return _index4.LoneAnonymousOperationRule; + }, +})); +Object.defineProperty(exports, "LoneSchemaDefinitionRule", ({ + enumerable: true, + get: function () { + return _index4.LoneSchemaDefinitionRule; + }, +})); +Object.defineProperty(exports, "NoDeprecatedCustomRule", ({ + enumerable: true, + get: function () { + return _index4.NoDeprecatedCustomRule; + }, +})); +Object.defineProperty(exports, "NoFragmentCyclesRule", ({ + enumerable: true, + get: function () { + return _index4.NoFragmentCyclesRule; + }, +})); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", ({ + enumerable: true, + get: function () { + return _index4.NoSchemaIntrospectionCustomRule; + }, +})); +Object.defineProperty(exports, "NoUndefinedVariablesRule", ({ + enumerable: true, + get: function () { + return _index4.NoUndefinedVariablesRule; + }, +})); +Object.defineProperty(exports, "NoUnusedFragmentsRule", ({ + enumerable: true, + get: function () { + return _index4.NoUnusedFragmentsRule; + }, +})); +Object.defineProperty(exports, "NoUnusedVariablesRule", ({ + enumerable: true, + get: function () { + return _index4.NoUnusedVariablesRule; + }, +})); +Object.defineProperty(exports, "OperationTypeNode", ({ + enumerable: true, + get: function () { + return _index2.OperationTypeNode; + }, +})); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", ({ + enumerable: true, + get: function () { + return _index4.OverlappingFieldsCanBeMergedRule; + }, +})); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", ({ + enumerable: true, + get: function () { + return _index4.PossibleFragmentSpreadsRule; + }, +})); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", ({ + enumerable: true, + get: function () { + return _index4.PossibleTypeExtensionsRule; + }, +})); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", ({ + enumerable: true, + get: function () { + return _index4.ProvidedRequiredArgumentsRule; + }, +})); +Object.defineProperty(exports, "ScalarLeafsRule", ({ + enumerable: true, + get: function () { + return _index4.ScalarLeafsRule; + }, +})); +Object.defineProperty(exports, "SchemaMetaFieldDef", ({ + enumerable: true, + get: function () { + return _index.SchemaMetaFieldDef; + }, +})); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ + enumerable: true, + get: function () { + return _index4.SingleFieldSubscriptionsRule; + }, +})); +Object.defineProperty(exports, "Source", ({ + enumerable: true, + get: function () { + return _index2.Source; + }, +})); +Object.defineProperty(exports, "Token", ({ + enumerable: true, + get: function () { + return _index2.Token; + }, +})); +Object.defineProperty(exports, "TokenKind", ({ + enumerable: true, + get: function () { + return _index2.TokenKind; + }, +})); +Object.defineProperty(exports, "TypeInfo", ({ + enumerable: true, + get: function () { + return _index6.TypeInfo; + }, +})); +Object.defineProperty(exports, "TypeKind", ({ + enumerable: true, + get: function () { + return _index.TypeKind; + }, +})); +Object.defineProperty(exports, "TypeMetaFieldDef", ({ + enumerable: true, + get: function () { + return _index.TypeMetaFieldDef; + }, +})); +Object.defineProperty(exports, "TypeNameMetaFieldDef", ({ + enumerable: true, + get: function () { + return _index.TypeNameMetaFieldDef; + }, +})); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueArgumentDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueDirectiveNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueDirectivesPerLocationRule; + }, +})); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueEnumValueNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueFieldDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueInputFieldNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueOperationNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationTypesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueOperationTypesRule; + }, +})); +Object.defineProperty(exports, "UniqueTypeNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueTypeNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueVariableNamesRule", ({ + enumerable: true, + get: function () { + return _index4.UniqueVariableNamesRule; + }, +})); +Object.defineProperty(exports, "ValidationContext", ({ + enumerable: true, + get: function () { + return _index4.ValidationContext; + }, +})); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _index4.ValuesOfCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "VariablesAreInputTypesRule", ({ + enumerable: true, + get: function () { + return _index4.VariablesAreInputTypesRule; + }, +})); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", ({ + enumerable: true, + get: function () { + return _index4.VariablesInAllowedPositionRule; + }, +})); +Object.defineProperty(exports, "__Directive", ({ + enumerable: true, + get: function () { + return _index.__Directive; + }, +})); +Object.defineProperty(exports, "__DirectiveLocation", ({ + enumerable: true, + get: function () { + return _index.__DirectiveLocation; + }, +})); +Object.defineProperty(exports, "__EnumValue", ({ + enumerable: true, + get: function () { + return _index.__EnumValue; + }, +})); +Object.defineProperty(exports, "__Field", ({ + enumerable: true, + get: function () { + return _index.__Field; + }, +})); +Object.defineProperty(exports, "__InputValue", ({ + enumerable: true, + get: function () { + return _index.__InputValue; + }, +})); +Object.defineProperty(exports, "__Schema", ({ + enumerable: true, + get: function () { + return _index.__Schema; + }, +})); +Object.defineProperty(exports, "__Type", ({ + enumerable: true, + get: function () { + return _index.__Type; + }, +})); +Object.defineProperty(exports, "__TypeKind", ({ + enumerable: true, + get: function () { + return _index.__TypeKind; + }, +})); +Object.defineProperty(exports, "assertAbstractType", ({ + enumerable: true, + get: function () { + return _index.assertAbstractType; + }, +})); +Object.defineProperty(exports, "assertCompositeType", ({ + enumerable: true, + get: function () { + return _index.assertCompositeType; + }, +})); +Object.defineProperty(exports, "assertDirective", ({ + enumerable: true, + get: function () { + return _index.assertDirective; + }, +})); +Object.defineProperty(exports, "assertEnumType", ({ + enumerable: true, + get: function () { + return _index.assertEnumType; + }, +})); +Object.defineProperty(exports, "assertEnumValueName", ({ + enumerable: true, + get: function () { + return _index.assertEnumValueName; + }, +})); +Object.defineProperty(exports, "assertInputObjectType", ({ + enumerable: true, + get: function () { + return _index.assertInputObjectType; + }, +})); +Object.defineProperty(exports, "assertInputType", ({ + enumerable: true, + get: function () { + return _index.assertInputType; + }, +})); +Object.defineProperty(exports, "assertInterfaceType", ({ + enumerable: true, + get: function () { + return _index.assertInterfaceType; + }, +})); +Object.defineProperty(exports, "assertLeafType", ({ + enumerable: true, + get: function () { + return _index.assertLeafType; + }, +})); +Object.defineProperty(exports, "assertListType", ({ + enumerable: true, + get: function () { + return _index.assertListType; + }, +})); +Object.defineProperty(exports, "assertName", ({ + enumerable: true, + get: function () { + return _index.assertName; + }, +})); +Object.defineProperty(exports, "assertNamedType", ({ + enumerable: true, + get: function () { + return _index.assertNamedType; + }, +})); +Object.defineProperty(exports, "assertNonNullType", ({ + enumerable: true, + get: function () { + return _index.assertNonNullType; + }, +})); +Object.defineProperty(exports, "assertNullableType", ({ + enumerable: true, + get: function () { + return _index.assertNullableType; + }, +})); +Object.defineProperty(exports, "assertObjectType", ({ + enumerable: true, + get: function () { + return _index.assertObjectType; + }, +})); +Object.defineProperty(exports, "assertOutputType", ({ + enumerable: true, + get: function () { + return _index.assertOutputType; + }, +})); +Object.defineProperty(exports, "assertScalarType", ({ + enumerable: true, + get: function () { + return _index.assertScalarType; + }, +})); +Object.defineProperty(exports, "assertSchema", ({ + enumerable: true, + get: function () { + return _index.assertSchema; + }, +})); +Object.defineProperty(exports, "assertType", ({ + enumerable: true, + get: function () { + return _index.assertType; + }, +})); +Object.defineProperty(exports, "assertUnionType", ({ + enumerable: true, + get: function () { + return _index.assertUnionType; + }, +})); +Object.defineProperty(exports, "assertValidName", ({ + enumerable: true, + get: function () { + return _index6.assertValidName; + }, +})); +Object.defineProperty(exports, "assertValidSchema", ({ + enumerable: true, + get: function () { + return _index.assertValidSchema; + }, +})); +Object.defineProperty(exports, "assertWrappingType", ({ + enumerable: true, + get: function () { + return _index.assertWrappingType; + }, +})); +Object.defineProperty(exports, "astFromValue", ({ + enumerable: true, + get: function () { + return _index6.astFromValue; + }, +})); +Object.defineProperty(exports, "buildASTSchema", ({ + enumerable: true, + get: function () { + return _index6.buildASTSchema; + }, +})); +Object.defineProperty(exports, "buildClientSchema", ({ + enumerable: true, + get: function () { + return _index6.buildClientSchema; + }, +})); +Object.defineProperty(exports, "buildSchema", ({ + enumerable: true, + get: function () { + return _index6.buildSchema; + }, +})); +Object.defineProperty(exports, "coerceInputValue", ({ + enumerable: true, + get: function () { + return _index6.coerceInputValue; + }, +})); +Object.defineProperty(exports, "concatAST", ({ + enumerable: true, + get: function () { + return _index6.concatAST; + }, +})); +Object.defineProperty(exports, "createSourceEventStream", ({ + enumerable: true, + get: function () { + return _index3.createSourceEventStream; + }, +})); +Object.defineProperty(exports, "defaultFieldResolver", ({ + enumerable: true, + get: function () { + return _index3.defaultFieldResolver; + }, +})); +Object.defineProperty(exports, "defaultTypeResolver", ({ + enumerable: true, + get: function () { + return _index3.defaultTypeResolver; + }, +})); +Object.defineProperty(exports, "doTypesOverlap", ({ + enumerable: true, + get: function () { + return _index6.doTypesOverlap; + }, +})); +Object.defineProperty(exports, "execute", ({ + enumerable: true, + get: function () { + return _index3.execute; + }, +})); +Object.defineProperty(exports, "executeSync", ({ + enumerable: true, + get: function () { + return _index3.executeSync; + }, +})); +Object.defineProperty(exports, "extendSchema", ({ + enumerable: true, + get: function () { + return _index6.extendSchema; + }, +})); +Object.defineProperty(exports, "findBreakingChanges", ({ + enumerable: true, + get: function () { + return _index6.findBreakingChanges; + }, +})); +Object.defineProperty(exports, "findDangerousChanges", ({ + enumerable: true, + get: function () { + return _index6.findDangerousChanges; + }, +})); +Object.defineProperty(exports, "formatError", ({ + enumerable: true, + get: function () { + return _index5.formatError; + }, +})); +Object.defineProperty(exports, "getArgumentValues", ({ + enumerable: true, + get: function () { + return _index3.getArgumentValues; + }, +})); +Object.defineProperty(exports, "getDirectiveValues", ({ + enumerable: true, + get: function () { + return _index3.getDirectiveValues; + }, +})); +Object.defineProperty(exports, "getEnterLeaveForKind", ({ + enumerable: true, + get: function () { + return _index2.getEnterLeaveForKind; + }, +})); +Object.defineProperty(exports, "getIntrospectionQuery", ({ + enumerable: true, + get: function () { + return _index6.getIntrospectionQuery; + }, +})); +Object.defineProperty(exports, "getLocation", ({ + enumerable: true, + get: function () { + return _index2.getLocation; + }, +})); +Object.defineProperty(exports, "getNamedType", ({ + enumerable: true, + get: function () { + return _index.getNamedType; + }, +})); +Object.defineProperty(exports, "getNullableType", ({ + enumerable: true, + get: function () { + return _index.getNullableType; + }, +})); +Object.defineProperty(exports, "getOperationAST", ({ + enumerable: true, + get: function () { + return _index6.getOperationAST; + }, +})); +Object.defineProperty(exports, "getOperationRootType", ({ + enumerable: true, + get: function () { + return _index6.getOperationRootType; + }, +})); +Object.defineProperty(exports, "getVariableValues", ({ + enumerable: true, + get: function () { + return _index3.getVariableValues; + }, +})); +Object.defineProperty(exports, "getVisitFn", ({ + enumerable: true, + get: function () { + return _index2.getVisitFn; + }, +})); +Object.defineProperty(exports, "graphql", ({ + enumerable: true, + get: function () { + return _graphql.graphql; + }, +})); +Object.defineProperty(exports, "graphqlSync", ({ + enumerable: true, + get: function () { + return _graphql.graphqlSync; + }, +})); +Object.defineProperty(exports, "introspectionFromSchema", ({ + enumerable: true, + get: function () { + return _index6.introspectionFromSchema; + }, +})); +Object.defineProperty(exports, "introspectionTypes", ({ + enumerable: true, + get: function () { + return _index.introspectionTypes; + }, +})); +Object.defineProperty(exports, "isAbstractType", ({ + enumerable: true, + get: function () { + return _index.isAbstractType; + }, +})); +Object.defineProperty(exports, "isCompositeType", ({ + enumerable: true, + get: function () { + return _index.isCompositeType; + }, +})); +Object.defineProperty(exports, "isConstValueNode", ({ + enumerable: true, + get: function () { + return _index2.isConstValueNode; + }, +})); +Object.defineProperty(exports, "isDefinitionNode", ({ + enumerable: true, + get: function () { + return _index2.isDefinitionNode; + }, +})); +Object.defineProperty(exports, "isDirective", ({ + enumerable: true, + get: function () { + return _index.isDirective; + }, +})); +Object.defineProperty(exports, "isEnumType", ({ + enumerable: true, + get: function () { + return _index.isEnumType; + }, +})); +Object.defineProperty(exports, "isEqualType", ({ + enumerable: true, + get: function () { + return _index6.isEqualType; + }, +})); +Object.defineProperty(exports, "isExecutableDefinitionNode", ({ + enumerable: true, + get: function () { + return _index2.isExecutableDefinitionNode; + }, +})); +Object.defineProperty(exports, "isInputObjectType", ({ + enumerable: true, + get: function () { + return _index.isInputObjectType; + }, +})); +Object.defineProperty(exports, "isInputType", ({ + enumerable: true, + get: function () { + return _index.isInputType; + }, +})); +Object.defineProperty(exports, "isInterfaceType", ({ + enumerable: true, + get: function () { + return _index.isInterfaceType; + }, +})); +Object.defineProperty(exports, "isIntrospectionType", ({ + enumerable: true, + get: function () { + return _index.isIntrospectionType; + }, +})); +Object.defineProperty(exports, "isLeafType", ({ + enumerable: true, + get: function () { + return _index.isLeafType; + }, +})); +Object.defineProperty(exports, "isListType", ({ + enumerable: true, + get: function () { + return _index.isListType; + }, +})); +Object.defineProperty(exports, "isNamedType", ({ + enumerable: true, + get: function () { + return _index.isNamedType; + }, +})); +Object.defineProperty(exports, "isNonNullType", ({ + enumerable: true, + get: function () { + return _index.isNonNullType; + }, +})); +Object.defineProperty(exports, "isNullableType", ({ + enumerable: true, + get: function () { + return _index.isNullableType; + }, +})); +Object.defineProperty(exports, "isObjectType", ({ + enumerable: true, + get: function () { + return _index.isObjectType; + }, +})); +Object.defineProperty(exports, "isOutputType", ({ + enumerable: true, + get: function () { + return _index.isOutputType; + }, +})); +Object.defineProperty(exports, "isRequiredArgument", ({ + enumerable: true, + get: function () { + return _index.isRequiredArgument; + }, +})); +Object.defineProperty(exports, "isRequiredInputField", ({ + enumerable: true, + get: function () { + return _index.isRequiredInputField; + }, +})); +Object.defineProperty(exports, "isScalarType", ({ + enumerable: true, + get: function () { + return _index.isScalarType; + }, +})); +Object.defineProperty(exports, "isSchema", ({ + enumerable: true, + get: function () { + return _index.isSchema; + }, +})); +Object.defineProperty(exports, "isSelectionNode", ({ + enumerable: true, + get: function () { + return _index2.isSelectionNode; + }, +})); +Object.defineProperty(exports, "isSpecifiedDirective", ({ + enumerable: true, + get: function () { + return _index.isSpecifiedDirective; + }, +})); +Object.defineProperty(exports, "isSpecifiedScalarType", ({ + enumerable: true, + get: function () { + return _index.isSpecifiedScalarType; + }, +})); +Object.defineProperty(exports, "isType", ({ + enumerable: true, + get: function () { + return _index.isType; + }, +})); +Object.defineProperty(exports, "isTypeDefinitionNode", ({ + enumerable: true, + get: function () { + return _index2.isTypeDefinitionNode; + }, +})); +Object.defineProperty(exports, "isTypeExtensionNode", ({ + enumerable: true, + get: function () { + return _index2.isTypeExtensionNode; + }, +})); +Object.defineProperty(exports, "isTypeNode", ({ + enumerable: true, + get: function () { + return _index2.isTypeNode; + }, +})); +Object.defineProperty(exports, "isTypeSubTypeOf", ({ + enumerable: true, + get: function () { + return _index6.isTypeSubTypeOf; + }, +})); +Object.defineProperty(exports, "isTypeSystemDefinitionNode", ({ + enumerable: true, + get: function () { + return _index2.isTypeSystemDefinitionNode; + }, +})); +Object.defineProperty(exports, "isTypeSystemExtensionNode", ({ + enumerable: true, + get: function () { + return _index2.isTypeSystemExtensionNode; + }, +})); +Object.defineProperty(exports, "isUnionType", ({ + enumerable: true, + get: function () { + return _index.isUnionType; + }, +})); +Object.defineProperty(exports, "isValidNameError", ({ + enumerable: true, + get: function () { + return _index6.isValidNameError; + }, +})); +Object.defineProperty(exports, "isValueNode", ({ + enumerable: true, + get: function () { + return _index2.isValueNode; + }, +})); +Object.defineProperty(exports, "isWrappingType", ({ + enumerable: true, + get: function () { + return _index.isWrappingType; + }, +})); +Object.defineProperty(exports, "lexicographicSortSchema", ({ + enumerable: true, + get: function () { + return _index6.lexicographicSortSchema; + }, +})); +Object.defineProperty(exports, "locatedError", ({ + enumerable: true, + get: function () { + return _index5.locatedError; + }, +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _index2.parse; + }, +})); +Object.defineProperty(exports, "parseConstValue", ({ + enumerable: true, + get: function () { + return _index2.parseConstValue; + }, +})); +Object.defineProperty(exports, "parseType", ({ + enumerable: true, + get: function () { + return _index2.parseType; + }, +})); +Object.defineProperty(exports, "parseValue", ({ + enumerable: true, + get: function () { + return _index2.parseValue; + }, +})); +Object.defineProperty(exports, "print", ({ + enumerable: true, + get: function () { + return _index2.print; + }, +})); +Object.defineProperty(exports, "printError", ({ + enumerable: true, + get: function () { + return _index5.printError; + }, +})); +Object.defineProperty(exports, "printIntrospectionSchema", ({ + enumerable: true, + get: function () { + return _index6.printIntrospectionSchema; + }, +})); +Object.defineProperty(exports, "printLocation", ({ + enumerable: true, + get: function () { + return _index2.printLocation; + }, +})); +Object.defineProperty(exports, "printSchema", ({ + enumerable: true, + get: function () { + return _index6.printSchema; + }, +})); +Object.defineProperty(exports, "printSourceLocation", ({ + enumerable: true, + get: function () { + return _index2.printSourceLocation; + }, +})); +Object.defineProperty(exports, "printType", ({ + enumerable: true, + get: function () { + return _index6.printType; + }, +})); +Object.defineProperty(exports, "resolveObjMapThunk", ({ + enumerable: true, + get: function () { + return _index.resolveObjMapThunk; + }, +})); +Object.defineProperty(exports, "resolveReadonlyArrayThunk", ({ + enumerable: true, + get: function () { + return _index.resolveReadonlyArrayThunk; + }, +})); +Object.defineProperty(exports, "responsePathAsArray", ({ + enumerable: true, + get: function () { + return _index3.responsePathAsArray; + }, +})); +Object.defineProperty(exports, "separateOperations", ({ + enumerable: true, + get: function () { + return _index6.separateOperations; + }, +})); +Object.defineProperty(exports, "specifiedDirectives", ({ + enumerable: true, + get: function () { + return _index.specifiedDirectives; + }, +})); +Object.defineProperty(exports, "specifiedRules", ({ + enumerable: true, + get: function () { + return _index4.specifiedRules; + }, +})); +Object.defineProperty(exports, "specifiedScalarTypes", ({ + enumerable: true, + get: function () { + return _index.specifiedScalarTypes; + }, +})); +Object.defineProperty(exports, "stripIgnoredCharacters", ({ + enumerable: true, + get: function () { + return _index6.stripIgnoredCharacters; + }, +})); +Object.defineProperty(exports, "subscribe", ({ + enumerable: true, + get: function () { + return _index3.subscribe; + }, +})); +Object.defineProperty(exports, "syntaxError", ({ + enumerable: true, + get: function () { + return _index5.syntaxError; + }, +})); +Object.defineProperty(exports, "typeFromAST", ({ + enumerable: true, + get: function () { + return _index6.typeFromAST; + }, +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _index4.validate; + }, +})); +Object.defineProperty(exports, "validateSchema", ({ + enumerable: true, + get: function () { + return _index.validateSchema; + }, +})); +Object.defineProperty(exports, "valueFromAST", ({ + enumerable: true, + get: function () { + return _index6.valueFromAST; + }, +})); +Object.defineProperty(exports, "valueFromASTUntyped", ({ + enumerable: true, + get: function () { + return _index6.valueFromASTUntyped; + }, +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.version; + }, +})); +Object.defineProperty(exports, "versionInfo", ({ + enumerable: true, + get: function () { + return _version.versionInfo; + }, +})); +Object.defineProperty(exports, "visit", ({ + enumerable: true, + get: function () { + return _index2.visit; + }, +})); +Object.defineProperty(exports, "visitInParallel", ({ + enumerable: true, + get: function () { + return _index2.visitInParallel; + }, +})); +Object.defineProperty(exports, "visitWithTypeInfo", ({ + enumerable: true, + get: function () { + return _index6.visitWithTypeInfo; + }, +})); + +var _version = __nccwpck_require__(61121); + +var _graphql = __nccwpck_require__(95063); + +var _index = __nccwpck_require__(11702); + +var _index2 = __nccwpck_require__(94079); + +var _index3 = __nccwpck_require__(40005); + +var _index4 = __nccwpck_require__(68660); + +var _index5 = __nccwpck_require__(17651); + +var _index6 = __nccwpck_require__(39167); + + +/***/ }), + +/***/ 80333: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.addPath = addPath; +exports.pathToArray = pathToArray; + +/** + * Given a Path and a key, return a new Path containing the new key. + */ +function addPath(prev, key, typename) { + return { + prev, + key, + typename, + }; +} +/** + * Given a Path, return an Array of the path keys. + */ + +function pathToArray(path) { + const flattened = []; + let curr = path; + + while (curr) { + flattened.push(curr.key); + curr = curr.prev; + } + + return flattened.reverse(); +} + + +/***/ }), + +/***/ 60645: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.devAssert = devAssert; + +function devAssert(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error(message); + } +} + + +/***/ }), + +/***/ 94476: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.didYouMean = didYouMean; +const MAX_SUGGESTIONS = 5; +/** + * Given [ A, B, C ] return ' Did you mean A, B, or C?'. + */ + +function didYouMean(firstArg, secondArg) { + const [subMessage, suggestionsArg] = secondArg + ? [firstArg, secondArg] + : [undefined, firstArg]; + let message = ' Did you mean '; + + if (subMessage) { + message += subMessage + ' '; + } + + const suggestions = suggestionsArg.map((x) => `"${x}"`); + + switch (suggestions.length) { + case 0: + return ''; + + case 1: + return message + suggestions[0] + '?'; + + case 2: + return message + suggestions[0] + ' or ' + suggestions[1] + '?'; + } + + const selected = suggestions.slice(0, MAX_SUGGESTIONS); + const lastItem = selected.pop(); + return message + selected.join(', ') + ', or ' + lastItem + '?'; +} + + +/***/ }), + +/***/ 33278: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.groupBy = groupBy; + +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +function groupBy(list, keyFn) { + const result = new Map(); + + for (const item of list) { + const key = keyFn(item); + const group = result.get(key); + + if (group === undefined) { + result.set(key, [item]); + } else { + group.push(item); + } + } + + return result; +} + + +/***/ }), + +/***/ 16149: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.identityFunc = identityFunc; + +/** + * Returns the first argument it receives. + */ +function identityFunc(x) { + return x; +} + + +/***/ }), + +/***/ 17819: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.inspect = inspect; +const MAX_ARRAY_LENGTH = 10; +const MAX_RECURSIVE_DEPTH = 2; +/** + * Used to print values in error messages. + */ + +function inspect(value) { + return formatValue(value, []); +} + +function formatValue(value, seenValues) { + switch (typeof value) { + case 'string': + return JSON.stringify(value); + + case 'function': + return value.name ? `[function ${value.name}]` : '[function]'; + + case 'object': + return formatObjectValue(value, seenValues); + + default: + return String(value); + } +} + +function formatObjectValue(value, previouslySeenValues) { + if (value === null) { + return 'null'; + } + + if (previouslySeenValues.includes(value)) { + return '[Circular]'; + } + + const seenValues = [...previouslySeenValues, value]; + + if (isJSONable(value)) { + const jsonValue = value.toJSON(); // check for infinite recursion + + if (jsonValue !== value) { + return typeof jsonValue === 'string' + ? jsonValue + : formatValue(jsonValue, seenValues); + } + } else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } + + return formatObject(value, seenValues); +} + +function isJSONable(value) { + return typeof value.toJSON === 'function'; +} + +function formatObject(object, seenValues) { + const entries = Object.entries(object); + + if (entries.length === 0) { + return '{}'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } + + const properties = entries.map( + ([key, value]) => key + ': ' + formatValue(value, seenValues), + ); + return '{ ' + properties.join(', ') + ' }'; +} + +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } + + const len = Math.min(MAX_ARRAY_LENGTH, array.length); + const remaining = array.length - len; + const items = []; + + for (let i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } + + if (remaining === 1) { + items.push('... 1 more item'); + } else if (remaining > 1) { + items.push(`... ${remaining} more items`); + } + + return '[' + items.join(', ') + ']'; +} + +function getObjectTag(object) { + const tag = Object.prototype.toString + .call(object) + .replace(/^\[object /, '') + .replace(/]$/, ''); + + if (tag === 'Object' && typeof object.constructor === 'function') { + const name = object.constructor.name; + + if (typeof name === 'string' && name !== '') { + return name; + } + } + + return tag; +} + + +/***/ }), + +/***/ 92830: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.instanceOf = void 0; + +var _inspect = __nccwpck_require__(17819); + +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ +const instanceOf = + /* c8 ignore next 6 */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + // eslint-disable-next-line no-undef + process.env.NODE_ENV === 'production' + ? function instanceOf(value, constructor) { + return value instanceof constructor; + } + : function instanceOf(value, constructor) { + if (value instanceof constructor) { + return true; + } + + if (typeof value === 'object' && value !== null) { + var _value$constructor; + + // Prefer Symbol.toStringTag since it is immune to minification. + const className = constructor.prototype[Symbol.toStringTag]; + 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] + : (_value$constructor = value.constructor) === null || + _value$constructor === void 0 + ? void 0 + : _value$constructor.name; + + if (className === valueClassName) { + const stringifiedValue = (0, _inspect.inspect)(value); + throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm. + +Ensure that there is only one instance of "graphql" in the node_modules +directory. If different versions of "graphql" are the dependencies of other +relied on modules, use "resolutions" to ensure only one version is installed. + +https://yarnpkg.com/en/docs/selective-version-resolutions + +Duplicate "graphql" modules cannot be used at the same time since different +versions may have different capabilities and behavior. The data from one +version used in the function from another could produce confusing and +spurious results.`); + } + } + + return false; + }; +exports.instanceOf = instanceOf; + + +/***/ }), + +/***/ 52810: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.invariant = invariant; + +function invariant(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error( + message != null ? message : 'Unexpected invariant triggered.', + ); + } +} + + +/***/ }), + +/***/ 96607: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isAsyncIterable = isAsyncIterable; + +/** + * Returns true if the provided object implements the AsyncIterator protocol via + * implementing a `Symbol.asyncIterator` method. + */ +function isAsyncIterable(maybeAsyncIterable) { + return ( + typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 + ? void 0 + : maybeAsyncIterable[Symbol.asyncIterator]) === 'function' + ); +} + + +/***/ }), + +/***/ 45988: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isIterableObject = isIterableObject; + +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +function isIterableObject(maybeIterable) { + return ( + typeof maybeIterable === 'object' && + typeof (maybeIterable === null || maybeIterable === void 0 + ? void 0 + : maybeIterable[Symbol.iterator]) === 'function' + ); +} + + +/***/ }), + +/***/ 63457: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isObjectLike = isObjectLike; + +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +function isObjectLike(value) { + return typeof value == 'object' && value !== null; +} + + +/***/ }), + +/***/ 68362: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isPromise = isPromise; + +/** + * Returns true if the value acts like a Promise, i.e. has a "then" function, + * otherwise returns false. + */ +function isPromise(value) { + return ( + typeof (value === null || value === void 0 ? void 0 : value.then) === + 'function' + ); +} + + +/***/ }), + +/***/ 35053: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.keyMap = keyMap; + +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +function keyMap(list, keyFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = item; + } + + return result; +} + + +/***/ }), + +/***/ 69662: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.keyValMap = keyValMap; + +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +function keyValMap(list, keyFn, valFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = valFn(item); + } + + return result; +} + + +/***/ }), + +/***/ 31687: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.mapValue = mapValue; + +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +function mapValue(map, fn) { + const result = Object.create(null); + + for (const key of Object.keys(map)) { + result[key] = fn(map[key], key); + } + + return result; +} + + +/***/ }), + +/***/ 66997: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.memoize3 = memoize3; + +/** + * Memoizes the provided three-argument function. + */ +function memoize3(fn) { + let cache0; + return function memoized(a1, a2, a3) { + if (cache0 === undefined) { + cache0 = new WeakMap(); + } + + let cache1 = cache0.get(a1); + + if (cache1 === undefined) { + cache1 = new WeakMap(); + cache0.set(a1, cache1); + } + + let cache2 = cache1.get(a2); + + if (cache2 === undefined) { + cache2 = new WeakMap(); + cache1.set(a2, cache2); + } + + let fnResult = cache2.get(a3); + + if (fnResult === undefined) { + fnResult = fn(a1, a2, a3); + cache2.set(a3, fnResult); + } + + return fnResult; + }; +} + + +/***/ }), + +/***/ 29329: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.naturalCompare = naturalCompare; + +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +function naturalCompare(aStr, bStr) { + let aIndex = 0; + let bIndex = 0; + + while (aIndex < aStr.length && bIndex < bStr.length) { + let aChar = aStr.charCodeAt(aIndex); + let bChar = bStr.charCodeAt(bIndex); + + if (isDigit(aChar) && isDigit(bChar)) { + let aNum = 0; + + do { + ++aIndex; + aNum = aNum * 10 + aChar - DIGIT_0; + aChar = aStr.charCodeAt(aIndex); + } while (isDigit(aChar) && aNum > 0); + + let bNum = 0; + + do { + ++bIndex; + bNum = bNum * 10 + bChar - DIGIT_0; + bChar = bStr.charCodeAt(bIndex); + } while (isDigit(bChar) && bNum > 0); + + if (aNum < bNum) { + return -1; + } + + if (aNum > bNum) { + return 1; + } + } else { + if (aChar < bChar) { + return -1; + } + + if (aChar > bChar) { + return 1; + } + + ++aIndex; + ++bIndex; + } + } + + return aStr.length - bStr.length; +} + +const DIGIT_0 = 48; +const DIGIT_9 = 57; + +function isDigit(code) { + return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; +} + + +/***/ }), + +/***/ 49802: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printPathArray = printPathArray; + +/** + * Build a string describing the path. + */ +function printPathArray(path) { + return path + .map((key) => + typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key, + ) + .join(''); +} + + +/***/ }), + +/***/ 55982: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.promiseForObject = promiseForObject; + +/** + * This function transforms a JS object `ObjMap>` into + * a `Promise>` + * + * This is akin to bluebird's `Promise.props`, but implemented only using + * `Promise.all` so it will work with any implementation of ES6 promises. + */ +function promiseForObject(object) { + return Promise.all(Object.values(object)).then((resolvedValues) => { + const resolvedObject = Object.create(null); + + for (const [i, key] of Object.keys(object).entries()) { + resolvedObject[key] = resolvedValues[i]; + } + + return resolvedObject; + }); +} + + +/***/ }), + +/***/ 40490: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.promiseReduce = promiseReduce; + +var _isPromise = __nccwpck_require__(68362); + +/** + * Similar to Array.prototype.reduce(), however the reducing callback may return + * a Promise, in which case reduction will continue after each promise resolves. + * + * If the callback does not return a Promise, then this function will also not + * return a Promise. + */ +function promiseReduce(values, callbackFn, initialValue) { + let accumulator = initialValue; + + for (const value of values) { + accumulator = (0, _isPromise.isPromise)(accumulator) + ? accumulator.then((resolved) => callbackFn(resolved, value)) + : callbackFn(accumulator, value); + } + + return accumulator; +} + + +/***/ }), + +/***/ 48992: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.suggestionList = suggestionList; + +var _naturalCompare = __nccwpck_require__(29329); + +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ +function suggestionList(input, options) { + const optionsByDistance = Object.create(null); + const lexicalDistance = new LexicalDistance(input); + const threshold = Math.floor(input.length * 0.4) + 1; + + for (const option of options) { + const distance = lexicalDistance.measure(option, threshold); + + if (distance !== undefined) { + optionsByDistance[option] = distance; + } + } + + return Object.keys(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; + return distanceDiff !== 0 + ? distanceDiff + : (0, _naturalCompare.naturalCompare)(a, b); + }); +} +/** + * Computes the lexical distance between strings A and B. + * + * The "distance" between two strings is given by counting the minimum number + * of edits needed to transform string A into string B. An edit can be an + * insertion, deletion, or substitution of a single character, or a swap of two + * adjacent characters. + * + * Includes a custom alteration from Damerau-Levenshtein to treat case changes + * as a single edit which helps identify mis-cased values with an edit distance + * of 1. + * + * This distance can be useful for detecting typos in input or sorting + */ + +class LexicalDistance { + constructor(input) { + this._input = input; + this._inputLowerCase = input.toLowerCase(); + this._inputArray = stringToArray(this._inputLowerCase); + this._rows = [ + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + ]; + } + + measure(option, threshold) { + if (this._input === option) { + return 0; + } + + const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit + + if (this._inputLowerCase === optionLowerCase) { + return 1; + } + + let a = stringToArray(optionLowerCase); + let b = this._inputArray; + + if (a.length < b.length) { + const tmp = a; + a = b; + b = tmp; + } + + const aLength = a.length; + const bLength = b.length; + + if (aLength - bLength > threshold) { + return undefined; + } + + const rows = this._rows; + + for (let j = 0; j <= bLength; j++) { + rows[0][j] = j; + } + + for (let i = 1; i <= aLength; i++) { + const upRow = rows[(i - 1) % 3]; + const currentRow = rows[i % 3]; + let smallestCell = (currentRow[0] = i); + + for (let j = 1; j <= bLength; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + 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]) { + // transposition + const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; + currentCell = Math.min(currentCell, doubleDiagonalCell + 1); + } + + if (currentCell < smallestCell) { + smallestCell = currentCell; + } + + currentRow[j] = currentCell; + } // Early exit, since distance can't go smaller than smallest element of the previous row. + + if (smallestCell > threshold) { + return undefined; + } + } + + const distance = rows[aLength % 3][bLength]; + return distance <= threshold ? distance : undefined; + } +} + +function stringToArray(str) { + const strLength = str.length; + const array = new Array(strLength); + + for (let i = 0; i < strLength; ++i) { + array[i] = str.charCodeAt(i); + } + + return array; +} + + +/***/ }), + +/***/ 56552: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.toError = toError; + +var _inspect = __nccwpck_require__(17819); + +/** + * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + */ +function toError(thrownValue) { + return thrownValue instanceof Error + ? thrownValue + : new NonErrorThrown(thrownValue); +} + +class NonErrorThrown extends Error { + constructor(thrownValue) { + super('Unexpected error value: ' + (0, _inspect.inspect)(thrownValue)); + this.name = 'NonErrorThrown'; + this.thrownValue = thrownValue; + } +} + + +/***/ }), + +/***/ 54965: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.toObjMap = toObjMap; + +function toObjMap(obj) { + if (obj == null) { + return Object.create(null); + } + + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + + const map = Object.create(null); + + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + + return map; +} + + +/***/ }), + +/***/ 20727: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Token = + exports.QueryDocumentKeys = + exports.OperationTypeNode = + exports.Location = + void 0; +exports.isNode = isNode; + +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +class Location { + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The Token at which this Node begins. + */ + + /** + * The Token at which this Node ends. + */ + + /** + * The Source document the AST represents. + */ + constructor(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } + + get [Symbol.toStringTag]() { + return 'Location'; + } + + toJSON() { + return { + start: this.start, + end: this.end, + }; + } +} +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ + +exports.Location = Location; + +class Token { + /** + * The kind of Token. + */ + + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The 1-indexed line number on which this Token appears. + */ + + /** + * The 1-indexed column number at which this Token begins. + */ + + /** + * For non-punctuation tokens, represents the interpreted value of the token. + * + * Note: is undefined for punctuation tokens, but typed as string for + * convenience in the parser. + */ + + /** + * Tokens exist as nodes in a double-linked-list amongst all tokens + * including ignored tokens. is always the first node and + * the last. + */ + constructor(kind, start, end, line, column, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + + this.value = value; + this.prev = null; + this.next = null; + } + + get [Symbol.toStringTag]() { + return 'Token'; + } + + toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column, + }; + } +} +/** + * The list of all possible AST node types. + */ + +exports.Token = Token; + +/** + * @internal + */ +const QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: [ + 'name', + 'variableDefinitions', + 'directives', + 'selectionSet', + ], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentSpread: ['name', 'directives'], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: [ + 'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0 + 'variableDefinitions', + 'typeCondition', + 'directives', + 'selectionSet', + ], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: [ + 'description', + 'name', + 'type', + 'defaultValue', + 'directives', + ], + InterfaceTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'], +}; +exports.QueryDocumentKeys = QueryDocumentKeys; +const kindValues = new Set(Object.keys(QueryDocumentKeys)); +/** + * @internal + */ + +function isNode(maybeNode) { + const maybeKind = + maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind; + return typeof maybeKind === 'string' && kindValues.has(maybeKind); +} +/** Name */ + +var OperationTypeNode; +exports.OperationTypeNode = OperationTypeNode; + +(function (OperationTypeNode) { + OperationTypeNode['QUERY'] = 'query'; + OperationTypeNode['MUTATION'] = 'mutation'; + OperationTypeNode['SUBSCRIPTION'] = 'subscription'; +})(OperationTypeNode || (exports.OperationTypeNode = OperationTypeNode = {})); + + +/***/ }), + +/***/ 79685: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.dedentBlockStringLines = dedentBlockStringLines; +exports.isPrintableAsBlockString = isPrintableAsBlockString; +exports.printBlockString = printBlockString; + +var _characterClasses = __nccwpck_require__(46365); + +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ +function dedentBlockStringLines(lines) { + var _firstNonEmptyLine2; + + let commonIndent = Number.MAX_SAFE_INTEGER; + let firstNonEmptyLine = null; + let lastNonEmptyLine = -1; + + for (let i = 0; i < lines.length; ++i) { + var _firstNonEmptyLine; + + const line = lines[i]; + const indent = leadingWhitespace(line); + + if (indent === line.length) { + continue; // skip empty lines + } + + firstNonEmptyLine = + (_firstNonEmptyLine = firstNonEmptyLine) !== null && + _firstNonEmptyLine !== void 0 + ? _firstNonEmptyLine + : i; + lastNonEmptyLine = i; + + if (i !== 0 && indent < commonIndent) { + commonIndent = indent; + } + } + + return lines // Remove common indentation from all lines but first. + .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) // Remove leading and trailing blank lines. + .slice( + (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && + _firstNonEmptyLine2 !== void 0 + ? _firstNonEmptyLine2 + : 0, + lastNonEmptyLine + 1, + ); +} + +function leadingWhitespace(str) { + let i = 0; + + while ( + i < str.length && + (0, _characterClasses.isWhiteSpace)(str.charCodeAt(i)) + ) { + ++i; + } + + return i; +} +/** + * @internal + */ + +function isPrintableAsBlockString(value) { + if (value === '') { + return true; // empty string is printable + } + + let isEmptyLine = true; + let hasIndent = false; + let hasCommonIndent = true; + let seenNonEmptyLine = false; + + for (let i = 0; i < value.length; ++i) { + switch (value.codePointAt(i)) { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + case 0x0008: + case 0x000b: + case 0x000c: + case 0x000e: + case 0x000f: + return false; + // Has non-printable characters + + case 0x000d: + // \r + return false; + // Has \r or \r\n which will be replaced as \n + + case 10: + // \n + if (isEmptyLine && !seenNonEmptyLine) { + return false; // Has leading new line + } + + seenNonEmptyLine = true; + isEmptyLine = true; + hasIndent = false; + break; + + case 9: // \t + + case 32: + // + hasIndent || (hasIndent = isEmptyLine); + break; + + default: + hasCommonIndent && (hasCommonIndent = hasIndent); + isEmptyLine = false; + } + } + + if (isEmptyLine) { + return false; // Has trailing empty lines + } + + if (hasCommonIndent && seenNonEmptyLine) { + return false; // Has internal indent + } + + return true; +} +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ + +function printBlockString(value, options) { + const escapedValue = value.replace(/"""/g, '\\"""'); // Expand a block string's raw value into independent lines. + + const lines = escapedValue.split(/\r\n|[\n\r]/g); + const isSingleLine = lines.length === 1; // If common indentation is found we can fix some of those cases by adding leading new line + + const forceLeadingNewLine = + lines.length > 1 && + lines + .slice(1) + .every( + (line) => + line.length === 0 || + (0, _characterClasses.isWhiteSpace)(line.charCodeAt(0)), + ); // Trailing triple quotes just looks confusing but doesn't force trailing new line + + const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); // Trailing quote (single or double) or slash forces trailing new line + + const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; + const hasTrailingSlash = value.endsWith('\\'); + const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; + const printAsMultipleLines = + !(options !== null && options !== void 0 && options.minimize) && // add leading and trailing new lines only if it improves readability + (!isSingleLine || + value.length > 70 || + forceTrailingNewline || + forceLeadingNewLine || + hasTrailingTripleQuotes); + let result = ''; // Format a multi-line block quote to account for leading space. + + const skipLeadingNewLine = + isSingleLine && (0, _characterClasses.isWhiteSpace)(value.charCodeAt(0)); + + if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { + result += '\n'; + } + + result += escapedValue; + + if (printAsMultipleLines || forceTrailingNewline) { + result += '\n'; + } + + return '"""' + result + '"""'; +} + + +/***/ }), + +/***/ 46365: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isDigit = isDigit; +exports.isLetter = isLetter; +exports.isNameContinue = isNameContinue; +exports.isNameStart = isNameStart; +exports.isWhiteSpace = isWhiteSpace; + +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +function isWhiteSpace(code) { + return code === 0x0009 || code === 0x0020; +} +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ + +function isDigit(code) { + return code >= 0x0030 && code <= 0x0039; +} +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ + +function isLetter(code) { + return ( + (code >= 0x0061 && code <= 0x007a) || // A-Z + (code >= 0x0041 && code <= 0x005a) // a-z + ); +} +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ + +function isNameStart(code) { + return isLetter(code) || code === 0x005f; +} +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ + +function isNameContinue(code) { + return isLetter(code) || isDigit(code) || code === 0x005f; +} + + +/***/ }), + +/***/ 6128: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.DirectiveLocation = void 0; + +/** + * The set of allowed directive location values. + */ +var DirectiveLocation; +exports.DirectiveLocation = DirectiveLocation; + +(function (DirectiveLocation) { + DirectiveLocation['QUERY'] = 'QUERY'; + DirectiveLocation['MUTATION'] = 'MUTATION'; + DirectiveLocation['SUBSCRIPTION'] = 'SUBSCRIPTION'; + DirectiveLocation['FIELD'] = 'FIELD'; + DirectiveLocation['FRAGMENT_DEFINITION'] = 'FRAGMENT_DEFINITION'; + DirectiveLocation['FRAGMENT_SPREAD'] = 'FRAGMENT_SPREAD'; + DirectiveLocation['INLINE_FRAGMENT'] = 'INLINE_FRAGMENT'; + DirectiveLocation['VARIABLE_DEFINITION'] = 'VARIABLE_DEFINITION'; + DirectiveLocation['SCHEMA'] = 'SCHEMA'; + DirectiveLocation['SCALAR'] = 'SCALAR'; + DirectiveLocation['OBJECT'] = 'OBJECT'; + DirectiveLocation['FIELD_DEFINITION'] = 'FIELD_DEFINITION'; + DirectiveLocation['ARGUMENT_DEFINITION'] = 'ARGUMENT_DEFINITION'; + DirectiveLocation['INTERFACE'] = 'INTERFACE'; + DirectiveLocation['UNION'] = 'UNION'; + DirectiveLocation['ENUM'] = 'ENUM'; + DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE'; + DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT'; + DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION'; +})(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {})); +/** + * The enum type representing the directive location values. + * + * @deprecated Please use `DirectiveLocation`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 94079: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "BREAK", ({ + enumerable: true, + get: function () { + return _visitor.BREAK; + }, +})); +Object.defineProperty(exports, "DirectiveLocation", ({ + enumerable: true, + get: function () { + return _directiveLocation.DirectiveLocation; + }, +})); +Object.defineProperty(exports, "Kind", ({ + enumerable: true, + get: function () { + return _kinds.Kind; + }, +})); +Object.defineProperty(exports, "Lexer", ({ + enumerable: true, + get: function () { + return _lexer.Lexer; + }, +})); +Object.defineProperty(exports, "Location", ({ + enumerable: true, + get: function () { + return _ast.Location; + }, +})); +Object.defineProperty(exports, "OperationTypeNode", ({ + enumerable: true, + get: function () { + return _ast.OperationTypeNode; + }, +})); +Object.defineProperty(exports, "Source", ({ + enumerable: true, + get: function () { + return _source.Source; + }, +})); +Object.defineProperty(exports, "Token", ({ + enumerable: true, + get: function () { + return _ast.Token; + }, +})); +Object.defineProperty(exports, "TokenKind", ({ + enumerable: true, + get: function () { + return _tokenKind.TokenKind; + }, +})); +Object.defineProperty(exports, "getEnterLeaveForKind", ({ + enumerable: true, + get: function () { + return _visitor.getEnterLeaveForKind; + }, +})); +Object.defineProperty(exports, "getLocation", ({ + enumerable: true, + get: function () { + return _location.getLocation; + }, +})); +Object.defineProperty(exports, "getVisitFn", ({ + enumerable: true, + get: function () { + return _visitor.getVisitFn; + }, +})); +Object.defineProperty(exports, "isConstValueNode", ({ + enumerable: true, + get: function () { + return _predicates.isConstValueNode; + }, +})); +Object.defineProperty(exports, "isDefinitionNode", ({ + enumerable: true, + get: function () { + return _predicates.isDefinitionNode; + }, +})); +Object.defineProperty(exports, "isExecutableDefinitionNode", ({ + enumerable: true, + get: function () { + return _predicates.isExecutableDefinitionNode; + }, +})); +Object.defineProperty(exports, "isSelectionNode", ({ + enumerable: true, + get: function () { + return _predicates.isSelectionNode; + }, +})); +Object.defineProperty(exports, "isTypeDefinitionNode", ({ + enumerable: true, + get: function () { + return _predicates.isTypeDefinitionNode; + }, +})); +Object.defineProperty(exports, "isTypeExtensionNode", ({ + enumerable: true, + get: function () { + return _predicates.isTypeExtensionNode; + }, +})); +Object.defineProperty(exports, "isTypeNode", ({ + enumerable: true, + get: function () { + return _predicates.isTypeNode; + }, +})); +Object.defineProperty(exports, "isTypeSystemDefinitionNode", ({ + enumerable: true, + get: function () { + return _predicates.isTypeSystemDefinitionNode; + }, +})); +Object.defineProperty(exports, "isTypeSystemExtensionNode", ({ + enumerable: true, + get: function () { + return _predicates.isTypeSystemExtensionNode; + }, +})); +Object.defineProperty(exports, "isValueNode", ({ + enumerable: true, + get: function () { + return _predicates.isValueNode; + }, +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parser.parse; + }, +})); +Object.defineProperty(exports, "parseConstValue", ({ + enumerable: true, + get: function () { + return _parser.parseConstValue; + }, +})); +Object.defineProperty(exports, "parseType", ({ + enumerable: true, + get: function () { + return _parser.parseType; + }, +})); +Object.defineProperty(exports, "parseValue", ({ + enumerable: true, + get: function () { + return _parser.parseValue; + }, +})); +Object.defineProperty(exports, "print", ({ + enumerable: true, + get: function () { + return _printer.print; + }, +})); +Object.defineProperty(exports, "printLocation", ({ + enumerable: true, + get: function () { + return _printLocation.printLocation; + }, +})); +Object.defineProperty(exports, "printSourceLocation", ({ + enumerable: true, + get: function () { + return _printLocation.printSourceLocation; + }, +})); +Object.defineProperty(exports, "visit", ({ + enumerable: true, + get: function () { + return _visitor.visit; + }, +})); +Object.defineProperty(exports, "visitInParallel", ({ + enumerable: true, + get: function () { + return _visitor.visitInParallel; + }, +})); + +var _source = __nccwpck_require__(29915); + +var _location = __nccwpck_require__(61336); + +var _printLocation = __nccwpck_require__(29983); + +var _kinds = __nccwpck_require__(19542); + +var _tokenKind = __nccwpck_require__(43148); + +var _lexer = __nccwpck_require__(21363); + +var _parser = __nccwpck_require__(39927); + +var _printer = __nccwpck_require__(3099); + +var _visitor = __nccwpck_require__(45946); + +var _ast = __nccwpck_require__(20727); + +var _predicates = __nccwpck_require__(2493); + +var _directiveLocation = __nccwpck_require__(6128); + + +/***/ }), + +/***/ 19542: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Kind = void 0; + +/** + * The set of allowed kind values for AST nodes. + */ +var Kind; +exports.Kind = Kind; + +(function (Kind) { + Kind['NAME'] = 'Name'; + Kind['DOCUMENT'] = 'Document'; + Kind['OPERATION_DEFINITION'] = 'OperationDefinition'; + Kind['VARIABLE_DEFINITION'] = 'VariableDefinition'; + Kind['SELECTION_SET'] = 'SelectionSet'; + Kind['FIELD'] = 'Field'; + Kind['ARGUMENT'] = 'Argument'; + Kind['FRAGMENT_SPREAD'] = 'FragmentSpread'; + Kind['INLINE_FRAGMENT'] = 'InlineFragment'; + Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition'; + Kind['VARIABLE'] = 'Variable'; + Kind['INT'] = 'IntValue'; + Kind['FLOAT'] = 'FloatValue'; + Kind['STRING'] = 'StringValue'; + Kind['BOOLEAN'] = 'BooleanValue'; + Kind['NULL'] = 'NullValue'; + Kind['ENUM'] = 'EnumValue'; + Kind['LIST'] = 'ListValue'; + Kind['OBJECT'] = 'ObjectValue'; + Kind['OBJECT_FIELD'] = 'ObjectField'; + Kind['DIRECTIVE'] = 'Directive'; + Kind['NAMED_TYPE'] = 'NamedType'; + Kind['LIST_TYPE'] = 'ListType'; + Kind['NON_NULL_TYPE'] = 'NonNullType'; + Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition'; + Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition'; + Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition'; + Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition'; + Kind['FIELD_DEFINITION'] = 'FieldDefinition'; + Kind['INPUT_VALUE_DEFINITION'] = 'InputValueDefinition'; + Kind['INTERFACE_TYPE_DEFINITION'] = 'InterfaceTypeDefinition'; + Kind['UNION_TYPE_DEFINITION'] = 'UnionTypeDefinition'; + Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition'; + Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition'; + Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition'; + Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition'; + Kind['SCHEMA_EXTENSION'] = 'SchemaExtension'; + Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension'; + Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension'; + Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension'; + Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension'; + Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension'; + Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension'; +})(Kind || (exports.Kind = Kind = {})); +/** + * The enum type representing the possible kind values of AST nodes. + * + * @deprecated Please use `Kind`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 21363: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Lexer = void 0; +exports.isPunctuatorTokenKind = isPunctuatorTokenKind; + +var _syntaxError = __nccwpck_require__(53373); + +var _ast = __nccwpck_require__(20727); + +var _blockString = __nccwpck_require__(79685); + +var _characterClasses = __nccwpck_require__(46365); + +var _tokenKind = __nccwpck_require__(43148); + +/** + * Given a Source object, creates a Lexer for that source. + * A Lexer is a stateful stream generator in that every time + * it is advanced, it returns the next token in the Source. Assuming the + * source lexes, the final Token emitted by the lexer will be of kind + * EOF, after which the lexer will repeatedly return the same EOF token + * whenever called. + */ +class Lexer { + /** + * The previously focused non-ignored token. + */ + + /** + * The currently focused non-ignored token. + */ + + /** + * The (1-indexed) line containing the current token. + */ + + /** + * The character offset at which the current line begins. + */ + constructor(source) { + const startOfFileToken = new _ast.Token( + _tokenKind.TokenKind.SOF, + 0, + 0, + 0, + 0, + ); + this.source = source; + this.lastToken = startOfFileToken; + this.token = startOfFileToken; + this.line = 1; + this.lineStart = 0; + } + + get [Symbol.toStringTag]() { + return 'Lexer'; + } + /** + * Advances the token stream to the next non-ignored token. + */ + + advance() { + this.lastToken = this.token; + const token = (this.token = this.lookahead()); + return token; + } + /** + * Looks ahead and returns the next non-ignored token, but does not change + * the state of Lexer. + */ + + lookahead() { + let token = this.token; + + if (token.kind !== _tokenKind.TokenKind.EOF) { + do { + if (token.next) { + token = token.next; + } else { + // Read the next token and form a link in the token linked-list. + const nextToken = readNextToken(this, token.end); // @ts-expect-error next is only mutable during parsing. + + token.next = nextToken; // @ts-expect-error prev is only mutable during parsing. + + nextToken.prev = token; + token = nextToken; + } + } while (token.kind === _tokenKind.TokenKind.COMMENT); + } + + return token; + } +} +/** + * @internal + */ + +exports.Lexer = Lexer; + +function isPunctuatorTokenKind(kind) { + return ( + kind === _tokenKind.TokenKind.BANG || + kind === _tokenKind.TokenKind.DOLLAR || + kind === _tokenKind.TokenKind.AMP || + kind === _tokenKind.TokenKind.PAREN_L || + kind === _tokenKind.TokenKind.PAREN_R || + kind === _tokenKind.TokenKind.SPREAD || + kind === _tokenKind.TokenKind.COLON || + kind === _tokenKind.TokenKind.EQUALS || + kind === _tokenKind.TokenKind.AT || + kind === _tokenKind.TokenKind.BRACKET_L || + kind === _tokenKind.TokenKind.BRACKET_R || + kind === _tokenKind.TokenKind.BRACE_L || + kind === _tokenKind.TokenKind.PIPE || + kind === _tokenKind.TokenKind.BRACE_R + ); +} +/** + * A Unicode scalar value is any Unicode code point except surrogate code + * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and + * 0xE000 to 0x10FFFF. + * + * SourceCharacter :: + * - "Any Unicode scalar value" + */ + +function isUnicodeScalarValue(code) { + return ( + (code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff) + ); +} +/** + * The GraphQL specification defines source text as a sequence of unicode scalar + * values (which Unicode defines to exclude surrogate code points). However + * JavaScript defines strings as a sequence of UTF-16 code units which may + * include surrogates. A surrogate pair is a valid source character as it + * encodes a supplementary code point (above U+FFFF), but unpaired surrogate + * code points are not valid source characters. + */ + +function isSupplementaryCodePoint(body, location) { + return ( + isLeadingSurrogate(body.charCodeAt(location)) && + isTrailingSurrogate(body.charCodeAt(location + 1)) + ); +} + +function isLeadingSurrogate(code) { + return code >= 0xd800 && code <= 0xdbff; +} + +function isTrailingSurrogate(code) { + return code >= 0xdc00 && code <= 0xdfff; +} +/** + * Prints the code point (or end of file reference) at a given location in a + * source for use in error messages. + * + * Printable ASCII is printed quoted, while other points are printed in Unicode + * code point form (ie. U+1234). + */ + +function printCodePointAt(lexer, location) { + const code = lexer.source.body.codePointAt(location); + + if (code === undefined) { + return _tokenKind.TokenKind.EOF; + } else if (code >= 0x0020 && code <= 0x007e) { + // Printable ASCII + const char = String.fromCodePoint(code); + return char === '"' ? "'\"'" : `"${char}"`; + } // Unicode code point + + return 'U+' + code.toString(16).toUpperCase().padStart(4, '0'); +} +/** + * Create a token with line and column location information. + */ + +function createToken(lexer, kind, start, end, value) { + const line = lexer.line; + const col = 1 + start - lexer.lineStart; + return new _ast.Token(kind, start, end, line, col, value); +} +/** + * Gets the next token from the source starting at the given position. + * + * This skips over whitespace until it finds the next lexable token, then lexes + * punctuators immediately or calls the appropriate helper function for more + * complicated tokens. + */ + +function readNextToken(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // SourceCharacter + + switch (code) { + // Ignored :: + // - UnicodeBOM + // - WhiteSpace + // - LineTerminator + // - Comment + // - Comma + // + // UnicodeBOM :: "Byte Order Mark (U+FEFF)" + // + // WhiteSpace :: + // - "Horizontal Tab (U+0009)" + // - "Space (U+0020)" + // + // Comma :: , + case 0xfeff: // + + case 0x0009: // \t + + case 0x0020: // + + case 0x002c: + // , + ++position; + continue; + // LineTerminator :: + // - "New Line (U+000A)" + // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"] + // - "Carriage Return (U+000D)" "New Line (U+000A)" + + case 0x000a: + // \n + ++position; + ++lexer.line; + lexer.lineStart = position; + continue; + + case 0x000d: + // \r + if (body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } else { + ++position; + } + + ++lexer.line; + lexer.lineStart = position; + continue; + // Comment + + case 0x0023: + // # + return readComment(lexer, position); + // Token :: + // - Punctuator + // - Name + // - IntValue + // - FloatValue + // - StringValue + // + // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } + + case 0x0021: + // ! + return createToken( + lexer, + _tokenKind.TokenKind.BANG, + position, + position + 1, + ); + + case 0x0024: + // $ + return createToken( + lexer, + _tokenKind.TokenKind.DOLLAR, + position, + position + 1, + ); + + case 0x0026: + // & + return createToken( + lexer, + _tokenKind.TokenKind.AMP, + position, + position + 1, + ); + + case 0x0028: + // ( + return createToken( + lexer, + _tokenKind.TokenKind.PAREN_L, + position, + position + 1, + ); + + case 0x0029: + // ) + return createToken( + lexer, + _tokenKind.TokenKind.PAREN_R, + position, + position + 1, + ); + + case 0x002e: + // . + if ( + body.charCodeAt(position + 1) === 0x002e && + body.charCodeAt(position + 2) === 0x002e + ) { + return createToken( + lexer, + _tokenKind.TokenKind.SPREAD, + position, + position + 3, + ); + } + + break; + + case 0x003a: + // : + return createToken( + lexer, + _tokenKind.TokenKind.COLON, + position, + position + 1, + ); + + case 0x003d: + // = + return createToken( + lexer, + _tokenKind.TokenKind.EQUALS, + position, + position + 1, + ); + + case 0x0040: + // @ + return createToken( + lexer, + _tokenKind.TokenKind.AT, + position, + position + 1, + ); + + case 0x005b: + // [ + return createToken( + lexer, + _tokenKind.TokenKind.BRACKET_L, + position, + position + 1, + ); + + case 0x005d: + // ] + return createToken( + lexer, + _tokenKind.TokenKind.BRACKET_R, + position, + position + 1, + ); + + case 0x007b: + // { + return createToken( + lexer, + _tokenKind.TokenKind.BRACE_L, + position, + position + 1, + ); + + case 0x007c: + // | + return createToken( + lexer, + _tokenKind.TokenKind.PIPE, + position, + position + 1, + ); + + case 0x007d: + // } + return createToken( + lexer, + _tokenKind.TokenKind.BRACE_R, + position, + position + 1, + ); + // StringValue + + case 0x0022: + // " + if ( + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 + ) { + return readBlockString(lexer, position); + } + + return readString(lexer, position); + } // IntValue | FloatValue (Digit | -) + + if ((0, _characterClasses.isDigit)(code) || code === 0x002d) { + return readNumber(lexer, position, code); + } // Name + + if ((0, _characterClasses.isNameStart)(code)) { + return readName(lexer, position); + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + code === 0x0027 + ? 'Unexpected single quote character (\'), did you mean to use a double quote (")?' + : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) + ? `Unexpected character: ${printCodePointAt(lexer, position)}.` + : `Invalid character: ${printCodePointAt(lexer, position)}.`, + ); + } + + return createToken(lexer, _tokenKind.TokenKind.EOF, bodyLength, bodyLength); +} +/** + * Reads a comment token from the source file. + * + * ``` + * Comment :: # CommentChar* [lookahead != CommentChar] + * + * CommentChar :: SourceCharacter but not LineTerminator + * ``` + */ + +function readComment(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // LineTerminator (\n | \r) + + if (code === 0x000a || code === 0x000d) { + break; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + break; + } + } + + return createToken( + lexer, + _tokenKind.TokenKind.COMMENT, + start, + position, + body.slice(start + 1, position), + ); +} +/** + * Reads a number token from the source file, either a FloatValue or an IntValue + * depending on whether a FractionalPart or ExponentPart is encountered. + * + * ``` + * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}] + * + * IntegerPart :: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit Digit* + * + * NegativeSign :: - + * + * NonZeroDigit :: Digit but not `0` + * + * FloatValue :: + * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * + * FractionalPart :: . Digit+ + * + * ExponentPart :: ExponentIndicator Sign? Digit+ + * + * ExponentIndicator :: one of `e` `E` + * + * Sign :: one of + - + * ``` + */ + +function readNumber(lexer, start, firstCode) { + const body = lexer.source.body; + let position = start; + let code = firstCode; + let isFloat = false; // NegativeSign (-) + + if (code === 0x002d) { + code = body.charCodeAt(++position); + } // Zero (0) + + if (code === 0x0030) { + code = body.charCodeAt(++position); + + if ((0, _characterClasses.isDigit)(code)) { + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid number, unexpected digit after 0: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } else { + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // Full stop (.) + + if (code === 0x002e) { + isFloat = true; + code = body.charCodeAt(++position); + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // E e + + if (code === 0x0045 || code === 0x0065) { + isFloat = true; + code = body.charCodeAt(++position); // + - + + if (code === 0x002b || code === 0x002d) { + code = body.charCodeAt(++position); + } + + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // Numbers cannot be followed by . or NameStart + + if (code === 0x002e || (0, _characterClasses.isNameStart)(code)) { + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid number, expected digit but got: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + + return createToken( + lexer, + isFloat ? _tokenKind.TokenKind.FLOAT : _tokenKind.TokenKind.INT, + start, + position, + body.slice(start, position), + ); +} +/** + * Returns the new position in the source after reading one or more digits. + */ + +function readDigits(lexer, start, firstCode) { + if (!(0, _characterClasses.isDigit)(firstCode)) { + throw (0, _syntaxError.syntaxError)( + lexer.source, + start, + `Invalid number, expected digit but got: ${printCodePointAt( + lexer, + start, + )}.`, + ); + } + + const body = lexer.source.body; + let position = start + 1; // +1 to skip first firstCode + + while ((0, _characterClasses.isDigit)(body.charCodeAt(position))) { + ++position; + } + + return position; +} +/** + * Reads a single-quote string token from the source file. + * + * ``` + * StringValue :: + * - `""` [lookahead != `"`] + * - `"` StringCharacter+ `"` + * + * StringCharacter :: + * - SourceCharacter but not `"` or `\` or LineTerminator + * - `\u` EscapedUnicode + * - `\` EscapedCharacter + * + * EscapedUnicode :: + * - `{` HexDigit+ `}` + * - HexDigit HexDigit HexDigit HexDigit + * + * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` + * ``` + */ + +function readString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + let chunkStart = position; + let value = ''; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // Closing Quote (") + + if (code === 0x0022) { + value += body.slice(chunkStart, position); + return createToken( + lexer, + _tokenKind.TokenKind.STRING, + start, + position + 1, + value, + ); + } // Escape Sequence (\) + + if (code === 0x005c) { + value += body.slice(chunkStart, position); + const escape = + body.charCodeAt(position + 1) === 0x0075 // u + ? body.charCodeAt(position + 2) === 0x007b // { + ? readEscapedUnicodeVariableWidth(lexer, position) + : readEscapedUnicodeFixedWidth(lexer, position) + : readEscapedCharacter(lexer, position); + value += escape.value; + position += escape.size; + chunkStart = position; + continue; + } // LineTerminator (\n | \r) + + if (code === 0x000a || code === 0x000d) { + break; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid character within String: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + 'Unterminated string.', + ); +} // The string value and lexed size of an escape sequence. + +function readEscapedUnicodeVariableWidth(lexer, position) { + const body = lexer.source.body; + let point = 0; + let size = 3; // Cannot be larger than 12 chars (\u{00000000}). + + while (size < 12) { + const code = body.charCodeAt(position + size++); // Closing Brace (}) + + if (code === 0x007d) { + // Must be at least 5 chars (\u{0}) and encode a Unicode scalar value. + if (size < 5 || !isUnicodeScalarValue(point)) { + break; + } + + return { + value: String.fromCodePoint(point), + size, + }; + } // Append this hex digit to the code point. + + point = (point << 4) | readHexDigit(code); + + if (point < 0) { + break; + } + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid Unicode escape sequence: "${body.slice( + position, + position + size, + )}".`, + ); +} + +function readEscapedUnicodeFixedWidth(lexer, position) { + const body = lexer.source.body; + const code = read16BitHexCode(body, position + 2); + + if (isUnicodeScalarValue(code)) { + return { + value: String.fromCodePoint(code), + size: 6, + }; + } // GraphQL allows JSON-style surrogate pair escape sequences, but only when + // a valid pair is formed. + + if (isLeadingSurrogate(code)) { + // \u + if ( + body.charCodeAt(position + 6) === 0x005c && + body.charCodeAt(position + 7) === 0x0075 + ) { + const trailingCode = read16BitHexCode(body, position + 8); + + if (isTrailingSurrogate(trailingCode)) { + // JavaScript defines strings as a sequence of UTF-16 code units and + // encodes Unicode code points above U+FFFF using a surrogate pair of + // code units. Since this is a surrogate pair escape sequence, just + // include both codes into the JavaScript string value. Had JavaScript + // not been internally based on UTF-16, then this surrogate pair would + // be decoded to retrieve the supplementary code point. + return { + value: String.fromCodePoint(code, trailingCode), + size: 12, + }; + } + } + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`, + ); +} +/** + * Reads four hexadecimal characters and returns the positive integer that 16bit + * hexadecimal string represents. For example, "000f" will return 15, and "dead" + * will return 57005. + * + * Returns a negative number if any char was not a valid hexadecimal digit. + */ + +function read16BitHexCode(body, position) { + // readHexDigit() returns -1 on error. ORing a negative value with any other + // value always produces a negative value. + return ( + (readHexDigit(body.charCodeAt(position)) << 12) | + (readHexDigit(body.charCodeAt(position + 1)) << 8) | + (readHexDigit(body.charCodeAt(position + 2)) << 4) | + readHexDigit(body.charCodeAt(position + 3)) + ); +} +/** + * Reads a hexadecimal character and returns its positive integer value (0-15). + * + * '0' becomes 0, '9' becomes 9 + * 'A' becomes 10, 'F' becomes 15 + * 'a' becomes 10, 'f' becomes 15 + * + * Returns -1 if the provided character code was not a valid hexadecimal digit. + * + * HexDigit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * - `A` `B` `C` `D` `E` `F` + * - `a` `b` `c` `d` `e` `f` + */ + +function readHexDigit(code) { + return code >= 0x0030 && code <= 0x0039 // 0-9 + ? code - 0x0030 + : code >= 0x0041 && code <= 0x0046 // A-F + ? code - 0x0037 + : code >= 0x0061 && code <= 0x0066 // a-f + ? code - 0x0057 + : -1; +} +/** + * | Escaped Character | Code Point | Character Name | + * | ----------------- | ---------- | ---------------------------- | + * | `"` | U+0022 | double quote | + * | `\` | U+005C | reverse solidus (back slash) | + * | `/` | U+002F | solidus (forward slash) | + * | `b` | U+0008 | backspace | + * | `f` | U+000C | form feed | + * | `n` | U+000A | line feed (new line) | + * | `r` | U+000D | carriage return | + * | `t` | U+0009 | horizontal tab | + */ + +function readEscapedCharacter(lexer, position) { + const body = lexer.source.body; + const code = body.charCodeAt(position + 1); + + switch (code) { + case 0x0022: + // " + return { + value: '\u0022', + size: 2, + }; + + case 0x005c: + // \ + return { + value: '\u005c', + size: 2, + }; + + case 0x002f: + // / + return { + value: '\u002f', + size: 2, + }; + + case 0x0062: + // b + return { + value: '\u0008', + size: 2, + }; + + case 0x0066: + // f + return { + value: '\u000c', + size: 2, + }; + + case 0x006e: + // n + return { + value: '\u000a', + size: 2, + }; + + case 0x0072: + // r + return { + value: '\u000d', + size: 2, + }; + + case 0x0074: + // t + return { + value: '\u0009', + size: 2, + }; + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid character escape sequence: "${body.slice( + position, + position + 2, + )}".`, + ); +} +/** + * Reads a block string token from the source file. + * + * ``` + * StringValue :: + * - `"""` BlockStringCharacter* `"""` + * + * BlockStringCharacter :: + * - SourceCharacter but not `"""` or `\"""` + * - `\"""` + * ``` + */ + +function readBlockString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let lineStart = lexer.lineStart; + let position = start + 3; + let chunkStart = position; + let currentLine = ''; + const blockLines = []; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // Closing Triple-Quote (""") + + if ( + code === 0x0022 && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 + ) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + const token = createToken( + lexer, + _tokenKind.TokenKind.BLOCK_STRING, + start, + position + 3, // Return a string of the lines joined with U+000A. + (0, _blockString.dedentBlockStringLines)(blockLines).join('\n'), + ); + lexer.line += blockLines.length - 1; + lexer.lineStart = lineStart; + return token; + } // Escaped Triple-Quote (\""") + + if ( + code === 0x005c && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 && + body.charCodeAt(position + 3) === 0x0022 + ) { + currentLine += body.slice(chunkStart, position); + chunkStart = position + 1; // skip only slash + + position += 4; + continue; + } // LineTerminator + + if (code === 0x000a || code === 0x000d) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + + if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } else { + ++position; + } + + currentLine = ''; + chunkStart = position; + lineStart = position; + continue; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + `Invalid character within String: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } + + throw (0, _syntaxError.syntaxError)( + lexer.source, + position, + 'Unterminated string.', + ); +} +/** + * Reads an alphanumeric + underscore name from the source. + * + * ``` + * Name :: + * - NameStart NameContinue* [lookahead != NameContinue] + * ``` + */ + +function readName(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + + while (position < bodyLength) { + const code = body.charCodeAt(position); + + if ((0, _characterClasses.isNameContinue)(code)) { + ++position; + } else { + break; + } + } + + return createToken( + lexer, + _tokenKind.TokenKind.NAME, + start, + position, + body.slice(start, position), + ); +} + + +/***/ }), + +/***/ 61336: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getLocation = getLocation; + +var _invariant = __nccwpck_require__(52810); + +const LineRegExp = /\r\n|[\n\r]/g; +/** + * Represents a location in a Source. + */ + +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +function getLocation(source, position) { + let lastLineStart = 0; + let line = 1; + + for (const match of source.body.matchAll(LineRegExp)) { + typeof match.index === 'number' || (0, _invariant.invariant)(false); + + if (match.index >= position) { + break; + } + + lastLineStart = match.index + match[0].length; + line += 1; + } + + return { + line, + column: position + 1 - lastLineStart, + }; +} + + +/***/ }), + +/***/ 39927: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Parser = void 0; +exports.parse = parse; +exports.parseConstValue = parseConstValue; +exports.parseType = parseType; +exports.parseValue = parseValue; + +var _syntaxError = __nccwpck_require__(53373); + +var _ast = __nccwpck_require__(20727); + +var _directiveLocation = __nccwpck_require__(6128); + +var _kinds = __nccwpck_require__(19542); + +var _lexer = __nccwpck_require__(21363); + +var _source = __nccwpck_require__(29915); + +var _tokenKind = __nccwpck_require__(43148); + +/** + * Given a GraphQL source, parses it into a Document. + * Throws GraphQLError if a syntax error is encountered. + */ +function parse(source, options) { + const parser = new Parser(source, options); + return parser.parseDocument(); +} +/** + * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for + * that value. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Values directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: valueFromAST(). + */ + +function parseValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind.TokenKind.SOF); + const value = parser.parseValueLiteral(false); + parser.expectToken(_tokenKind.TokenKind.EOF); + return value; +} +/** + * Similar to parseValue(), but raises a parse error if it encounters a + * variable. The return type will be a constant value. + */ + +function parseConstValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind.TokenKind.SOF); + const value = parser.parseConstValueLiteral(); + parser.expectToken(_tokenKind.TokenKind.EOF); + return value; +} +/** + * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for + * that type. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Types directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: typeFromAST(). + */ + +function parseType(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind.TokenKind.SOF); + const type = parser.parseTypeReference(); + parser.expectToken(_tokenKind.TokenKind.EOF); + return type; +} +/** + * This class is exported only to assist people in implementing their own parsers + * without duplicating too much code and should be used only as last resort for cases + * such as experimental syntax or if certain features could not be contributed upstream. + * + * It is still part of the internal API and is versioned, so any changes to it are never + * considered breaking changes. If you still need to support multiple versions of the + * library, please use the `versionInfo` variable for version detection. + * + * @internal + */ + +class Parser { + constructor(source, options = {}) { + const sourceObj = (0, _source.isSource)(source) + ? source + : new _source.Source(source); + this._lexer = new _lexer.Lexer(sourceObj); + this._options = options; + this._tokenCounter = 0; + } + /** + * Converts a name lex token into a name parse node. + */ + + parseName() { + const token = this.expectToken(_tokenKind.TokenKind.NAME); + return this.node(token, { + kind: _kinds.Kind.NAME, + value: token.value, + }); + } // Implements the parsing rules in the Document section. + + /** + * Document : Definition+ + */ + + parseDocument() { + return this.node(this._lexer.token, { + kind: _kinds.Kind.DOCUMENT, + definitions: this.many( + _tokenKind.TokenKind.SOF, + this.parseDefinition, + _tokenKind.TokenKind.EOF, + ), + }); + } + /** + * Definition : + * - ExecutableDefinition + * - TypeSystemDefinition + * - TypeSystemExtension + * + * ExecutableDefinition : + * - OperationDefinition + * - FragmentDefinition + * + * TypeSystemDefinition : + * - SchemaDefinition + * - TypeDefinition + * - DirectiveDefinition + * + * TypeDefinition : + * - ScalarTypeDefinition + * - ObjectTypeDefinition + * - InterfaceTypeDefinition + * - UnionTypeDefinition + * - EnumTypeDefinition + * - InputObjectTypeDefinition + */ + + parseDefinition() { + if (this.peek(_tokenKind.TokenKind.BRACE_L)) { + return this.parseOperationDefinition(); + } // Many definitions begin with a description and require a lookahead. + + const hasDescription = this.peekDescription(); + const keywordToken = hasDescription + ? this._lexer.lookahead() + : this._lexer.token; + + if (keywordToken.kind === _tokenKind.TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaDefinition(); + + case 'scalar': + return this.parseScalarTypeDefinition(); + + case 'type': + return this.parseObjectTypeDefinition(); + + case 'interface': + return this.parseInterfaceTypeDefinition(); + + case 'union': + return this.parseUnionTypeDefinition(); + + case 'enum': + return this.parseEnumTypeDefinition(); + + case 'input': + return this.parseInputObjectTypeDefinition(); + + case 'directive': + return this.parseDirectiveDefinition(); + } + + if (hasDescription) { + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + this._lexer.token.start, + 'Unexpected description, descriptions are supported only on type definitions.', + ); + } + + switch (keywordToken.value) { + case 'query': + case 'mutation': + case 'subscription': + return this.parseOperationDefinition(); + + case 'fragment': + return this.parseFragmentDefinition(); + + case 'extend': + return this.parseTypeSystemExtension(); + } + } + + throw this.unexpected(keywordToken); + } // Implements the parsing rules in the Operations section. + + /** + * OperationDefinition : + * - SelectionSet + * - OperationType Name? VariableDefinitions? Directives? SelectionSet + */ + + parseOperationDefinition() { + const start = this._lexer.token; + + if (this.peek(_tokenKind.TokenKind.BRACE_L)) { + return this.node(start, { + kind: _kinds.Kind.OPERATION_DEFINITION, + operation: _ast.OperationTypeNode.QUERY, + name: undefined, + variableDefinitions: [], + directives: [], + selectionSet: this.parseSelectionSet(), + }); + } + + const operation = this.parseOperationType(); + let name; + + if (this.peek(_tokenKind.TokenKind.NAME)) { + name = this.parseName(); + } + + return this.node(start, { + kind: _kinds.Kind.OPERATION_DEFINITION, + operation, + name, + variableDefinitions: this.parseVariableDefinitions(), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * OperationType : one of query mutation subscription + */ + + parseOperationType() { + const operationToken = this.expectToken(_tokenKind.TokenKind.NAME); + + switch (operationToken.value) { + case 'query': + return _ast.OperationTypeNode.QUERY; + + case 'mutation': + return _ast.OperationTypeNode.MUTATION; + + case 'subscription': + return _ast.OperationTypeNode.SUBSCRIPTION; + } + + throw this.unexpected(operationToken); + } + /** + * VariableDefinitions : ( VariableDefinition+ ) + */ + + parseVariableDefinitions() { + return this.optionalMany( + _tokenKind.TokenKind.PAREN_L, + this.parseVariableDefinition, + _tokenKind.TokenKind.PAREN_R, + ); + } + /** + * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? + */ + + parseVariableDefinition() { + return this.node(this._lexer.token, { + kind: _kinds.Kind.VARIABLE_DEFINITION, + variable: this.parseVariable(), + type: + (this.expectToken(_tokenKind.TokenKind.COLON), + this.parseTypeReference()), + defaultValue: this.expectOptionalToken(_tokenKind.TokenKind.EQUALS) + ? this.parseConstValueLiteral() + : undefined, + directives: this.parseConstDirectives(), + }); + } + /** + * Variable : $ Name + */ + + parseVariable() { + const start = this._lexer.token; + this.expectToken(_tokenKind.TokenKind.DOLLAR); + return this.node(start, { + kind: _kinds.Kind.VARIABLE, + name: this.parseName(), + }); + } + /** + * ``` + * SelectionSet : { Selection+ } + * ``` + */ + + parseSelectionSet() { + return this.node(this._lexer.token, { + kind: _kinds.Kind.SELECTION_SET, + selections: this.many( + _tokenKind.TokenKind.BRACE_L, + this.parseSelection, + _tokenKind.TokenKind.BRACE_R, + ), + }); + } + /** + * Selection : + * - Field + * - FragmentSpread + * - InlineFragment + */ + + parseSelection() { + return this.peek(_tokenKind.TokenKind.SPREAD) + ? this.parseFragment() + : this.parseField(); + } + /** + * Field : Alias? Name Arguments? Directives? SelectionSet? + * + * Alias : Name : + */ + + parseField() { + const start = this._lexer.token; + const nameOrAlias = this.parseName(); + let alias; + let name; + + if (this.expectOptionalToken(_tokenKind.TokenKind.COLON)) { + alias = nameOrAlias; + name = this.parseName(); + } else { + name = nameOrAlias; + } + + return this.node(start, { + kind: _kinds.Kind.FIELD, + alias, + name, + arguments: this.parseArguments(false), + directives: this.parseDirectives(false), + selectionSet: this.peek(_tokenKind.TokenKind.BRACE_L) + ? this.parseSelectionSet() + : undefined, + }); + } + /** + * Arguments[Const] : ( Argument[?Const]+ ) + */ + + parseArguments(isConst) { + const item = isConst ? this.parseConstArgument : this.parseArgument; + return this.optionalMany( + _tokenKind.TokenKind.PAREN_L, + item, + _tokenKind.TokenKind.PAREN_R, + ); + } + /** + * Argument[Const] : Name : Value[?Const] + */ + + parseArgument(isConst = false) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(_tokenKind.TokenKind.COLON); + return this.node(start, { + kind: _kinds.Kind.ARGUMENT, + name, + value: this.parseValueLiteral(isConst), + }); + } + + parseConstArgument() { + return this.parseArgument(true); + } // Implements the parsing rules in the Fragments section. + + /** + * Corresponds to both FragmentSpread and InlineFragment in the spec. + * + * FragmentSpread : ... FragmentName Directives? + * + * InlineFragment : ... TypeCondition? Directives? SelectionSet + */ + + parseFragment() { + const start = this._lexer.token; + this.expectToken(_tokenKind.TokenKind.SPREAD); + const hasTypeCondition = this.expectOptionalKeyword('on'); + + if (!hasTypeCondition && this.peek(_tokenKind.TokenKind.NAME)) { + return this.node(start, { + kind: _kinds.Kind.FRAGMENT_SPREAD, + name: this.parseFragmentName(), + directives: this.parseDirectives(false), + }); + } + + return this.node(start, { + kind: _kinds.Kind.INLINE_FRAGMENT, + typeCondition: hasTypeCondition ? this.parseNamedType() : undefined, + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentDefinition : + * - fragment FragmentName on TypeCondition Directives? SelectionSet + * + * TypeCondition : NamedType + */ + + parseFragmentDefinition() { + const start = this._lexer.token; + this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes + // the grammar of FragmentDefinition: + // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet + + if (this._options.allowLegacyFragmentVariables === true) { + return this.node(start, { + kind: _kinds.Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + variableDefinitions: this.parseVariableDefinitions(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + + return this.node(start, { + kind: _kinds.Kind.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentName : Name but not `on` + */ + + parseFragmentName() { + if (this._lexer.token.value === 'on') { + throw this.unexpected(); + } + + return this.parseName(); + } // Implements the parsing rules in the Values section. + + /** + * Value[Const] : + * - [~Const] Variable + * - IntValue + * - FloatValue + * - StringValue + * - BooleanValue + * - NullValue + * - EnumValue + * - ListValue[?Const] + * - ObjectValue[?Const] + * + * BooleanValue : one of `true` `false` + * + * NullValue : `null` + * + * EnumValue : Name but not `true`, `false` or `null` + */ + + parseValueLiteral(isConst) { + const token = this._lexer.token; + + switch (token.kind) { + case _tokenKind.TokenKind.BRACKET_L: + return this.parseList(isConst); + + case _tokenKind.TokenKind.BRACE_L: + return this.parseObject(isConst); + + case _tokenKind.TokenKind.INT: + this.advanceLexer(); + return this.node(token, { + kind: _kinds.Kind.INT, + value: token.value, + }); + + case _tokenKind.TokenKind.FLOAT: + this.advanceLexer(); + return this.node(token, { + kind: _kinds.Kind.FLOAT, + value: token.value, + }); + + case _tokenKind.TokenKind.STRING: + case _tokenKind.TokenKind.BLOCK_STRING: + return this.parseStringLiteral(); + + case _tokenKind.TokenKind.NAME: + this.advanceLexer(); + + switch (token.value) { + case 'true': + return this.node(token, { + kind: _kinds.Kind.BOOLEAN, + value: true, + }); + + case 'false': + return this.node(token, { + kind: _kinds.Kind.BOOLEAN, + value: false, + }); + + case 'null': + return this.node(token, { + kind: _kinds.Kind.NULL, + }); + + default: + return this.node(token, { + kind: _kinds.Kind.ENUM, + value: token.value, + }); + } + + case _tokenKind.TokenKind.DOLLAR: + if (isConst) { + this.expectToken(_tokenKind.TokenKind.DOLLAR); + + if (this._lexer.token.kind === _tokenKind.TokenKind.NAME) { + const varName = this._lexer.token.value; + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + token.start, + `Unexpected variable "$${varName}" in constant value.`, + ); + } else { + throw this.unexpected(token); + } + } + + return this.parseVariable(); + + default: + throw this.unexpected(); + } + } + + parseConstValueLiteral() { + return this.parseValueLiteral(true); + } + + parseStringLiteral() { + const token = this._lexer.token; + this.advanceLexer(); + return this.node(token, { + kind: _kinds.Kind.STRING, + value: token.value, + block: token.kind === _tokenKind.TokenKind.BLOCK_STRING, + }); + } + /** + * ListValue[Const] : + * - [ ] + * - [ Value[?Const]+ ] + */ + + parseList(isConst) { + const item = () => this.parseValueLiteral(isConst); + + return this.node(this._lexer.token, { + kind: _kinds.Kind.LIST, + values: this.any( + _tokenKind.TokenKind.BRACKET_L, + item, + _tokenKind.TokenKind.BRACKET_R, + ), + }); + } + /** + * ``` + * ObjectValue[Const] : + * - { } + * - { ObjectField[?Const]+ } + * ``` + */ + + parseObject(isConst) { + const item = () => this.parseObjectField(isConst); + + return this.node(this._lexer.token, { + kind: _kinds.Kind.OBJECT, + fields: this.any( + _tokenKind.TokenKind.BRACE_L, + item, + _tokenKind.TokenKind.BRACE_R, + ), + }); + } + /** + * ObjectField[Const] : Name : Value[?Const] + */ + + parseObjectField(isConst) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(_tokenKind.TokenKind.COLON); + return this.node(start, { + kind: _kinds.Kind.OBJECT_FIELD, + name, + value: this.parseValueLiteral(isConst), + }); + } // Implements the parsing rules in the Directives section. + + /** + * Directives[Const] : Directive[?Const]+ + */ + + parseDirectives(isConst) { + const directives = []; + + while (this.peek(_tokenKind.TokenKind.AT)) { + directives.push(this.parseDirective(isConst)); + } + + return directives; + } + + parseConstDirectives() { + return this.parseDirectives(true); + } + /** + * ``` + * Directive[Const] : @ Name Arguments[?Const]? + * ``` + */ + + parseDirective(isConst) { + const start = this._lexer.token; + this.expectToken(_tokenKind.TokenKind.AT); + return this.node(start, { + kind: _kinds.Kind.DIRECTIVE, + name: this.parseName(), + arguments: this.parseArguments(isConst), + }); + } // Implements the parsing rules in the Types section. + + /** + * Type : + * - NamedType + * - ListType + * - NonNullType + */ + + parseTypeReference() { + const start = this._lexer.token; + let type; + + if (this.expectOptionalToken(_tokenKind.TokenKind.BRACKET_L)) { + const innerType = this.parseTypeReference(); + this.expectToken(_tokenKind.TokenKind.BRACKET_R); + type = this.node(start, { + kind: _kinds.Kind.LIST_TYPE, + type: innerType, + }); + } else { + type = this.parseNamedType(); + } + + if (this.expectOptionalToken(_tokenKind.TokenKind.BANG)) { + return this.node(start, { + kind: _kinds.Kind.NON_NULL_TYPE, + type, + }); + } + + return type; + } + /** + * NamedType : Name + */ + + parseNamedType() { + return this.node(this._lexer.token, { + kind: _kinds.Kind.NAMED_TYPE, + name: this.parseName(), + }); + } // Implements the parsing rules in the Type Definition section. + + peekDescription() { + return ( + this.peek(_tokenKind.TokenKind.STRING) || + this.peek(_tokenKind.TokenKind.BLOCK_STRING) + ); + } + /** + * Description : StringValue + */ + + parseDescription() { + if (this.peekDescription()) { + return this.parseStringLiteral(); + } + } + /** + * ``` + * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } + * ``` + */ + + parseSchemaDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.many( + _tokenKind.TokenKind.BRACE_L, + this.parseOperationTypeDefinition, + _tokenKind.TokenKind.BRACE_R, + ); + return this.node(start, { + kind: _kinds.Kind.SCHEMA_DEFINITION, + description, + directives, + operationTypes, + }); + } + /** + * OperationTypeDefinition : OperationType : NamedType + */ + + parseOperationTypeDefinition() { + const start = this._lexer.token; + const operation = this.parseOperationType(); + this.expectToken(_tokenKind.TokenKind.COLON); + const type = this.parseNamedType(); + return this.node(start, { + kind: _kinds.Kind.OPERATION_TYPE_DEFINITION, + operation, + type, + }); + } + /** + * ScalarTypeDefinition : Description? scalar Name Directives[Const]? + */ + + parseScalarTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds.Kind.SCALAR_TYPE_DEFINITION, + description, + name, + directives, + }); + } + /** + * ObjectTypeDefinition : + * Description? + * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? + */ + + parseObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: _kinds.Kind.OBJECT_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * ImplementsInterfaces : + * - implements `&`? NamedType + * - ImplementsInterfaces & NamedType + */ + + parseImplementsInterfaces() { + return this.expectOptionalKeyword('implements') + ? this.delimitedMany(_tokenKind.TokenKind.AMP, this.parseNamedType) + : []; + } + /** + * ``` + * FieldsDefinition : { FieldDefinition+ } + * ``` + */ + + parseFieldsDefinition() { + return this.optionalMany( + _tokenKind.TokenKind.BRACE_L, + this.parseFieldDefinition, + _tokenKind.TokenKind.BRACE_R, + ); + } + /** + * FieldDefinition : + * - Description? Name ArgumentsDefinition? : Type Directives[Const]? + */ + + parseFieldDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + this.expectToken(_tokenKind.TokenKind.COLON); + const type = this.parseTypeReference(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds.Kind.FIELD_DEFINITION, + description, + name, + arguments: args, + type, + directives, + }); + } + /** + * ArgumentsDefinition : ( InputValueDefinition+ ) + */ + + parseArgumentDefs() { + return this.optionalMany( + _tokenKind.TokenKind.PAREN_L, + this.parseInputValueDef, + _tokenKind.TokenKind.PAREN_R, + ); + } + /** + * InputValueDefinition : + * - Description? Name : Type DefaultValue? Directives[Const]? + */ + + parseInputValueDef() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + this.expectToken(_tokenKind.TokenKind.COLON); + const type = this.parseTypeReference(); + let defaultValue; + + if (this.expectOptionalToken(_tokenKind.TokenKind.EQUALS)) { + defaultValue = this.parseConstValueLiteral(); + } + + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds.Kind.INPUT_VALUE_DEFINITION, + description, + name, + type, + defaultValue, + directives, + }); + } + /** + * InterfaceTypeDefinition : + * - Description? interface Name Directives[Const]? FieldsDefinition? + */ + + parseInterfaceTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: _kinds.Kind.INTERFACE_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeDefinition : + * - Description? union Name Directives[Const]? UnionMemberTypes? + */ + + parseUnionTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + return this.node(start, { + kind: _kinds.Kind.UNION_TYPE_DEFINITION, + description, + name, + directives, + types, + }); + } + /** + * UnionMemberTypes : + * - = `|`? NamedType + * - UnionMemberTypes | NamedType + */ + + parseUnionMemberTypes() { + return this.expectOptionalToken(_tokenKind.TokenKind.EQUALS) + ? this.delimitedMany(_tokenKind.TokenKind.PIPE, this.parseNamedType) + : []; + } + /** + * EnumTypeDefinition : + * - Description? enum Name Directives[Const]? EnumValuesDefinition? + */ + + parseEnumTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + return this.node(start, { + kind: _kinds.Kind.ENUM_TYPE_DEFINITION, + description, + name, + directives, + values, + }); + } + /** + * ``` + * EnumValuesDefinition : { EnumValueDefinition+ } + * ``` + */ + + parseEnumValuesDefinition() { + return this.optionalMany( + _tokenKind.TokenKind.BRACE_L, + this.parseEnumValueDefinition, + _tokenKind.TokenKind.BRACE_R, + ); + } + /** + * EnumValueDefinition : Description? EnumValue Directives[Const]? + */ + + parseEnumValueDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseEnumValueName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds.Kind.ENUM_VALUE_DEFINITION, + description, + name, + directives, + }); + } + /** + * EnumValue : Name but not `true`, `false` or `null` + */ + + parseEnumValueName() { + if ( + this._lexer.token.value === 'true' || + this._lexer.token.value === 'false' || + this._lexer.token.value === 'null' + ) { + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + this._lexer.token.start, + `${getTokenDesc( + this._lexer.token, + )} is reserved and cannot be used for an enum value.`, + ); + } + + return this.parseName(); + } + /** + * InputObjectTypeDefinition : + * - Description? input Name Directives[Const]? InputFieldsDefinition? + */ + + parseInputObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + return this.node(start, { + kind: _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION, + description, + name, + directives, + fields, + }); + } + /** + * ``` + * InputFieldsDefinition : { InputValueDefinition+ } + * ``` + */ + + parseInputFieldsDefinition() { + return this.optionalMany( + _tokenKind.TokenKind.BRACE_L, + this.parseInputValueDef, + _tokenKind.TokenKind.BRACE_R, + ); + } + /** + * TypeSystemExtension : + * - SchemaExtension + * - TypeExtension + * + * TypeExtension : + * - ScalarTypeExtension + * - ObjectTypeExtension + * - InterfaceTypeExtension + * - UnionTypeExtension + * - EnumTypeExtension + * - InputObjectTypeDefinition + */ + + parseTypeSystemExtension() { + const keywordToken = this._lexer.lookahead(); + + if (keywordToken.kind === _tokenKind.TokenKind.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaExtension(); + + case 'scalar': + return this.parseScalarTypeExtension(); + + case 'type': + return this.parseObjectTypeExtension(); + + case 'interface': + return this.parseInterfaceTypeExtension(); + + case 'union': + return this.parseUnionTypeExtension(); + + case 'enum': + return this.parseEnumTypeExtension(); + + case 'input': + return this.parseInputObjectTypeExtension(); + } + } + + throw this.unexpected(keywordToken); + } + /** + * ``` + * SchemaExtension : + * - extend schema Directives[Const]? { OperationTypeDefinition+ } + * - extend schema Directives[Const] + * ``` + */ + + parseSchemaExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.optionalMany( + _tokenKind.TokenKind.BRACE_L, + this.parseOperationTypeDefinition, + _tokenKind.TokenKind.BRACE_R, + ); + + if (directives.length === 0 && operationTypes.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.SCHEMA_EXTENSION, + directives, + operationTypes, + }); + } + /** + * ScalarTypeExtension : + * - extend scalar Name Directives[Const] + */ + + parseScalarTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + + if (directives.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.SCALAR_TYPE_EXTENSION, + name, + directives, + }); + } + /** + * ObjectTypeExtension : + * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend type Name ImplementsInterfaces? Directives[Const] + * - extend type Name ImplementsInterfaces + */ + + parseObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + + if ( + interfaces.length === 0 && + directives.length === 0 && + fields.length === 0 + ) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.OBJECT_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * InterfaceTypeExtension : + * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend interface Name ImplementsInterfaces? Directives[Const] + * - extend interface Name ImplementsInterfaces + */ + + parseInterfaceTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + + if ( + interfaces.length === 0 && + directives.length === 0 && + fields.length === 0 + ) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.INTERFACE_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeExtension : + * - extend union Name Directives[Const]? UnionMemberTypes + * - extend union Name Directives[Const] + */ + + parseUnionTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + + if (directives.length === 0 && types.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.UNION_TYPE_EXTENSION, + name, + directives, + types, + }); + } + /** + * EnumTypeExtension : + * - extend enum Name Directives[Const]? EnumValuesDefinition + * - extend enum Name Directives[Const] + */ + + parseEnumTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + + if (directives.length === 0 && values.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.ENUM_TYPE_EXTENSION, + name, + directives, + values, + }); + } + /** + * InputObjectTypeExtension : + * - extend input Name Directives[Const]? InputFieldsDefinition + * - extend input Name Directives[Const] + */ + + parseInputObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + + if (directives.length === 0 && fields.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION, + name, + directives, + fields, + }); + } + /** + * ``` + * DirectiveDefinition : + * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations + * ``` + */ + + parseDirectiveDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('directive'); + this.expectToken(_tokenKind.TokenKind.AT); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + const repeatable = this.expectOptionalKeyword('repeatable'); + this.expectKeyword('on'); + const locations = this.parseDirectiveLocations(); + return this.node(start, { + kind: _kinds.Kind.DIRECTIVE_DEFINITION, + description, + name, + arguments: args, + repeatable, + locations, + }); + } + /** + * DirectiveLocations : + * - `|`? DirectiveLocation + * - DirectiveLocations | DirectiveLocation + */ + + parseDirectiveLocations() { + return this.delimitedMany( + _tokenKind.TokenKind.PIPE, + this.parseDirectiveLocation, + ); + } + /* + * DirectiveLocation : + * - ExecutableDirectiveLocation + * - TypeSystemDirectiveLocation + * + * ExecutableDirectiveLocation : one of + * `QUERY` + * `MUTATION` + * `SUBSCRIPTION` + * `FIELD` + * `FRAGMENT_DEFINITION` + * `FRAGMENT_SPREAD` + * `INLINE_FRAGMENT` + * + * TypeSystemDirectiveLocation : one of + * `SCHEMA` + * `SCALAR` + * `OBJECT` + * `FIELD_DEFINITION` + * `ARGUMENT_DEFINITION` + * `INTERFACE` + * `UNION` + * `ENUM` + * `ENUM_VALUE` + * `INPUT_OBJECT` + * `INPUT_FIELD_DEFINITION` + */ + + parseDirectiveLocation() { + const start = this._lexer.token; + const name = this.parseName(); + + if ( + Object.prototype.hasOwnProperty.call( + _directiveLocation.DirectiveLocation, + name.value, + ) + ) { + return name; + } + + throw this.unexpected(start); + } // Core parsing utility functions + + /** + * Returns a node that, if configured to do so, sets a "loc" field as a + * location object, used to identify the place in the source that created a + * given parsed object. + */ + + node(startToken, node) { + if (this._options.noLocation !== true) { + node.loc = new _ast.Location( + startToken, + this._lexer.lastToken, + this._lexer.source, + ); + } + + return node; + } + /** + * Determines if the next token is of a given kind + */ + + peek(kind) { + return this._lexer.token.kind === kind; + } + /** + * If the next token is of the given kind, return that token after advancing the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + + expectToken(kind) { + const token = this._lexer.token; + + if (token.kind === kind) { + this.advanceLexer(); + return token; + } + + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + token.start, + `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`, + ); + } + /** + * If the next token is of the given kind, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + + expectOptionalToken(kind) { + const token = this._lexer.token; + + if (token.kind === kind) { + this.advanceLexer(); + return true; + } + + return false; + } + /** + * If the next token is a given keyword, advance the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + + expectKeyword(value) { + const token = this._lexer.token; + + if (token.kind === _tokenKind.TokenKind.NAME && token.value === value) { + this.advanceLexer(); + } else { + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + token.start, + `Expected "${value}", found ${getTokenDesc(token)}.`, + ); + } + } + /** + * If the next token is a given keyword, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + + expectOptionalKeyword(value) { + const token = this._lexer.token; + + if (token.kind === _tokenKind.TokenKind.NAME && token.value === value) { + this.advanceLexer(); + return true; + } + + return false; + } + /** + * Helper function for creating an error when an unexpected lexed token is encountered. + */ + + unexpected(atToken) { + const token = + atToken !== null && atToken !== void 0 ? atToken : this._lexer.token; + return (0, _syntaxError.syntaxError)( + this._lexer.source, + token.start, + `Unexpected ${getTokenDesc(token)}.`, + ); + } + /** + * Returns a possibly empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + any(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + + while (!this.expectOptionalToken(closeKind)) { + nodes.push(parseFn.call(this)); + } + + return nodes; + } + /** + * Returns a list of parse nodes, determined by the parseFn. + * It can be empty only if open token is missing otherwise it will always return non-empty list + * that begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + optionalMany(openKind, parseFn, closeKind) { + if (this.expectOptionalToken(openKind)) { + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + + return nodes; + } + + return []; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + many(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + + return nodes; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. + * Advances the parser to the next lex token after last item in the list. + */ + + delimitedMany(delimiterKind, parseFn) { + this.expectOptionalToken(delimiterKind); + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (this.expectOptionalToken(delimiterKind)); + + return nodes; + } + + advanceLexer() { + const { maxTokens } = this._options; + + const token = this._lexer.advance(); + + if (maxTokens !== undefined && token.kind !== _tokenKind.TokenKind.EOF) { + ++this._tokenCounter; + + if (this._tokenCounter > maxTokens) { + throw (0, _syntaxError.syntaxError)( + this._lexer.source, + token.start, + `Document contains more that ${maxTokens} tokens. Parsing aborted.`, + ); + } + } + } +} +/** + * A helper function to describe a token as a string for debugging. + */ + +exports.Parser = Parser; + +function getTokenDesc(token) { + const value = token.value; + return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : ''); +} +/** + * A helper function to describe a token kind as a string for debugging. + */ + +function getTokenKindDesc(kind) { + return (0, _lexer.isPunctuatorTokenKind)(kind) ? `"${kind}"` : kind; +} + + +/***/ }), + +/***/ 2493: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isConstValueNode = isConstValueNode; +exports.isDefinitionNode = isDefinitionNode; +exports.isExecutableDefinitionNode = isExecutableDefinitionNode; +exports.isSelectionNode = isSelectionNode; +exports.isTypeDefinitionNode = isTypeDefinitionNode; +exports.isTypeExtensionNode = isTypeExtensionNode; +exports.isTypeNode = isTypeNode; +exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode; +exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode; +exports.isValueNode = isValueNode; + +var _kinds = __nccwpck_require__(19542); + +function isDefinitionNode(node) { + return ( + isExecutableDefinitionNode(node) || + isTypeSystemDefinitionNode(node) || + isTypeSystemExtensionNode(node) + ); +} + +function isExecutableDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.OPERATION_DEFINITION || + node.kind === _kinds.Kind.FRAGMENT_DEFINITION + ); +} + +function isSelectionNode(node) { + return ( + node.kind === _kinds.Kind.FIELD || + node.kind === _kinds.Kind.FRAGMENT_SPREAD || + node.kind === _kinds.Kind.INLINE_FRAGMENT + ); +} + +function isValueNode(node) { + return ( + node.kind === _kinds.Kind.VARIABLE || + node.kind === _kinds.Kind.INT || + node.kind === _kinds.Kind.FLOAT || + node.kind === _kinds.Kind.STRING || + node.kind === _kinds.Kind.BOOLEAN || + node.kind === _kinds.Kind.NULL || + node.kind === _kinds.Kind.ENUM || + node.kind === _kinds.Kind.LIST || + node.kind === _kinds.Kind.OBJECT + ); +} + +function isConstValueNode(node) { + return ( + isValueNode(node) && + (node.kind === _kinds.Kind.LIST + ? node.values.some(isConstValueNode) + : node.kind === _kinds.Kind.OBJECT + ? node.fields.some((field) => isConstValueNode(field.value)) + : node.kind !== _kinds.Kind.VARIABLE) + ); +} + +function isTypeNode(node) { + return ( + node.kind === _kinds.Kind.NAMED_TYPE || + node.kind === _kinds.Kind.LIST_TYPE || + node.kind === _kinds.Kind.NON_NULL_TYPE + ); +} + +function isTypeSystemDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.SCHEMA_DEFINITION || + isTypeDefinitionNode(node) || + node.kind === _kinds.Kind.DIRECTIVE_DEFINITION + ); +} + +function isTypeDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.SCALAR_TYPE_DEFINITION || + node.kind === _kinds.Kind.OBJECT_TYPE_DEFINITION || + node.kind === _kinds.Kind.INTERFACE_TYPE_DEFINITION || + node.kind === _kinds.Kind.UNION_TYPE_DEFINITION || + node.kind === _kinds.Kind.ENUM_TYPE_DEFINITION || + node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION + ); +} + +function isTypeSystemExtensionNode(node) { + return ( + node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node) + ); +} + +function isTypeExtensionNode(node) { + return ( + node.kind === _kinds.Kind.SCALAR_TYPE_EXTENSION || + node.kind === _kinds.Kind.OBJECT_TYPE_EXTENSION || + node.kind === _kinds.Kind.INTERFACE_TYPE_EXTENSION || + node.kind === _kinds.Kind.UNION_TYPE_EXTENSION || + node.kind === _kinds.Kind.ENUM_TYPE_EXTENSION || + node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION + ); +} + + +/***/ }), + +/***/ 29983: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printLocation = printLocation; +exports.printSourceLocation = printSourceLocation; + +var _location = __nccwpck_require__(61336); + +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +function printLocation(location) { + return printSourceLocation( + location.source, + (0, _location.getLocation)(location.source, location.start), + ); +} +/** + * Render a helpful description of the location in the GraphQL Source document. + */ + +function printSourceLocation(source, sourceLocation) { + const firstLineColumnOffset = source.locationOffset.column - 1; + const body = ''.padStart(firstLineColumnOffset) + source.body; + const lineIndex = sourceLocation.line - 1; + const lineOffset = source.locationOffset.line - 1; + const lineNum = sourceLocation.line + lineOffset; + const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; + const columnNum = sourceLocation.column + columnOffset; + const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; + const lines = body.split(/\r\n|[\n\r]/g); + const locationLine = lines[lineIndex]; // Special case for minified documents + + if (locationLine.length > 120) { + const subLineIndex = Math.floor(columnNum / 80); + const subLineColumnNum = columnNum % 80; + const subLines = []; + + for (let i = 0; i < locationLine.length; i += 80) { + subLines.push(locationLine.slice(i, i + 80)); + } + + return ( + locationStr + + printPrefixedLines([ + [`${lineNum} |`, subLines[0]], + ...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]), + ['|', '^'.padStart(subLineColumnNum)], + ['|', subLines[subLineIndex + 1]], + ]) + ); + } + + return ( + locationStr + + printPrefixedLines([ + // Lines specified like this: ["prefix", "string"], + [`${lineNum - 1} |`, lines[lineIndex - 1]], + [`${lineNum} |`, locationLine], + ['|', '^'.padStart(columnNum)], + [`${lineNum + 1} |`, lines[lineIndex + 1]], + ]) + ); +} + +function printPrefixedLines(lines) { + const existingLines = lines.filter(([_, line]) => line !== undefined); + const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); + return existingLines + .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) + .join('\n'); +} + + +/***/ }), + +/***/ 9997: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printString = printString; + +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +function printString(str) { + return `"${str.replace(escapedRegExp, escapedReplacer)}"`; +} // eslint-disable-next-line no-control-regex + +const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; + +function escapedReplacer(str) { + return escapeSequences[str.charCodeAt(0)]; +} // prettier-ignore + +const escapeSequences = [ + '\\u0000', + '\\u0001', + '\\u0002', + '\\u0003', + '\\u0004', + '\\u0005', + '\\u0006', + '\\u0007', + '\\b', + '\\t', + '\\n', + '\\u000B', + '\\f', + '\\r', + '\\u000E', + '\\u000F', + '\\u0010', + '\\u0011', + '\\u0012', + '\\u0013', + '\\u0014', + '\\u0015', + '\\u0016', + '\\u0017', + '\\u0018', + '\\u0019', + '\\u001A', + '\\u001B', + '\\u001C', + '\\u001D', + '\\u001E', + '\\u001F', + '', + '', + '\\"', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 2F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 3F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 4F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\\\', + '', + '', + '', // 5F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 6F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\u007F', + '\\u0080', + '\\u0081', + '\\u0082', + '\\u0083', + '\\u0084', + '\\u0085', + '\\u0086', + '\\u0087', + '\\u0088', + '\\u0089', + '\\u008A', + '\\u008B', + '\\u008C', + '\\u008D', + '\\u008E', + '\\u008F', + '\\u0090', + '\\u0091', + '\\u0092', + '\\u0093', + '\\u0094', + '\\u0095', + '\\u0096', + '\\u0097', + '\\u0098', + '\\u0099', + '\\u009A', + '\\u009B', + '\\u009C', + '\\u009D', + '\\u009E', + '\\u009F', +]; + + +/***/ }), + +/***/ 3099: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.print = print; + +var _blockString = __nccwpck_require__(79685); + +var _printString = __nccwpck_require__(9997); + +var _visitor = __nccwpck_require__(45946); + +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +function print(ast) { + return (0, _visitor.visit)(ast, printDocASTReducer); +} + +const MAX_LINE_LENGTH = 80; +const printDocASTReducer = { + Name: { + leave: (node) => node.value, + }, + Variable: { + leave: (node) => '$' + node.name, + }, + // Document + Document: { + leave: (node) => join(node.definitions, '\n\n'), + }, + OperationDefinition: { + leave(node) { + const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + const prefix = join( + [ + node.operation, + join([node.name, varDefs]), + join(node.directives, ' '), + ], + ' ', + ); // Anonymous queries with no directives or variable definitions can use + // the query short form. + + return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; + }, + }, + VariableDefinition: { + leave: ({ variable, type, defaultValue, directives }) => + variable + + ': ' + + type + + wrap(' = ', defaultValue) + + wrap(' ', join(directives, ' ')), + }, + SelectionSet: { + leave: ({ selections }) => block(selections), + }, + Field: { + leave({ alias, name, arguments: args, directives, selectionSet }) { + const prefix = wrap('', alias, ': ') + name; + let argsLine = prefix + wrap('(', join(args, ', '), ')'); + + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + + return join([argsLine, join(directives, ' '), selectionSet], ' '); + }, + }, + Argument: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Fragments + FragmentSpread: { + leave: ({ name, directives }) => + '...' + name + wrap(' ', join(directives, ' ')), + }, + InlineFragment: { + leave: ({ typeCondition, directives, selectionSet }) => + join( + [ + '...', + wrap('on ', typeCondition), + join(directives, ' '), + selectionSet, + ], + ' ', + ), + }, + FragmentDefinition: { + leave: ( + { name, typeCondition, variableDefinitions, directives, selectionSet }, // Note: fragment variable definitions are experimental and may be changed + ) => + // or removed in the future. + `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + + selectionSet, + }, + // Value + IntValue: { + leave: ({ value }) => value, + }, + FloatValue: { + leave: ({ value }) => value, + }, + StringValue: { + leave: ({ value, block: isBlockString }) => + isBlockString + ? (0, _blockString.printBlockString)(value) + : (0, _printString.printString)(value), + }, + BooleanValue: { + leave: ({ value }) => (value ? 'true' : 'false'), + }, + NullValue: { + leave: () => 'null', + }, + EnumValue: { + leave: ({ value }) => value, + }, + ListValue: { + leave: ({ values }) => '[' + join(values, ', ') + ']', + }, + ObjectValue: { + leave: ({ fields }) => '{' + join(fields, ', ') + '}', + }, + ObjectField: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Directive + Directive: { + leave: ({ name, arguments: args }) => + '@' + name + wrap('(', join(args, ', '), ')'), + }, + // Type + NamedType: { + leave: ({ name }) => name, + }, + ListType: { + leave: ({ type }) => '[' + type + ']', + }, + NonNullType: { + leave: ({ type }) => type + '!', + }, + // Type System Definitions + SchemaDefinition: { + leave: ({ description, directives, operationTypes }) => + wrap('', description, '\n') + + join(['schema', join(directives, ' '), block(operationTypes)], ' '), + }, + OperationTypeDefinition: { + leave: ({ operation, type }) => operation + ': ' + type, + }, + ScalarTypeDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + + join(['scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + FieldDefinition: { + leave: ({ description, name, arguments: args, type, directives }) => + wrap('', description, '\n') + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + ': ' + + type + + wrap(' ', join(directives, ' ')), + }, + InputValueDefinition: { + leave: ({ description, name, type, defaultValue, directives }) => + wrap('', description, '\n') + + join( + [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], + ' ', + ), + }, + InterfaceTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeDefinition: { + leave: ({ description, name, directives, types }) => + wrap('', description, '\n') + + join( + ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], + ' ', + ), + }, + EnumTypeDefinition: { + leave: ({ description, name, directives, values }) => + wrap('', description, '\n') + + join(['enum', name, join(directives, ' '), block(values)], ' '), + }, + EnumValueDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), + }, + InputObjectTypeDefinition: { + leave: ({ description, name, directives, fields }) => + wrap('', description, '\n') + + join(['input', name, join(directives, ' '), block(fields)], ' '), + }, + DirectiveDefinition: { + leave: ({ description, name, arguments: args, repeatable, locations }) => + wrap('', description, '\n') + + 'directive @' + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + (repeatable ? ' repeatable' : '') + + ' on ' + + join(locations, ' | '), + }, + SchemaExtension: { + leave: ({ directives, operationTypes }) => + join( + ['extend schema', join(directives, ' '), block(operationTypes)], + ' ', + ), + }, + ScalarTypeExtension: { + leave: ({ name, directives }) => + join(['extend scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + InterfaceTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeExtension: { + leave: ({ name, directives, types }) => + join( + [ + 'extend union', + name, + join(directives, ' '), + wrap('= ', join(types, ' | ')), + ], + ' ', + ), + }, + EnumTypeExtension: { + leave: ({ name, directives, values }) => + join(['extend enum', name, join(directives, ' '), block(values)], ' '), + }, + InputObjectTypeExtension: { + leave: ({ name, directives, fields }) => + join(['extend input', name, join(directives, ' '), block(fields)], ' '), + }, +}; +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ + +function join(maybeArray, separator = '') { + var _maybeArray$filter$jo; + + return (_maybeArray$filter$jo = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.filter((x) => x).join(separator)) !== null && + _maybeArray$filter$jo !== void 0 + ? _maybeArray$filter$jo + : ''; +} +/** + * Given array, print each item on its own line, wrapped in an indented `{ }` block. + */ + +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ + +function wrap(start, maybeString, end = '') { + return maybeString != null && maybeString !== '' + ? start + maybeString + end + : ''; +} + +function indent(str) { + return wrap(' ', str.replace(/\n/g, '\n ')); +} + +function hasMultilineItems(maybeArray) { + var _maybeArray$some; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + return (_maybeArray$some = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.some((str) => str.includes('\n'))) !== null && + _maybeArray$some !== void 0 + ? _maybeArray$some + : false; +} + + +/***/ }), + +/***/ 29915: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Source = void 0; +exports.isSource = isSource; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _instanceOf = __nccwpck_require__(92830); + +/** + * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are + * optional, but they are useful for clients who store GraphQL documents in source files. + * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might + * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. + * The `line` and `column` properties in `locationOffset` are 1-indexed. + */ +class Source { + constructor( + body, + name = 'GraphQL request', + locationOffset = { + line: 1, + column: 1, + }, + ) { + typeof body === 'string' || + (0, _devAssert.devAssert)( + false, + `Body must be a string. Received: ${(0, _inspect.inspect)(body)}.`, + ); + this.body = body; + this.name = name; + this.locationOffset = locationOffset; + this.locationOffset.line > 0 || + (0, _devAssert.devAssert)( + false, + 'line in locationOffset is 1-indexed and must be positive.', + ); + this.locationOffset.column > 0 || + (0, _devAssert.devAssert)( + false, + 'column in locationOffset is 1-indexed and must be positive.', + ); + } + + get [Symbol.toStringTag]() { + return 'Source'; + } +} +/** + * Test if the given value is a Source object. + * + * @internal + */ + +exports.Source = Source; + +function isSource(source) { + return (0, _instanceOf.instanceOf)(source, Source); +} + + +/***/ }), + +/***/ 43148: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.TokenKind = void 0; + +/** + * An exported enum describing the different kinds of tokens that the + * lexer emits. + */ +var TokenKind; +exports.TokenKind = TokenKind; + +(function (TokenKind) { + TokenKind['SOF'] = ''; + TokenKind['EOF'] = ''; + TokenKind['BANG'] = '!'; + TokenKind['DOLLAR'] = '$'; + TokenKind['AMP'] = '&'; + TokenKind['PAREN_L'] = '('; + TokenKind['PAREN_R'] = ')'; + TokenKind['SPREAD'] = '...'; + TokenKind['COLON'] = ':'; + TokenKind['EQUALS'] = '='; + TokenKind['AT'] = '@'; + TokenKind['BRACKET_L'] = '['; + TokenKind['BRACKET_R'] = ']'; + TokenKind['BRACE_L'] = '{'; + TokenKind['PIPE'] = '|'; + TokenKind['BRACE_R'] = '}'; + TokenKind['NAME'] = 'Name'; + TokenKind['INT'] = 'Int'; + TokenKind['FLOAT'] = 'Float'; + TokenKind['STRING'] = 'String'; + TokenKind['BLOCK_STRING'] = 'BlockString'; + TokenKind['COMMENT'] = 'Comment'; +})(TokenKind || (exports.TokenKind = TokenKind = {})); +/** + * The enum type representing the token kinds values. + * + * @deprecated Please use `TokenKind`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 45946: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.BREAK = void 0; +exports.getEnterLeaveForKind = getEnterLeaveForKind; +exports.getVisitFn = getVisitFn; +exports.visit = visit; +exports.visitInParallel = visitInParallel; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _ast = __nccwpck_require__(20727); + +var _kinds = __nccwpck_require__(19542); + +const BREAK = Object.freeze({}); +/** + * visit() will walk through an AST using a depth-first traversal, calling + * the visitor's enter function at each node in the traversal, and calling the + * leave function after visiting that node and all of its child nodes. + * + * By returning different values from the enter and leave functions, the + * behavior of the visitor can be altered, including skipping over a sub-tree of + * the AST (by returning false), editing the AST by returning a value or null + * to remove the value, or to stop the whole traversal by returning BREAK. + * + * When using visit() to edit an AST, the original AST will not be modified, and + * a new version of the AST with the changes applied will be returned from the + * visit function. + * + * ```ts + * const editedAST = visit(ast, { + * enter(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: skip visiting this node + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * }, + * leave(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: no action + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * } + * }); + * ``` + * + * Alternatively to providing enter() and leave() functions, a visitor can + * instead provide functions named the same as the kinds of AST nodes, or + * enter/leave visitors at a named key, leading to three permutations of the + * visitor API: + * + * 1) Named visitors triggered when entering a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind(node) { + * // enter the "Kind" node + * } + * }) + * ``` + * + * 2) Named visitors that trigger upon entering and leaving a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind: { + * enter(node) { + * // enter the "Kind" node + * } + * leave(node) { + * // leave the "Kind" node + * } + * } + * }) + * ``` + * + * 3) Generic visitors that trigger upon entering and leaving any node. + * + * ```ts + * visit(ast, { + * enter(node) { + * // enter any node + * }, + * leave(node) { + * // leave any node + * } + * }) + * ``` + */ + +exports.BREAK = BREAK; + +function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { + const enterLeaveMap = new Map(); + + for (const kind of Object.values(_kinds.Kind)) { + enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); + } + /* eslint-disable no-undef-init */ + + let stack = undefined; + let inArray = Array.isArray(root); + let keys = [root]; + let index = -1; + let edits = []; + let node = root; + let key = undefined; + let parent = undefined; + const path = []; + const ancestors = []; + /* eslint-enable no-undef-init */ + + do { + index++; + const isLeaving = index === keys.length; + const isEdited = isLeaving && edits.length !== 0; + + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); + + if (isEdited) { + if (inArray) { + node = node.slice(); + let editOffset = 0; + + for (const [editKey, editValue] of edits) { + const arrayKey = editKey - editOffset; + + if (editValue === null) { + node.splice(arrayKey, 1); + editOffset++; + } else { + node[arrayKey] = editValue; + } + } + } else { + node = Object.defineProperties( + {}, + Object.getOwnPropertyDescriptors(node), + ); + + for (const [editKey, editValue] of edits) { + node[editKey] = editValue; + } + } + } + + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } else if (parent) { + key = inArray ? index : keys[index]; + node = parent[key]; + + if (node === null || node === undefined) { + continue; + } + + path.push(key); + } + + let result; + + if (!Array.isArray(node)) { + var _enterLeaveMap$get, _enterLeaveMap$get2; + + (0, _ast.isNode)(node) || + (0, _devAssert.devAssert)( + false, + `Invalid AST Node: ${(0, _inspect.inspect)(node)}.`, + ); + const visitFn = isLeaving + ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get === void 0 + ? void 0 + : _enterLeaveMap$get.leave + : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get2 === void 0 + ? void 0 + : _enterLeaveMap$get2.enter; + result = + visitFn === null || visitFn === void 0 + ? void 0 + : visitFn.call(visitor, node, key, parent, path, ancestors); + + if (result === BREAK) { + break; + } + + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } else if (result !== undefined) { + edits.push([key, result]); + + if (!isLeaving) { + if ((0, _ast.isNode)(result)) { + node = result; + } else { + path.pop(); + continue; + } + } + } + } + + if (result === undefined && isEdited) { + edits.push([key, node]); + } + + if (isLeaving) { + path.pop(); + } else { + var _node$kind; + + stack = { + inArray, + index, + keys, + edits, + prev: stack, + }; + inArray = Array.isArray(node); + keys = inArray + ? node + : (_node$kind = visitorKeys[node.kind]) !== null && + _node$kind !== void 0 + ? _node$kind + : []; + index = -1; + edits = []; + + if (parent) { + ancestors.push(parent); + } + + parent = node; + } + } while (stack !== undefined); + + if (edits.length !== 0) { + // New root + return edits[edits.length - 1][1]; + } + + return root; +} +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ + +function visitInParallel(visitors) { + const skipping = new Array(visitors.length).fill(null); + const mergedVisitor = Object.create(null); + + for (const kind of Object.values(_kinds.Kind)) { + let hasVisitor = false; + const enterList = new Array(visitors.length).fill(undefined); + const leaveList = new Array(visitors.length).fill(undefined); + + for (let i = 0; i < visitors.length; ++i) { + const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); + hasVisitor || (hasVisitor = enter != null || leave != null); + enterList[i] = enter; + leaveList[i] = leave; + } + + if (!hasVisitor) { + continue; + } + + const mergedEnterLeave = { + enter(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _enterList$i; + + const result = + (_enterList$i = enterList[i]) === null || _enterList$i === void 0 + ? void 0 + : _enterList$i.apply(visitors[i], args); + + if (result === false) { + skipping[i] = node; + } else if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined) { + return result; + } + } + } + }, + + leave(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _leaveList$i; + + const result = + (_leaveList$i = leaveList[i]) === null || _leaveList$i === void 0 + ? void 0 + : _leaveList$i.apply(visitors[i], args); + + if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined && result !== false) { + return result; + } + } else if (skipping[i] === node) { + skipping[i] = null; + } + } + }, + }; + mergedVisitor[kind] = mergedEnterLeave; + } + + return mergedVisitor; +} +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ + +function getEnterLeaveForKind(visitor, kind) { + const kindVisitor = visitor[kind]; + + if (typeof kindVisitor === 'object') { + // { Kind: { enter() {}, leave() {} } } + return kindVisitor; + } else if (typeof kindVisitor === 'function') { + // { Kind() {} } + return { + enter: kindVisitor, + leave: undefined, + }; + } // { enter() {}, leave() {} } + + return { + enter: visitor.enter, + leave: visitor.leave, + }; +} +/** + * Given a visitor instance, if it is leaving or not, and a node kind, return + * the function the visitor runtime should call. + * + * @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17 + */ + +/* c8 ignore next 8 */ + +function getVisitFn(visitor, kind, isLeaving) { + const { enter, leave } = getEnterLeaveForKind(visitor, kind); + return isLeaving ? leave : enter; +} + + +/***/ }), + +/***/ 52223: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertEnumValueName = assertEnumValueName; +exports.assertName = assertName; + +var _devAssert = __nccwpck_require__(60645); + +var _GraphQLError = __nccwpck_require__(66807); + +var _characterClasses = __nccwpck_require__(46365); + +/** + * Upholds the spec rules about naming. + */ +function assertName(name) { + name != null || (0, _devAssert.devAssert)(false, 'Must provide name.'); + typeof name === 'string' || + (0, _devAssert.devAssert)(false, 'Expected name to be a string.'); + + if (name.length === 0) { + throw new _GraphQLError.GraphQLError( + 'Expected name to be a non-empty string.', + ); + } + + for (let i = 1; i < name.length; ++i) { + if (!(0, _characterClasses.isNameContinue)(name.charCodeAt(i))) { + throw new _GraphQLError.GraphQLError( + `Names must only contain [_a-zA-Z0-9] but "${name}" does not.`, + ); + } + } + + if (!(0, _characterClasses.isNameStart)(name.charCodeAt(0))) { + throw new _GraphQLError.GraphQLError( + `Names must start with [_a-zA-Z] but "${name}" does not.`, + ); + } + + return name; +} +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ + +function assertEnumValueName(name) { + if (name === 'true' || name === 'false' || name === 'null') { + throw new _GraphQLError.GraphQLError( + `Enum values cannot be named: ${name}`, + ); + } + + return assertName(name); +} + + +/***/ }), + +/***/ 49492: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLUnionType = + exports.GraphQLScalarType = + exports.GraphQLObjectType = + exports.GraphQLNonNull = + exports.GraphQLList = + exports.GraphQLInterfaceType = + exports.GraphQLInputObjectType = + exports.GraphQLEnumType = + void 0; +exports.argsToArgsConfig = argsToArgsConfig; +exports.assertAbstractType = assertAbstractType; +exports.assertCompositeType = assertCompositeType; +exports.assertEnumType = assertEnumType; +exports.assertInputObjectType = assertInputObjectType; +exports.assertInputType = assertInputType; +exports.assertInterfaceType = assertInterfaceType; +exports.assertLeafType = assertLeafType; +exports.assertListType = assertListType; +exports.assertNamedType = assertNamedType; +exports.assertNonNullType = assertNonNullType; +exports.assertNullableType = assertNullableType; +exports.assertObjectType = assertObjectType; +exports.assertOutputType = assertOutputType; +exports.assertScalarType = assertScalarType; +exports.assertType = assertType; +exports.assertUnionType = assertUnionType; +exports.assertWrappingType = assertWrappingType; +exports.defineArguments = defineArguments; +exports.getNamedType = getNamedType; +exports.getNullableType = getNullableType; +exports.isAbstractType = isAbstractType; +exports.isCompositeType = isCompositeType; +exports.isEnumType = isEnumType; +exports.isInputObjectType = isInputObjectType; +exports.isInputType = isInputType; +exports.isInterfaceType = isInterfaceType; +exports.isLeafType = isLeafType; +exports.isListType = isListType; +exports.isNamedType = isNamedType; +exports.isNonNullType = isNonNullType; +exports.isNullableType = isNullableType; +exports.isObjectType = isObjectType; +exports.isOutputType = isOutputType; +exports.isRequiredArgument = isRequiredArgument; +exports.isRequiredInputField = isRequiredInputField; +exports.isScalarType = isScalarType; +exports.isType = isType; +exports.isUnionType = isUnionType; +exports.isWrappingType = isWrappingType; +exports.resolveObjMapThunk = resolveObjMapThunk; +exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk; + +var _devAssert = __nccwpck_require__(60645); + +var _didYouMean = __nccwpck_require__(94476); + +var _identityFunc = __nccwpck_require__(16149); + +var _inspect = __nccwpck_require__(17819); + +var _instanceOf = __nccwpck_require__(92830); + +var _isObjectLike = __nccwpck_require__(63457); + +var _keyMap = __nccwpck_require__(35053); + +var _keyValMap = __nccwpck_require__(69662); + +var _mapValue = __nccwpck_require__(31687); + +var _suggestionList = __nccwpck_require__(48992); + +var _toObjMap = __nccwpck_require__(54965); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _valueFromASTUntyped = __nccwpck_require__(64539); + +var _assertName = __nccwpck_require__(52223); + +function isType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) || + isListType(type) || + isNonNullType(type) + ); +} + +function assertType(type) { + if (!isType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL type.`, + ); + } + + return type; +} +/** + * There are predicates for each kind of GraphQL type. + */ + +function isScalarType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLScalarType); +} + +function assertScalarType(type) { + if (!isScalarType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Scalar type.`, + ); + } + + return type; +} + +function isObjectType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLObjectType); +} + +function assertObjectType(type) { + if (!isObjectType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Object type.`, + ); + } + + return type; +} + +function isInterfaceType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLInterfaceType); +} + +function assertInterfaceType(type) { + if (!isInterfaceType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Interface type.`, + ); + } + + return type; +} + +function isUnionType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLUnionType); +} + +function assertUnionType(type) { + if (!isUnionType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Union type.`, + ); + } + + return type; +} + +function isEnumType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLEnumType); +} + +function assertEnumType(type) { + if (!isEnumType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Enum type.`, + ); + } + + return type; +} + +function isInputObjectType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLInputObjectType); +} + +function assertInputObjectType(type) { + if (!isInputObjectType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)( + type, + )} to be a GraphQL Input Object type.`, + ); + } + + return type; +} + +function isListType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLList); +} + +function assertListType(type) { + if (!isListType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL List type.`, + ); + } + + return type; +} + +function isNonNullType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLNonNull); +} + +function assertNonNullType(type) { + if (!isNonNullType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Non-Null type.`, + ); + } + + return type; +} +/** + * These types may be used as input types for arguments and directives. + */ + +function isInputType(type) { + return ( + isScalarType(type) || + isEnumType(type) || + isInputObjectType(type) || + (isWrappingType(type) && isInputType(type.ofType)) + ); +} + +function assertInputType(type) { + if (!isInputType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL input type.`, + ); + } + + return type; +} +/** + * These types may be used as output types as the result of fields. + */ + +function isOutputType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + (isWrappingType(type) && isOutputType(type.ofType)) + ); +} + +function assertOutputType(type) { + if (!isOutputType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL output type.`, + ); + } + + return type; +} +/** + * These types may describe types which may be leaf values. + */ + +function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} + +function assertLeafType(type) { + if (!isLeafType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL leaf type.`, + ); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} + +function assertCompositeType(type) { + if (!isCompositeType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL composite type.`, + ); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} + +function assertAbstractType(type) { + if (!isAbstractType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL abstract type.`, + ); + } + + return type; +} +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ + +class GraphQLList { + constructor(ofType) { + isType(ofType) || + (0, _devAssert.devAssert)( + false, + `Expected ${(0, _inspect.inspect)(ofType)} to be a GraphQL type.`, + ); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLList'; + } + + toString() { + return '[' + String(this.ofType) + ']'; + } + + toJSON() { + return this.toString(); + } +} +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ + +exports.GraphQLList = GraphQLList; + +class GraphQLNonNull { + constructor(ofType) { + isNullableType(ofType) || + (0, _devAssert.devAssert)( + false, + `Expected ${(0, _inspect.inspect)( + ofType, + )} to be a GraphQL nullable type.`, + ); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLNonNull'; + } + + toString() { + return String(this.ofType) + '!'; + } + + toJSON() { + return this.toString(); + } +} +/** + * These types wrap and modify other types + */ + +exports.GraphQLNonNull = GraphQLNonNull; + +function isWrappingType(type) { + return isListType(type) || isNonNullType(type); +} + +function assertWrappingType(type) { + if (!isWrappingType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL wrapping type.`, + ); + } + + return type; +} +/** + * These types can all accept null as a value. + */ + +function isNullableType(type) { + return isType(type) && !isNonNullType(type); +} + +function assertNullableType(type) { + if (!isNullableType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL nullable type.`, + ); + } + + return type; +} + +function getNullableType(type) { + if (type) { + return isNonNullType(type) ? type.ofType : type; + } +} +/** + * These named types do not include modifiers like List or NonNull. + */ + +function isNamedType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) + ); +} + +function assertNamedType(type) { + if (!isNamedType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL named type.`, + ); + } + + return type; +} + +function getNamedType(type) { + if (type) { + let unwrappedType = type; + + while (isWrappingType(unwrappedType)) { + unwrappedType = unwrappedType.ofType; + } + + return unwrappedType; + } +} +/** + * Used while defining GraphQL types to allow for circular references in + * otherwise immutable type definitions. + */ + +function resolveReadonlyArrayThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} + +function resolveObjMapThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's serialize function returns `null` or does not return a value + * (i.e. it returns `undefined`) then an error will be raised and a `null` + * value will be returned in the response. It is always better to validate + * + * Example: + * + * ```ts + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * serialize(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * return value; + * } + * }); + * ``` + */ +class GraphQLScalarType { + constructor(config) { + var _config$parseValue, + _config$serialize, + _config$parseLiteral, + _config$extensionASTN; + + const parseValue = + (_config$parseValue = config.parseValue) !== null && + _config$parseValue !== void 0 + ? _config$parseValue + : _identityFunc.identityFunc; + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.specifiedByURL = config.specifiedByURL; + this.serialize = + (_config$serialize = config.serialize) !== null && + _config$serialize !== void 0 + ? _config$serialize + : _identityFunc.identityFunc; + this.parseValue = parseValue; + this.parseLiteral = + (_config$parseLiteral = config.parseLiteral) !== null && + _config$parseLiteral !== void 0 + ? _config$parseLiteral + : (node, variables) => + parseValue( + (0, _valueFromASTUntyped.valueFromASTUntyped)(node, variables), + ); + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + config.specifiedByURL == null || + typeof config.specifiedByURL === 'string' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "specifiedByURL" as a string, ` + + `but got: ${(0, _inspect.inspect)(config.specifiedByURL)}.`, + ); + config.serialize == null || + typeof config.serialize === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`, + ); + + if (config.parseLiteral) { + (typeof config.parseValue === 'function' && + typeof config.parseLiteral === 'function') || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide both "parseValue" and "parseLiteral" functions.`, + ); + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLScalarType'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + specifiedByURL: this.specifiedByURL, + serialize: this.serialize, + parseValue: this.parseValue, + parseLiteral: this.parseLiteral, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLScalarType = GraphQLScalarType; + +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +class GraphQLObjectType { + constructor(config) { + var _config$extensionASTN2; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.isTypeOf = config.isTypeOf; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN2 = config.extensionASTNodes) !== null && + _config$extensionASTN2 !== void 0 + ? _config$extensionASTN2 + : []; + + this._fields = () => defineFieldMap(config); + + this._interfaces = () => defineInterfaces(config); + + config.isTypeOf == null || + typeof config.isTypeOf === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "isTypeOf" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.isTypeOf)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + isTypeOf: this.isTypeOf, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLObjectType = GraphQLObjectType; + +function defineInterfaces(config) { + var _config$interfaces; + + const interfaces = resolveReadonlyArrayThunk( + (_config$interfaces = config.interfaces) !== null && + _config$interfaces !== void 0 + ? _config$interfaces + : [], + ); + Array.isArray(interfaces) || + (0, _devAssert.devAssert)( + false, + `${config.name} interfaces must be an Array or a function which returns an Array.`, + ); + return interfaces; +} + +function defineFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0, _devAssert.devAssert)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => { + var _fieldConfig$args; + + isPlainObj(fieldConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field config must be an object.`, + ); + fieldConfig.resolve == null || + typeof fieldConfig.resolve === 'function' || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field resolver must be a function if ` + + `provided, but got: ${(0, _inspect.inspect)(fieldConfig.resolve)}.`, + ); + const argsConfig = + (_fieldConfig$args = fieldConfig.args) !== null && + _fieldConfig$args !== void 0 + ? _fieldConfig$args + : {}; + isPlainObj(argsConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} args must be an object with argument names as keys.`, + ); + return { + name: (0, _assertName.assertName)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + args: defineArguments(argsConfig), + resolve: fieldConfig.resolve, + subscribe: fieldConfig.subscribe, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function defineArguments(config) { + return Object.entries(config).map(([argName, argConfig]) => ({ + name: (0, _assertName.assertName)(argName), + description: argConfig.description, + type: argConfig.type, + defaultValue: argConfig.defaultValue, + deprecationReason: argConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(argConfig.extensions), + astNode: argConfig.astNode, + })); +} + +function isPlainObj(obj) { + return (0, _isObjectLike.isObjectLike)(obj) && !Array.isArray(obj); +} + +function fieldsToFieldsConfig(fields) { + return (0, _mapValue.mapValue)(fields, (field) => ({ + description: field.description, + type: field.type, + args: argsToArgsConfig(field.args), + resolve: field.resolve, + subscribe: field.subscribe, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); +} +/** + * @internal + */ + +function argsToArgsConfig(args) { + return (0, _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, + }), + ); +} + +function isRequiredArgument(arg) { + return isNonNullType(arg.type) && arg.defaultValue === undefined; +} + +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +class GraphQLInterfaceType { + constructor(config) { + var _config$extensionASTN3; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN3 = config.extensionASTNodes) !== null && + _config$extensionASTN3 !== void 0 + ? _config$extensionASTN3 + : []; + this._fields = defineFieldMap.bind(undefined, config); + this._interfaces = defineInterfaces.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInterfaceType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLInterfaceType = GraphQLInterfaceType; + +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +class GraphQLUnionType { + constructor(config) { + var _config$extensionASTN4; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN4 = config.extensionASTNodes) !== null && + _config$extensionASTN4 !== void 0 + ? _config$extensionASTN4 + : []; + this._types = defineTypes.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLUnionType'; + } + + getTypes() { + if (typeof this._types === 'function') { + this._types = this._types(); + } + + return this._types; + } + + toConfig() { + return { + name: this.name, + description: this.description, + types: this.getTypes(), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLUnionType = GraphQLUnionType; + +function defineTypes(config) { + const types = resolveReadonlyArrayThunk(config.types); + Array.isArray(types) || + (0, _devAssert.devAssert)( + false, + `Must provide Array of types or a function which returns such an array for Union ${config.name}.`, + ); + return types; +} + +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL serializes + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +class GraphQLEnumType { + /* */ + constructor(config) { + var _config$extensionASTN5; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN5 = config.extensionASTNodes) !== null && + _config$extensionASTN5 !== void 0 + ? _config$extensionASTN5 + : []; + this._values = defineEnumValues(this.name, config.values); + this._valueLookup = new Map( + this._values.map((enumValue) => [enumValue.value, enumValue]), + ); + this._nameLookup = (0, _keyMap.keyMap)(this._values, (value) => value.name); + } + + get [Symbol.toStringTag]() { + return 'GraphQLEnumType'; + } + + getValues() { + return this._values; + } + + getValue(name) { + return this._nameLookup[name]; + } + + serialize(outputValue) { + const enumValue = this._valueLookup.get(outputValue); + + if (enumValue === undefined) { + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent value: ${(0, _inspect.inspect)( + outputValue, + )}`, + ); + } + + return enumValue.name; + } + + parseValue(inputValue) /* T */ + { + if (typeof inputValue !== 'string') { + const valueStr = (0, _inspect.inspect)(inputValue); + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + ); + } + + const enumValue = this.getValue(inputValue); + + if (enumValue == null) { + throw new _GraphQLError.GraphQLError( + `Value "${inputValue}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, inputValue), + ); + } + + return enumValue.value; + } + + parseLiteral(valueNode, _variables) /* T */ + { + // Note: variables will be resolved to a value before calling this function. + if (valueNode.kind !== _kinds.Kind.ENUM) { + const valueStr = (0, _printer.print)(valueNode); + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + const enumValue = this.getValue(valueNode.value); + + if (enumValue == null) { + const valueStr = (0, _printer.print)(valueNode); + throw new _GraphQLError.GraphQLError( + `Value "${valueStr}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + return enumValue.value; + } + + toConfig() { + const values = (0, _keyValMap.keyValMap)( + this.getValues(), + (value) => value.name, + (value) => ({ + description: value.description, + value: value.value, + deprecationReason: value.deprecationReason, + extensions: value.extensions, + astNode: value.astNode, + }), + ); + return { + name: this.name, + description: this.description, + values, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLEnumType = GraphQLEnumType; + +function didYouMeanEnumValue(enumType, unknownValueStr) { + const allNames = enumType.getValues().map((value) => value.name); + const suggestedValues = (0, _suggestionList.suggestionList)( + unknownValueStr, + allNames, + ); + return (0, _didYouMean.didYouMean)('the enum value', suggestedValues); +} + +function defineEnumValues(typeName, valueMap) { + isPlainObj(valueMap) || + (0, _devAssert.devAssert)( + false, + `${typeName} values must be an object with value names as keys.`, + ); + return Object.entries(valueMap).map(([valueName, valueConfig]) => { + isPlainObj(valueConfig) || + (0, _devAssert.devAssert)( + false, + `${typeName}.${valueName} must refer to an object with a "value" key ` + + `representing an internal value but got: ${(0, _inspect.inspect)( + valueConfig, + )}.`, + ); + return { + name: (0, _assertName.assertEnumValueName)(valueName), + description: valueConfig.description, + value: valueConfig.value !== undefined ? valueConfig.value : valueName, + deprecationReason: valueConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(valueConfig.extensions), + astNode: valueConfig.astNode, + }; + }); +} + +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +class GraphQLInputObjectType { + constructor(config) { + var _config$extensionASTN6; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN6 = config.extensionASTNodes) !== null && + _config$extensionASTN6 !== void 0 + ? _config$extensionASTN6 + : []; + this._fields = defineInputFieldMap.bind(undefined, config); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInputObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + toConfig() { + const fields = (0, _mapValue.mapValue)(this.getFields(), (field) => ({ + description: field.description, + type: field.type, + defaultValue: field.defaultValue, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); + return { + name: this.name, + description: this.description, + fields, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLInputObjectType = GraphQLInputObjectType; + +function defineInputFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0, _devAssert.devAssert)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => { + !('resolve' in fieldConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`, + ); + return { + name: (0, _assertName.assertName)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + defaultValue: fieldConfig.defaultValue, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function isRequiredInputField(field) { + return isNonNullType(field.type) && field.defaultValue === undefined; +} + + +/***/ }), + +/***/ 34154: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLSpecifiedByDirective = + exports.GraphQLSkipDirective = + exports.GraphQLIncludeDirective = + exports.GraphQLDirective = + exports.GraphQLDeprecatedDirective = + exports.DEFAULT_DEPRECATION_REASON = + void 0; +exports.assertDirective = assertDirective; +exports.isDirective = isDirective; +exports.isSpecifiedDirective = isSpecifiedDirective; +exports.specifiedDirectives = void 0; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _instanceOf = __nccwpck_require__(92830); + +var _isObjectLike = __nccwpck_require__(63457); + +var _toObjMap = __nccwpck_require__(54965); + +var _directiveLocation = __nccwpck_require__(6128); + +var _assertName = __nccwpck_require__(52223); + +var _definition = __nccwpck_require__(49492); + +var _scalars = __nccwpck_require__(14544); + +/** + * Test if the given value is a GraphQL directive. + */ +function isDirective(directive) { + return (0, _instanceOf.instanceOf)(directive, GraphQLDirective); +} + +function assertDirective(directive) { + if (!isDirective(directive)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(directive)} to be a GraphQL directive.`, + ); + } + + return directive; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +class GraphQLDirective { + constructor(config) { + var _config$isRepeatable, _config$args; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.locations = config.locations; + this.isRepeatable = + (_config$isRepeatable = config.isRepeatable) !== null && + _config$isRepeatable !== void 0 + ? _config$isRepeatable + : false; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + Array.isArray(config.locations) || + (0, _devAssert.devAssert)( + false, + `@${config.name} locations must be an Array.`, + ); + const args = + (_config$args = config.args) !== null && _config$args !== void 0 + ? _config$args + : {}; + ((0, _isObjectLike.isObjectLike)(args) && !Array.isArray(args)) || + (0, _devAssert.devAssert)( + false, + `@${config.name} args must be an object with argument names as keys.`, + ); + this.args = (0, _definition.defineArguments)(args); + } + + get [Symbol.toStringTag]() { + return 'GraphQLDirective'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + locations: this.locations, + args: (0, _definition.argsToArgsConfig)(this.args), + isRepeatable: this.isRepeatable, + extensions: this.extensions, + astNode: this.astNode, + }; + } + + toString() { + return '@' + this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLDirective = GraphQLDirective; + +/** + * Used to conditionally include fields or fragments. + */ +const GraphQLIncludeDirective = new GraphQLDirective({ + name: 'include', + description: + 'Directs the executor to include this field or fragment only when the `if` argument is true.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD, + _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + description: 'Included when true.', + }, + }, +}); +/** + * Used to conditionally skip (exclude) fields or fragments. + */ + +exports.GraphQLIncludeDirective = GraphQLIncludeDirective; +const GraphQLSkipDirective = new GraphQLDirective({ + name: 'skip', + description: + 'Directs the executor to skip this field or fragment when the `if` argument is true.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD, + _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + description: 'Skipped when true.', + }, + }, +}); +/** + * Constant string used for default reason for a deprecation. + */ + +exports.GraphQLSkipDirective = GraphQLSkipDirective; +const DEFAULT_DEPRECATION_REASON = 'No longer supported'; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ + +exports.DEFAULT_DEPRECATION_REASON = DEFAULT_DEPRECATION_REASON; +const GraphQLDeprecatedDirective = new GraphQLDirective({ + name: 'deprecated', + description: 'Marks an element of a GraphQL schema as no longer supported.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD_DEFINITION, + _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION, + _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION, + _directiveLocation.DirectiveLocation.ENUM_VALUE, + ], + args: { + reason: { + type: _scalars.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, + }, + }, +}); +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ + +exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective; +const GraphQLSpecifiedByDirective = new GraphQLDirective({ + name: 'specifiedBy', + description: 'Exposes a URL that specifies the behavior of this scalar.', + locations: [_directiveLocation.DirectiveLocation.SCALAR], + args: { + url: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + description: 'The URL that specifies the behavior of this scalar.', + }, + }, +}); +/** + * The full list of specified directives. + */ + +exports.GraphQLSpecifiedByDirective = GraphQLSpecifiedByDirective; +const specifiedDirectives = Object.freeze([ + GraphQLIncludeDirective, + GraphQLSkipDirective, + GraphQLDeprecatedDirective, + GraphQLSpecifiedByDirective, +]); +exports.specifiedDirectives = specifiedDirectives; + +function isSpecifiedDirective(directive) { + return specifiedDirectives.some(({ name }) => name === directive.name); +} + + +/***/ }), + +/***/ 11702: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", ({ + enumerable: true, + get: function () { + return _directives.DEFAULT_DEPRECATION_REASON; + }, +})); +Object.defineProperty(exports, "GRAPHQL_MAX_INT", ({ + enumerable: true, + get: function () { + return _scalars.GRAPHQL_MAX_INT; + }, +})); +Object.defineProperty(exports, "GRAPHQL_MIN_INT", ({ + enumerable: true, + get: function () { + return _scalars.GRAPHQL_MIN_INT; + }, +})); +Object.defineProperty(exports, "GraphQLBoolean", ({ + enumerable: true, + get: function () { + return _scalars.GraphQLBoolean; + }, +})); +Object.defineProperty(exports, "GraphQLDeprecatedDirective", ({ + enumerable: true, + get: function () { + return _directives.GraphQLDeprecatedDirective; + }, +})); +Object.defineProperty(exports, "GraphQLDirective", ({ + enumerable: true, + get: function () { + return _directives.GraphQLDirective; + }, +})); +Object.defineProperty(exports, "GraphQLEnumType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLEnumType; + }, +})); +Object.defineProperty(exports, "GraphQLFloat", ({ + enumerable: true, + get: function () { + return _scalars.GraphQLFloat; + }, +})); +Object.defineProperty(exports, "GraphQLID", ({ + enumerable: true, + get: function () { + return _scalars.GraphQLID; + }, +})); +Object.defineProperty(exports, "GraphQLIncludeDirective", ({ + enumerable: true, + get: function () { + return _directives.GraphQLIncludeDirective; + }, +})); +Object.defineProperty(exports, "GraphQLInputObjectType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLInputObjectType; + }, +})); +Object.defineProperty(exports, "GraphQLInt", ({ + enumerable: true, + get: function () { + return _scalars.GraphQLInt; + }, +})); +Object.defineProperty(exports, "GraphQLInterfaceType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLInterfaceType; + }, +})); +Object.defineProperty(exports, "GraphQLList", ({ + enumerable: true, + get: function () { + return _definition.GraphQLList; + }, +})); +Object.defineProperty(exports, "GraphQLNonNull", ({ + enumerable: true, + get: function () { + return _definition.GraphQLNonNull; + }, +})); +Object.defineProperty(exports, "GraphQLObjectType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLObjectType; + }, +})); +Object.defineProperty(exports, "GraphQLScalarType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLScalarType; + }, +})); +Object.defineProperty(exports, "GraphQLSchema", ({ + enumerable: true, + get: function () { + return _schema.GraphQLSchema; + }, +})); +Object.defineProperty(exports, "GraphQLSkipDirective", ({ + enumerable: true, + get: function () { + return _directives.GraphQLSkipDirective; + }, +})); +Object.defineProperty(exports, "GraphQLSpecifiedByDirective", ({ + enumerable: true, + get: function () { + return _directives.GraphQLSpecifiedByDirective; + }, +})); +Object.defineProperty(exports, "GraphQLString", ({ + enumerable: true, + get: function () { + return _scalars.GraphQLString; + }, +})); +Object.defineProperty(exports, "GraphQLUnionType", ({ + enumerable: true, + get: function () { + return _definition.GraphQLUnionType; + }, +})); +Object.defineProperty(exports, "SchemaMetaFieldDef", ({ + enumerable: true, + get: function () { + return _introspection.SchemaMetaFieldDef; + }, +})); +Object.defineProperty(exports, "TypeKind", ({ + enumerable: true, + get: function () { + return _introspection.TypeKind; + }, +})); +Object.defineProperty(exports, "TypeMetaFieldDef", ({ + enumerable: true, + get: function () { + return _introspection.TypeMetaFieldDef; + }, +})); +Object.defineProperty(exports, "TypeNameMetaFieldDef", ({ + enumerable: true, + get: function () { + return _introspection.TypeNameMetaFieldDef; + }, +})); +Object.defineProperty(exports, "__Directive", ({ + enumerable: true, + get: function () { + return _introspection.__Directive; + }, +})); +Object.defineProperty(exports, "__DirectiveLocation", ({ + enumerable: true, + get: function () { + return _introspection.__DirectiveLocation; + }, +})); +Object.defineProperty(exports, "__EnumValue", ({ + enumerable: true, + get: function () { + return _introspection.__EnumValue; + }, +})); +Object.defineProperty(exports, "__Field", ({ + enumerable: true, + get: function () { + return _introspection.__Field; + }, +})); +Object.defineProperty(exports, "__InputValue", ({ + enumerable: true, + get: function () { + return _introspection.__InputValue; + }, +})); +Object.defineProperty(exports, "__Schema", ({ + enumerable: true, + get: function () { + return _introspection.__Schema; + }, +})); +Object.defineProperty(exports, "__Type", ({ + enumerable: true, + get: function () { + return _introspection.__Type; + }, +})); +Object.defineProperty(exports, "__TypeKind", ({ + enumerable: true, + get: function () { + return _introspection.__TypeKind; + }, +})); +Object.defineProperty(exports, "assertAbstractType", ({ + enumerable: true, + get: function () { + return _definition.assertAbstractType; + }, +})); +Object.defineProperty(exports, "assertCompositeType", ({ + enumerable: true, + get: function () { + return _definition.assertCompositeType; + }, +})); +Object.defineProperty(exports, "assertDirective", ({ + enumerable: true, + get: function () { + return _directives.assertDirective; + }, +})); +Object.defineProperty(exports, "assertEnumType", ({ + enumerable: true, + get: function () { + return _definition.assertEnumType; + }, +})); +Object.defineProperty(exports, "assertEnumValueName", ({ + enumerable: true, + get: function () { + return _assertName.assertEnumValueName; + }, +})); +Object.defineProperty(exports, "assertInputObjectType", ({ + enumerable: true, + get: function () { + return _definition.assertInputObjectType; + }, +})); +Object.defineProperty(exports, "assertInputType", ({ + enumerable: true, + get: function () { + return _definition.assertInputType; + }, +})); +Object.defineProperty(exports, "assertInterfaceType", ({ + enumerable: true, + get: function () { + return _definition.assertInterfaceType; + }, +})); +Object.defineProperty(exports, "assertLeafType", ({ + enumerable: true, + get: function () { + return _definition.assertLeafType; + }, +})); +Object.defineProperty(exports, "assertListType", ({ + enumerable: true, + get: function () { + return _definition.assertListType; + }, +})); +Object.defineProperty(exports, "assertName", ({ + enumerable: true, + get: function () { + return _assertName.assertName; + }, +})); +Object.defineProperty(exports, "assertNamedType", ({ + enumerable: true, + get: function () { + return _definition.assertNamedType; + }, +})); +Object.defineProperty(exports, "assertNonNullType", ({ + enumerable: true, + get: function () { + return _definition.assertNonNullType; + }, +})); +Object.defineProperty(exports, "assertNullableType", ({ + enumerable: true, + get: function () { + return _definition.assertNullableType; + }, +})); +Object.defineProperty(exports, "assertObjectType", ({ + enumerable: true, + get: function () { + return _definition.assertObjectType; + }, +})); +Object.defineProperty(exports, "assertOutputType", ({ + enumerable: true, + get: function () { + return _definition.assertOutputType; + }, +})); +Object.defineProperty(exports, "assertScalarType", ({ + enumerable: true, + get: function () { + return _definition.assertScalarType; + }, +})); +Object.defineProperty(exports, "assertSchema", ({ + enumerable: true, + get: function () { + return _schema.assertSchema; + }, +})); +Object.defineProperty(exports, "assertType", ({ + enumerable: true, + get: function () { + return _definition.assertType; + }, +})); +Object.defineProperty(exports, "assertUnionType", ({ + enumerable: true, + get: function () { + return _definition.assertUnionType; + }, +})); +Object.defineProperty(exports, "assertValidSchema", ({ + enumerable: true, + get: function () { + return _validate.assertValidSchema; + }, +})); +Object.defineProperty(exports, "assertWrappingType", ({ + enumerable: true, + get: function () { + return _definition.assertWrappingType; + }, +})); +Object.defineProperty(exports, "getNamedType", ({ + enumerable: true, + get: function () { + return _definition.getNamedType; + }, +})); +Object.defineProperty(exports, "getNullableType", ({ + enumerable: true, + get: function () { + return _definition.getNullableType; + }, +})); +Object.defineProperty(exports, "introspectionTypes", ({ + enumerable: true, + get: function () { + return _introspection.introspectionTypes; + }, +})); +Object.defineProperty(exports, "isAbstractType", ({ + enumerable: true, + get: function () { + return _definition.isAbstractType; + }, +})); +Object.defineProperty(exports, "isCompositeType", ({ + enumerable: true, + get: function () { + return _definition.isCompositeType; + }, +})); +Object.defineProperty(exports, "isDirective", ({ + enumerable: true, + get: function () { + return _directives.isDirective; + }, +})); +Object.defineProperty(exports, "isEnumType", ({ + enumerable: true, + get: function () { + return _definition.isEnumType; + }, +})); +Object.defineProperty(exports, "isInputObjectType", ({ + enumerable: true, + get: function () { + return _definition.isInputObjectType; + }, +})); +Object.defineProperty(exports, "isInputType", ({ + enumerable: true, + get: function () { + return _definition.isInputType; + }, +})); +Object.defineProperty(exports, "isInterfaceType", ({ + enumerable: true, + get: function () { + return _definition.isInterfaceType; + }, +})); +Object.defineProperty(exports, "isIntrospectionType", ({ + enumerable: true, + get: function () { + return _introspection.isIntrospectionType; + }, +})); +Object.defineProperty(exports, "isLeafType", ({ + enumerable: true, + get: function () { + return _definition.isLeafType; + }, +})); +Object.defineProperty(exports, "isListType", ({ + enumerable: true, + get: function () { + return _definition.isListType; + }, +})); +Object.defineProperty(exports, "isNamedType", ({ + enumerable: true, + get: function () { + return _definition.isNamedType; + }, +})); +Object.defineProperty(exports, "isNonNullType", ({ + enumerable: true, + get: function () { + return _definition.isNonNullType; + }, +})); +Object.defineProperty(exports, "isNullableType", ({ + enumerable: true, + get: function () { + return _definition.isNullableType; + }, +})); +Object.defineProperty(exports, "isObjectType", ({ + enumerable: true, + get: function () { + return _definition.isObjectType; + }, +})); +Object.defineProperty(exports, "isOutputType", ({ + enumerable: true, + get: function () { + return _definition.isOutputType; + }, +})); +Object.defineProperty(exports, "isRequiredArgument", ({ + enumerable: true, + get: function () { + return _definition.isRequiredArgument; + }, +})); +Object.defineProperty(exports, "isRequiredInputField", ({ + enumerable: true, + get: function () { + return _definition.isRequiredInputField; + }, +})); +Object.defineProperty(exports, "isScalarType", ({ + enumerable: true, + get: function () { + return _definition.isScalarType; + }, +})); +Object.defineProperty(exports, "isSchema", ({ + enumerable: true, + get: function () { + return _schema.isSchema; + }, +})); +Object.defineProperty(exports, "isSpecifiedDirective", ({ + enumerable: true, + get: function () { + return _directives.isSpecifiedDirective; + }, +})); +Object.defineProperty(exports, "isSpecifiedScalarType", ({ + enumerable: true, + get: function () { + return _scalars.isSpecifiedScalarType; + }, +})); +Object.defineProperty(exports, "isType", ({ + enumerable: true, + get: function () { + return _definition.isType; + }, +})); +Object.defineProperty(exports, "isUnionType", ({ + enumerable: true, + get: function () { + return _definition.isUnionType; + }, +})); +Object.defineProperty(exports, "isWrappingType", ({ + enumerable: true, + get: function () { + return _definition.isWrappingType; + }, +})); +Object.defineProperty(exports, "resolveObjMapThunk", ({ + enumerable: true, + get: function () { + return _definition.resolveObjMapThunk; + }, +})); +Object.defineProperty(exports, "resolveReadonlyArrayThunk", ({ + enumerable: true, + get: function () { + return _definition.resolveReadonlyArrayThunk; + }, +})); +Object.defineProperty(exports, "specifiedDirectives", ({ + enumerable: true, + get: function () { + return _directives.specifiedDirectives; + }, +})); +Object.defineProperty(exports, "specifiedScalarTypes", ({ + enumerable: true, + get: function () { + return _scalars.specifiedScalarTypes; + }, +})); +Object.defineProperty(exports, "validateSchema", ({ + enumerable: true, + get: function () { + return _validate.validateSchema; + }, +})); + +var _schema = __nccwpck_require__(80613); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _scalars = __nccwpck_require__(14544); + +var _introspection = __nccwpck_require__(98029); + +var _validate = __nccwpck_require__(95929); + +var _assertName = __nccwpck_require__(52223); + + +/***/ }), + +/***/ 98029: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.introspectionTypes = + exports.__TypeKind = + exports.__Type = + exports.__Schema = + exports.__InputValue = + exports.__Field = + exports.__EnumValue = + exports.__DirectiveLocation = + exports.__Directive = + exports.TypeNameMetaFieldDef = + exports.TypeMetaFieldDef = + exports.TypeKind = + exports.SchemaMetaFieldDef = + void 0; +exports.isIntrospectionType = isIntrospectionType; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _directiveLocation = __nccwpck_require__(6128); + +var _printer = __nccwpck_require__(3099); + +var _astFromValue = __nccwpck_require__(68906); + +var _definition = __nccwpck_require__(49492); + +var _scalars = __nccwpck_require__(14544); + +const __Schema = new _definition.GraphQLObjectType({ + name: '__Schema', + description: + 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', + fields: () => ({ + description: { + type: _scalars.GraphQLString, + resolve: (schema) => schema.description, + }, + types: { + description: 'A list of all types supported by this server.', + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + ), + + resolve(schema) { + return Object.values(schema.getTypeMap()); + }, + }, + queryType: { + description: 'The type that query operations will be rooted at.', + type: new _definition.GraphQLNonNull(__Type), + resolve: (schema) => schema.getQueryType(), + }, + mutationType: { + description: + 'If this server supports mutation, the type that mutation operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getMutationType(), + }, + subscriptionType: { + description: + 'If this server support subscription, the type that subscription operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getSubscriptionType(), + }, + directives: { + description: 'A list of all directives supported by this server.', + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__Directive), + ), + ), + resolve: (schema) => schema.getDirectives(), + }, + }), +}); + +exports.__Schema = __Schema; + +const __Directive = new _definition.GraphQLObjectType({ + name: '__Directive', + description: + "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (directive) => directive.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (directive) => directive.description, + }, + isRepeatable: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (directive) => directive.isRepeatable, + }, + locations: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__DirectiveLocation), + ), + ), + resolve: (directive) => directive.locations, + }, + args: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + }), +}); + +exports.__Directive = __Directive; + +const __DirectiveLocation = new _definition.GraphQLEnumType({ + name: '__DirectiveLocation', + description: + 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', + values: { + QUERY: { + value: _directiveLocation.DirectiveLocation.QUERY, + description: 'Location adjacent to a query operation.', + }, + MUTATION: { + value: _directiveLocation.DirectiveLocation.MUTATION, + description: 'Location adjacent to a mutation operation.', + }, + SUBSCRIPTION: { + value: _directiveLocation.DirectiveLocation.SUBSCRIPTION, + description: 'Location adjacent to a subscription operation.', + }, + FIELD: { + value: _directiveLocation.DirectiveLocation.FIELD, + description: 'Location adjacent to a field.', + }, + FRAGMENT_DEFINITION: { + value: _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION, + description: 'Location adjacent to a fragment definition.', + }, + FRAGMENT_SPREAD: { + value: _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + description: 'Location adjacent to a fragment spread.', + }, + INLINE_FRAGMENT: { + value: _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + description: 'Location adjacent to an inline fragment.', + }, + VARIABLE_DEFINITION: { + value: _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION, + description: 'Location adjacent to a variable definition.', + }, + SCHEMA: { + value: _directiveLocation.DirectiveLocation.SCHEMA, + description: 'Location adjacent to a schema definition.', + }, + SCALAR: { + value: _directiveLocation.DirectiveLocation.SCALAR, + description: 'Location adjacent to a scalar definition.', + }, + OBJECT: { + value: _directiveLocation.DirectiveLocation.OBJECT, + description: 'Location adjacent to an object type definition.', + }, + FIELD_DEFINITION: { + value: _directiveLocation.DirectiveLocation.FIELD_DEFINITION, + description: 'Location adjacent to a field definition.', + }, + ARGUMENT_DEFINITION: { + value: _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION, + description: 'Location adjacent to an argument definition.', + }, + INTERFACE: { + value: _directiveLocation.DirectiveLocation.INTERFACE, + description: 'Location adjacent to an interface definition.', + }, + UNION: { + value: _directiveLocation.DirectiveLocation.UNION, + description: 'Location adjacent to a union definition.', + }, + ENUM: { + value: _directiveLocation.DirectiveLocation.ENUM, + description: 'Location adjacent to an enum definition.', + }, + ENUM_VALUE: { + value: _directiveLocation.DirectiveLocation.ENUM_VALUE, + description: 'Location adjacent to an enum value definition.', + }, + INPUT_OBJECT: { + value: _directiveLocation.DirectiveLocation.INPUT_OBJECT, + description: 'Location adjacent to an input object type definition.', + }, + INPUT_FIELD_DEFINITION: { + value: _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION, + description: 'Location adjacent to an input object field definition.', + }, + }, +}); + +exports.__DirectiveLocation = __DirectiveLocation; + +const __Type = new _definition.GraphQLObjectType({ + name: '__Type', + description: + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + fields: () => ({ + kind: { + type: new _definition.GraphQLNonNull(__TypeKind), + + resolve(type) { + if ((0, _definition.isScalarType)(type)) { + return TypeKind.SCALAR; + } + + if ((0, _definition.isObjectType)(type)) { + return TypeKind.OBJECT; + } + + if ((0, _definition.isInterfaceType)(type)) { + return TypeKind.INTERFACE; + } + + if ((0, _definition.isUnionType)(type)) { + return TypeKind.UNION; + } + + if ((0, _definition.isEnumType)(type)) { + return TypeKind.ENUM; + } + + if ((0, _definition.isInputObjectType)(type)) { + return TypeKind.INPUT_OBJECT; + } + + if ((0, _definition.isListType)(type)) { + return TypeKind.LIST; + } + + if ((0, _definition.isNonNullType)(type)) { + return TypeKind.NON_NULL; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered) + + false || + (0, _invariant.invariant)( + false, + `Unexpected type: "${(0, _inspect.inspect)(type)}".`, + ); + }, + }, + name: { + type: _scalars.GraphQLString, + resolve: (type) => ('name' in type ? type.name : undefined), + }, + description: { + type: _scalars.GraphQLString, + resolve: ( + type, // FIXME: add test case + ) => + /* c8 ignore next */ + 'description' in type ? type.description : undefined, + }, + specifiedByURL: { + type: _scalars.GraphQLString, + resolve: (obj) => + 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, + }, + fields: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__Field), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + const fields = Object.values(type.getFields()); + return includeDeprecated + ? fields + : fields.filter((field) => field.deprecationReason == null); + } + }, + }, + interfaces: { + type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + + resolve(type) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + return type.getInterfaces(); + } + }, + }, + possibleTypes: { + type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + + resolve(type, _args, _context, { schema }) { + if ((0, _definition.isAbstractType)(type)) { + return schema.getPossibleTypes(type); + } + }, + }, + enumValues: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__EnumValue), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0, _definition.isEnumType)(type)) { + const values = type.getValues(); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + inputFields: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0, _definition.isInputObjectType)(type)) { + const values = Object.values(type.getFields()); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + ofType: { + type: __Type, + resolve: (type) => ('ofType' in type ? type.ofType : undefined), + }, + }), +}); + +exports.__Type = __Type; + +const __Field = new _definition.GraphQLObjectType({ + name: '__Field', + description: + 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (field) => field.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (field) => field.description, + }, + args: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + type: { + type: new _definition.GraphQLNonNull(__Type), + resolve: (field) => field.type, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (field) => field.deprecationReason, + }, + }), +}); + +exports.__Field = __Field; + +const __InputValue = new _definition.GraphQLObjectType({ + name: '__InputValue', + description: + 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (inputValue) => inputValue.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (inputValue) => inputValue.description, + }, + type: { + type: new _definition.GraphQLNonNull(__Type), + resolve: (inputValue) => inputValue.type, + }, + defaultValue: { + type: _scalars.GraphQLString, + description: + 'A GraphQL-formatted string representing the default value for this input value.', + + resolve(inputValue) { + const { type, defaultValue } = inputValue; + const valueAST = (0, _astFromValue.astFromValue)(defaultValue, type); + return valueAST ? (0, _printer.print)(valueAST) : null; + }, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (obj) => obj.deprecationReason, + }, + }), +}); + +exports.__InputValue = __InputValue; + +const __EnumValue = new _definition.GraphQLObjectType({ + name: '__EnumValue', + description: + 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (enumValue) => enumValue.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (enumValue) => enumValue.description, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (enumValue) => enumValue.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (enumValue) => enumValue.deprecationReason, + }, + }), +}); + +exports.__EnumValue = __EnumValue; +var TypeKind; +exports.TypeKind = TypeKind; + +(function (TypeKind) { + TypeKind['SCALAR'] = 'SCALAR'; + TypeKind['OBJECT'] = 'OBJECT'; + TypeKind['INTERFACE'] = 'INTERFACE'; + TypeKind['UNION'] = 'UNION'; + TypeKind['ENUM'] = 'ENUM'; + TypeKind['INPUT_OBJECT'] = 'INPUT_OBJECT'; + TypeKind['LIST'] = 'LIST'; + TypeKind['NON_NULL'] = 'NON_NULL'; +})(TypeKind || (exports.TypeKind = TypeKind = {})); + +const __TypeKind = new _definition.GraphQLEnumType({ + name: '__TypeKind', + description: 'An enum describing what kind of type a given `__Type` is.', + values: { + SCALAR: { + value: TypeKind.SCALAR, + description: 'Indicates this type is a scalar.', + }, + OBJECT: { + value: TypeKind.OBJECT, + description: + 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', + }, + INTERFACE: { + value: TypeKind.INTERFACE, + description: + 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', + }, + UNION: { + value: TypeKind.UNION, + description: + 'Indicates this type is a union. `possibleTypes` is a valid field.', + }, + ENUM: { + value: TypeKind.ENUM, + description: + 'Indicates this type is an enum. `enumValues` is a valid field.', + }, + INPUT_OBJECT: { + value: TypeKind.INPUT_OBJECT, + description: + 'Indicates this type is an input object. `inputFields` is a valid field.', + }, + LIST: { + value: TypeKind.LIST, + description: 'Indicates this type is a list. `ofType` is a valid field.', + }, + NON_NULL: { + value: TypeKind.NON_NULL, + description: + 'Indicates this type is a non-null. `ofType` is a valid field.', + }, + }, +}); +/** + * Note that these are GraphQLField and not GraphQLFieldConfig, + * so the format for args is different. + */ + +exports.__TypeKind = __TypeKind; +const SchemaMetaFieldDef = { + name: '__schema', + type: new _definition.GraphQLNonNull(__Schema), + description: 'Access the current type schema of this server.', + args: [], + resolve: (_source, _args, _context, { schema }) => schema, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.SchemaMetaFieldDef = SchemaMetaFieldDef; +const TypeMetaFieldDef = { + name: '__type', + type: __Type, + description: 'Request the type information of a single type.', + args: [ + { + name: 'name', + description: undefined, + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + defaultValue: undefined, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, + }, + ], + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.TypeMetaFieldDef = TypeMetaFieldDef; +const TypeNameMetaFieldDef = { + name: '__typename', + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + description: 'The name of the current Object type at runtime.', + args: [], + resolve: (_source, _args, _context, { parentType }) => parentType.name, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.TypeNameMetaFieldDef = TypeNameMetaFieldDef; +const introspectionTypes = Object.freeze([ + __Schema, + __Directive, + __DirectiveLocation, + __Type, + __Field, + __InputValue, + __EnumValue, + __TypeKind, +]); +exports.introspectionTypes = introspectionTypes; + +function isIntrospectionType(type) { + return introspectionTypes.some(({ name }) => type.name === name); +} + + +/***/ }), + +/***/ 14544: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLString = + exports.GraphQLInt = + exports.GraphQLID = + exports.GraphQLFloat = + exports.GraphQLBoolean = + exports.GRAPHQL_MIN_INT = + exports.GRAPHQL_MAX_INT = + void 0; +exports.isSpecifiedScalarType = isSpecifiedScalarType; +exports.specifiedScalarTypes = void 0; + +var _inspect = __nccwpck_require__(17819); + +var _isObjectLike = __nccwpck_require__(63457); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ +const GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ + +exports.GRAPHQL_MAX_INT = GRAPHQL_MAX_INT; +const GRAPHQL_MIN_INT = -2147483648; +exports.GRAPHQL_MIN_INT = GRAPHQL_MIN_INT; +const GraphQLInt = new _definition.GraphQLScalarType({ + name: 'Int', + description: + 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isInteger(num)) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + } + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + 'Int cannot represent non 32-bit signed integer value: ' + + (0, _inspect.inspect)(coercedValue), + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non 32-bit signed integer value: ${inputValue}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + const num = parseInt(valueNode.value, 10); + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, + { + nodes: valueNode, + }, + ); + } + + return num; + }, +}); +exports.GraphQLInt = GraphQLInt; +const GraphQLFloat = new _definition.GraphQLScalarType({ + name: 'Float', + description: + 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isFinite(num)) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if ( + valueNode.kind !== _kinds.Kind.FLOAT && + valueNode.kind !== _kinds.Kind.INT + ) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _printer.print)( + valueNode, + )}`, + valueNode, + ); + } + + return parseFloat(valueNode.value); + }, +}); +exports.GraphQLFloat = GraphQLFloat; +const GraphQLString = new _definition.GraphQLScalarType({ + name: 'String', + description: + 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); // Serialize string, boolean and number values to a string, but do not + // attempt to coerce object, function, symbol, or other types as strings. + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 'true' : 'false'; + } + + if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { + return coercedValue.toString(); + } + + throw new _GraphQLError.GraphQLError( + `String cannot represent value: ${(0, _inspect.inspect)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'string') { + throw new _GraphQLError.GraphQLError( + `String cannot represent a non string value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.STRING) { + throw new _GraphQLError.GraphQLError( + `String cannot represent a non string value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLString = GraphQLString; +const GraphQLBoolean = new _definition.GraphQLScalarType({ + name: 'Boolean', + description: 'The `Boolean` scalar type represents `true` or `false`.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue; + } + + if (Number.isFinite(coercedValue)) { + return coercedValue !== 0; + } + + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'boolean') { + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.BOOLEAN) { + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLBoolean = GraphQLBoolean; +const GraphQLID = new _definition.GraphQLScalarType({ + name: 'ID', + description: + 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (Number.isInteger(coercedValue)) { + return String(coercedValue); + } + + throw new _GraphQLError.GraphQLError( + `ID cannot represent value: ${(0, _inspect.inspect)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue === 'string') { + return inputValue; + } + + if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { + return inputValue.toString(); + } + + throw new _GraphQLError.GraphQLError( + `ID cannot represent value: ${(0, _inspect.inspect)(inputValue)}`, + ); + }, + + parseLiteral(valueNode) { + if ( + valueNode.kind !== _kinds.Kind.STRING && + valueNode.kind !== _kinds.Kind.INT + ) { + throw new _GraphQLError.GraphQLError( + 'ID cannot represent a non-string and non-integer value: ' + + (0, _printer.print)(valueNode), + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLID = GraphQLID; +const specifiedScalarTypes = Object.freeze([ + GraphQLString, + GraphQLInt, + GraphQLFloat, + GraphQLBoolean, + GraphQLID, +]); +exports.specifiedScalarTypes = specifiedScalarTypes; + +function isSpecifiedScalarType(type) { + return specifiedScalarTypes.some(({ name }) => type.name === name); +} // Support serializing objects with custom valueOf() or toJSON() functions - +// a common way to represent a complex value which can be represented as +// a string (ex: MongoDB id objects). + +function serializeObject(outputValue) { + if ((0, _isObjectLike.isObjectLike)(outputValue)) { + if (typeof outputValue.valueOf === 'function') { + const valueOfResult = outputValue.valueOf(); + + if (!(0, _isObjectLike.isObjectLike)(valueOfResult)) { + return valueOfResult; + } + } + + if (typeof outputValue.toJSON === 'function') { + return outputValue.toJSON(); + } + } + + return outputValue; +} + + +/***/ }), + +/***/ 80613: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLSchema = void 0; +exports.assertSchema = assertSchema; +exports.isSchema = isSchema; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _instanceOf = __nccwpck_require__(92830); + +var _isObjectLike = __nccwpck_require__(63457); + +var _toObjMap = __nccwpck_require__(54965); + +var _ast = __nccwpck_require__(20727); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +/** + * Test if the given value is a GraphQL schema. + */ +function isSchema(schema) { + return (0, _instanceOf.instanceOf)(schema, GraphQLSchema); +} + +function assertSchema(schema) { + if (!isSchema(schema)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(schema)} to be a GraphQL schema.`, + ); + } + + return schema; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +class GraphQLSchema { + // Used as a cache for validateSchema(). + constructor(config) { + var _config$extensionASTN, _config$directives; + + // If this schema was built from a source known to be valid, then it may be + // marked with assumeValid to avoid an additional type system validation. + this.__validationErrors = config.assumeValid === true ? [] : undefined; // Check for common mistakes during construction to produce early errors. + + (0, _isObjectLike.isObjectLike)(config) || + (0, _devAssert.devAssert)(false, 'Must provide configuration object.'); + !config.types || + Array.isArray(config.types) || + (0, _devAssert.devAssert)( + false, + `"types" must be Array if provided but got: ${(0, _inspect.inspect)( + config.types, + )}.`, + ); + !config.directives || + Array.isArray(config.directives) || + (0, _devAssert.devAssert)( + false, + '"directives" must be Array if provided but got: ' + + `${(0, _inspect.inspect)(config.directives)}.`, + ); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + this._queryType = config.query; + this._mutationType = config.mutation; + this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default. + + this._directives = + (_config$directives = config.directives) !== null && + _config$directives !== void 0 + ? _config$directives + : _directives.specifiedDirectives; // To preserve order of user-provided types, we add first to add them to + // the set of "collected" types, so `collectReferencedTypes` ignore them. + + const allReferencedTypes = new Set(config.types); + + if (config.types != null) { + for (const type of config.types) { + // When we ready to process this type, we remove it from "collected" types + // and then add it together with all dependent types in the correct position. + allReferencedTypes.delete(type); + collectReferencedTypes(type, allReferencedTypes); + } + } + + if (this._queryType != null) { + collectReferencedTypes(this._queryType, allReferencedTypes); + } + + if (this._mutationType != null) { + collectReferencedTypes(this._mutationType, allReferencedTypes); + } + + if (this._subscriptionType != null) { + collectReferencedTypes(this._subscriptionType, allReferencedTypes); + } + + for (const directive of this._directives) { + // Directives are not validated until validateSchema() is called. + if ((0, _directives.isDirective)(directive)) { + for (const arg of directive.args) { + collectReferencedTypes(arg.type, allReferencedTypes); + } + } + } + + collectReferencedTypes(_introspection.__Schema, allReferencedTypes); // Storing the resulting map for reference by the schema. + + this._typeMap = Object.create(null); + this._subTypeMap = Object.create(null); // Keep track of all implementations by interface name. + + this._implementationsMap = Object.create(null); + + for (const namedType of allReferencedTypes) { + if (namedType == null) { + continue; + } + + const typeName = namedType.name; + typeName || + (0, _devAssert.devAssert)( + false, + 'One of the provided types for building the Schema is missing a name.', + ); + + if (this._typeMap[typeName] !== undefined) { + throw new Error( + `Schema must contain uniquely named types but contains multiple types named "${typeName}".`, + ); + } + + this._typeMap[typeName] = namedType; + + if ((0, _definition.isInterfaceType)(namedType)) { + // Store implementations by interface. + for (const iface of namedType.getInterfaces()) { + if ((0, _definition.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.interfaces.push(namedType); + } + } + } else if ((0, _definition.isObjectType)(namedType)) { + // Store implementations by objects. + for (const iface of namedType.getInterfaces()) { + if ((0, _definition.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.objects.push(namedType); + } + } + } + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLSchema'; + } + + getQueryType() { + return this._queryType; + } + + getMutationType() { + return this._mutationType; + } + + getSubscriptionType() { + return this._subscriptionType; + } + + getRootType(operation) { + switch (operation) { + case _ast.OperationTypeNode.QUERY: + return this.getQueryType(); + + case _ast.OperationTypeNode.MUTATION: + return this.getMutationType(); + + case _ast.OperationTypeNode.SUBSCRIPTION: + return this.getSubscriptionType(); + } + } + + getTypeMap() { + return this._typeMap; + } + + getType(name) { + return this.getTypeMap()[name]; + } + + getPossibleTypes(abstractType) { + return (0, _definition.isUnionType)(abstractType) + ? abstractType.getTypes() + : this.getImplementations(abstractType).objects; + } + + getImplementations(interfaceType) { + const implementations = this._implementationsMap[interfaceType.name]; + return implementations !== null && implementations !== void 0 + ? implementations + : { + objects: [], + interfaces: [], + }; + } + + isSubType(abstractType, maybeSubType) { + let map = this._subTypeMap[abstractType.name]; + + if (map === undefined) { + map = Object.create(null); + + if ((0, _definition.isUnionType)(abstractType)) { + for (const type of abstractType.getTypes()) { + map[type.name] = true; + } + } else { + const implementations = this.getImplementations(abstractType); + + for (const type of implementations.objects) { + map[type.name] = true; + } + + for (const type of implementations.interfaces) { + map[type.name] = true; + } + } + + this._subTypeMap[abstractType.name] = map; + } + + return map[maybeSubType.name] !== undefined; + } + + getDirectives() { + return this._directives; + } + + getDirective(name) { + return this.getDirectives().find((directive) => directive.name === name); + } + + toConfig() { + return { + description: this.description, + query: this.getQueryType(), + mutation: this.getMutationType(), + subscription: this.getSubscriptionType(), + types: Object.values(this.getTypeMap()), + directives: this.getDirectives(), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + assumeValid: this.__validationErrors !== undefined, + }; + } +} + +exports.GraphQLSchema = GraphQLSchema; + +function collectReferencedTypes(type, typeSet) { + const namedType = (0, _definition.getNamedType)(type); + + if (!typeSet.has(namedType)) { + typeSet.add(namedType); + + if ((0, _definition.isUnionType)(namedType)) { + for (const memberType of namedType.getTypes()) { + collectReferencedTypes(memberType, typeSet); + } + } else if ( + (0, _definition.isObjectType)(namedType) || + (0, _definition.isInterfaceType)(namedType) + ) { + for (const interfaceType of namedType.getInterfaces()) { + collectReferencedTypes(interfaceType, typeSet); + } + + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + + for (const arg of field.args) { + collectReferencedTypes(arg.type, typeSet); + } + } + } else if ((0, _definition.isInputObjectType)(namedType)) { + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + } + } + } + + return typeSet; +} + + +/***/ }), + +/***/ 95929: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidSchema = assertValidSchema; +exports.validateSchema = validateSchema; + +var _inspect = __nccwpck_require__(17819); + +var _GraphQLError = __nccwpck_require__(66807); + +var _ast = __nccwpck_require__(20727); + +var _typeComparators = __nccwpck_require__(60700); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +var _schema = __nccwpck_require__(80613); + +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ +function validateSchema(schema) { + // First check to ensure the provided value is in fact a GraphQLSchema. + (0, _schema.assertSchema)(schema); // If this Schema has already been validated, return the previous results. + + if (schema.__validationErrors) { + return schema.__validationErrors; + } // Validate the schema, producing a list of errors. + + const context = new SchemaValidationContext(schema); + validateRootTypes(context); + validateDirectives(context); + validateTypes(context); // Persist the results of validation before returning to ensure validation + // does not run multiple times for this schema. + + const errors = context.getErrors(); + schema.__validationErrors = errors; + return errors; +} +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ + +function assertValidSchema(schema) { + const errors = validateSchema(schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + +class SchemaValidationContext { + constructor(schema) { + this._errors = []; + this.schema = schema; + } + + reportError(message, nodes) { + const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes; + + this._errors.push( + new _GraphQLError.GraphQLError(message, { + nodes: _nodes, + }), + ); + } + + getErrors() { + return this._errors; + } +} + +function validateRootTypes(context) { + const schema = context.schema; + const queryType = schema.getQueryType(); + + if (!queryType) { + context.reportError('Query root type must be provided.', schema.astNode); + } else if (!(0, _definition.isObjectType)(queryType)) { + var _getOperationTypeNode; + + context.reportError( + `Query root type must be Object type, it cannot be ${(0, + _inspect.inspect)(queryType)}.`, + (_getOperationTypeNode = getOperationTypeNode( + schema, + _ast.OperationTypeNode.QUERY, + )) !== null && _getOperationTypeNode !== void 0 + ? _getOperationTypeNode + : queryType.astNode, + ); + } + + const mutationType = schema.getMutationType(); + + if (mutationType && !(0, _definition.isObjectType)(mutationType)) { + var _getOperationTypeNode2; + + context.reportError( + 'Mutation root type must be Object type if provided, it cannot be ' + + `${(0, _inspect.inspect)(mutationType)}.`, + (_getOperationTypeNode2 = getOperationTypeNode( + schema, + _ast.OperationTypeNode.MUTATION, + )) !== null && _getOperationTypeNode2 !== void 0 + ? _getOperationTypeNode2 + : mutationType.astNode, + ); + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType && !(0, _definition.isObjectType)(subscriptionType)) { + var _getOperationTypeNode3; + + context.reportError( + 'Subscription root type must be Object type if provided, it cannot be ' + + `${(0, _inspect.inspect)(subscriptionType)}.`, + (_getOperationTypeNode3 = getOperationTypeNode( + schema, + _ast.OperationTypeNode.SUBSCRIPTION, + )) !== null && _getOperationTypeNode3 !== void 0 + ? _getOperationTypeNode3 + : subscriptionType.astNode, + ); + } +} + +function getOperationTypeNode(schema, operation) { + var _flatMap$find; + + return (_flatMap$find = [schema.astNode, ...schema.extensionASTNodes] + .flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (schemaNode) => { + var _schemaNode$operation; + + return ( + /* c8 ignore next */ + (_schemaNode$operation = + schemaNode === null || schemaNode === void 0 + ? void 0 + : schemaNode.operationTypes) !== null && + _schemaNode$operation !== void 0 + ? _schemaNode$operation + : [] + ); + }, + ) + .find((operationNode) => operationNode.operation === operation)) === null || + _flatMap$find === void 0 + ? void 0 + : _flatMap$find.type; +} + +function validateDirectives(context) { + for (const directive of context.schema.getDirectives()) { + // Ensure all directives are in fact GraphQL directives. + if (!(0, _directives.isDirective)(directive)) { + context.reportError( + `Expected directive but got: ${(0, _inspect.inspect)(directive)}.`, + directive === null || directive === void 0 ? void 0 : directive.astNode, + ); + continue; + } // Ensure they are named correctly. + + validateName(context, directive); // TODO: Ensure proper locations. + // Ensure the arguments are valid. + + for (const arg of directive.args) { + // Ensure they are named correctly. + validateName(context, arg); // Ensure the type is an input type. + + if (!(0, _definition.isInputType)(arg.type)) { + context.reportError( + `The type of @${directive.name}(${arg.name}:) must be Input Type ` + + `but got: ${(0, _inspect.inspect)(arg.type)}.`, + arg.astNode, + ); + } + + if ( + (0, _definition.isRequiredArgument)(arg) && + arg.deprecationReason != null + ) { + var _arg$astNode; + + context.reportError( + `Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode = arg.astNode) === null || _arg$astNode === void 0 + ? void 0 + : _arg$astNode.type, + ], + ); + } + } + } +} + +function validateName(context, node) { + // Ensure names are valid, however introspection types opt out. + if (node.name.startsWith('__')) { + context.reportError( + `Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, + node.astNode, + ); + } +} + +function validateTypes(context) { + const validateInputObjectCircularRefs = + createInputObjectCircularRefsValidator(context); + const typeMap = context.schema.getTypeMap(); + + for (const type of Object.values(typeMap)) { + // Ensure all provided types are in fact GraphQL type. + if (!(0, _definition.isNamedType)(type)) { + context.reportError( + `Expected GraphQL named type but got: ${(0, _inspect.inspect)(type)}.`, + type.astNode, + ); + continue; + } // Ensure it is named correctly (excluding introspection types). + + if (!(0, _introspection.isIntrospectionType)(type)) { + validateName(context, type); + } + + if ((0, _definition.isObjectType)(type)) { + // Ensure fields are valid + validateFields(context, type); // Ensure objects implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0, _definition.isInterfaceType)(type)) { + // Ensure fields are valid. + validateFields(context, type); // Ensure interfaces implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0, _definition.isUnionType)(type)) { + // Ensure Unions include valid member types. + validateUnionMembers(context, type); + } else if ((0, _definition.isEnumType)(type)) { + // Ensure Enums have valid values. + validateEnumValues(context, type); + } else if ((0, _definition.isInputObjectType)(type)) { + // Ensure Input Object fields are valid. + validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references + + validateInputObjectCircularRefs(type); + } + } +} + +function validateFields(context, type) { + const fields = Object.values(type.getFields()); // Objects and Interfaces both must define one or more fields. + + if (fields.length === 0) { + context.reportError(`Type ${type.name} must define one or more fields.`, [ + type.astNode, + ...type.extensionASTNodes, + ]); + } + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an output type + + if (!(0, _definition.isOutputType)(field.type)) { + var _field$astNode; + + context.reportError( + `The type of ${type.name}.${field.name} must be Output Type ` + + `but got: ${(0, _inspect.inspect)(field.type)}.`, + (_field$astNode = field.astNode) === null || _field$astNode === void 0 + ? void 0 + : _field$astNode.type, + ); + } // Ensure the arguments are valid + + for (const arg of field.args) { + const argName = arg.name; // Ensure they are named correctly. + + validateName(context, arg); // Ensure the type is an input type + + if (!(0, _definition.isInputType)(arg.type)) { + var _arg$astNode2; + + context.reportError( + `The type of ${type.name}.${field.name}(${argName}:) must be Input ` + + `Type but got: ${(0, _inspect.inspect)(arg.type)}.`, + (_arg$astNode2 = arg.astNode) === null || _arg$astNode2 === void 0 + ? void 0 + : _arg$astNode2.type, + ); + } + + if ( + (0, _definition.isRequiredArgument)(arg) && + arg.deprecationReason != null + ) { + var _arg$astNode3; + + context.reportError( + `Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode3 = arg.astNode) === null || _arg$astNode3 === void 0 + ? void 0 + : _arg$astNode3.type, + ], + ); + } + } + } +} + +function validateInterfaces(context, type) { + const ifaceTypeNames = Object.create(null); + + for (const iface of type.getInterfaces()) { + if (!(0, _definition.isInterfaceType)(iface)) { + context.reportError( + `Type ${(0, _inspect.inspect)( + type, + )} must only implement Interface types, ` + + `it cannot implement ${(0, _inspect.inspect)(iface)}.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (type === iface) { + context.reportError( + `Type ${type.name} cannot implement itself because it would create a circular reference.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (ifaceTypeNames[iface.name]) { + context.reportError( + `Type ${type.name} can only implement ${iface.name} once.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + ifaceTypeNames[iface.name] = true; + validateTypeImplementsAncestors(context, type, iface); + validateTypeImplementsInterface(context, type, iface); + } +} + +function validateTypeImplementsInterface(context, type, iface) { + const typeFieldMap = type.getFields(); // Assert each interface field is implemented. + + for (const ifaceField of Object.values(iface.getFields())) { + const fieldName = ifaceField.name; + const typeField = typeFieldMap[fieldName]; // Assert interface field exists on type. + + if (!typeField) { + context.reportError( + `Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, + [ifaceField.astNode, type.astNode, ...type.extensionASTNodes], + ); + continue; + } // Assert interface field type is satisfied by type field type, by being + // a valid subtype. (covariant) + + if ( + !(0, _typeComparators.isTypeSubTypeOf)( + context.schema, + typeField.type, + ifaceField.type, + ) + ) { + var _ifaceField$astNode, _typeField$astNode; + + context.reportError( + `Interface field ${iface.name}.${fieldName} expects type ` + + `${(0, _inspect.inspect)(ifaceField.type)} but ${ + type.name + }.${fieldName} ` + + `is type ${(0, _inspect.inspect)(typeField.type)}.`, + [ + (_ifaceField$astNode = ifaceField.astNode) === null || + _ifaceField$astNode === void 0 + ? void 0 + : _ifaceField$astNode.type, + (_typeField$astNode = typeField.astNode) === null || + _typeField$astNode === void 0 + ? void 0 + : _typeField$astNode.type, + ], + ); + } // Assert each interface field arg is implemented. + + for (const ifaceArg of ifaceField.args) { + const argName = ifaceArg.name; + const typeArg = typeField.args.find((arg) => arg.name === argName); // Assert interface field arg exists on object field. + + if (!typeArg) { + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, + [ifaceArg.astNode, typeField.astNode], + ); + continue; + } // Assert interface field arg type matches object field arg type. + // (invariant) + // TODO: change to contravariant? + + if (!(0, _typeComparators.isEqualType)(ifaceArg.type, typeArg.type)) { + var _ifaceArg$astNode, _typeArg$astNode; + + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + + `expects type ${(0, _inspect.inspect)(ifaceArg.type)} but ` + + `${type.name}.${fieldName}(${argName}:) is type ` + + `${(0, _inspect.inspect)(typeArg.type)}.`, + [ + (_ifaceArg$astNode = ifaceArg.astNode) === null || + _ifaceArg$astNode === void 0 + ? void 0 + : _ifaceArg$astNode.type, + (_typeArg$astNode = typeArg.astNode) === null || + _typeArg$astNode === void 0 + ? void 0 + : _typeArg$astNode.type, + ], + ); + } // TODO: validate default values? + } // Assert additional arguments must not be required. + + for (const typeArg of typeField.args) { + const argName = typeArg.name; + const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); + + if (!ifaceArg && (0, _definition.isRequiredArgument)(typeArg)) { + context.reportError( + `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, + [typeArg.astNode, ifaceField.astNode], + ); + } + } + } +} + +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError( + transitive === type + ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` + : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, + [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ], + ); + } + } +} + +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + + if (memberTypes.length === 0) { + context.reportError( + `Union type ${union.name} must define one or more member types.`, + [union.astNode, ...union.extensionASTNodes], + ); + } + + const includedTypeNames = Object.create(null); + + for (const memberType of memberTypes) { + if (includedTypeNames[memberType.name]) { + context.reportError( + `Union type ${union.name} can only include type ${memberType.name} once.`, + getUnionMemberTypeNodes(union, memberType.name), + ); + continue; + } + + includedTypeNames[memberType.name] = true; + + if (!(0, _definition.isObjectType)(memberType)) { + context.reportError( + `Union type ${union.name} can only include Object types, ` + + `it cannot include ${(0, _inspect.inspect)(memberType)}.`, + getUnionMemberTypeNodes(union, String(memberType)), + ); + } + } +} + +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + + if (enumValues.length === 0) { + context.reportError( + `Enum type ${enumType.name} must define one or more values.`, + [enumType.astNode, ...enumType.extensionASTNodes], + ); + } + + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} + +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + + if (fields.length === 0) { + context.reportError( + `Input Object type ${inputObj.name} must define one or more fields.`, + [inputObj.astNode, ...inputObj.extensionASTNodes], + ); + } // Ensure the arguments are valid + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an input type + + if (!(0, _definition.isInputType)(field.type)) { + var _field$astNode2; + + context.reportError( + `The type of ${inputObj.name}.${field.name} must be Input Type ` + + `but got: ${(0, _inspect.inspect)(field.type)}.`, + (_field$astNode2 = field.astNode) === null || _field$astNode2 === void 0 + ? void 0 + : _field$astNode2.type, + ); + } + + if ( + (0, _definition.isRequiredInputField)(field) && + field.deprecationReason != null + ) { + var _field$astNode3; + + context.reportError( + `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(field.astNode), + (_field$astNode3 = field.astNode) === null || + _field$astNode3 === void 0 + ? void 0 + : _field$astNode3.type, + ], + ); + } + } +} + +function createInputObjectCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors + + const fieldPath = []; // Position in the type path + + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(inputObj) { + if (visitedTypes[inputObj.name]) { + return; + } + + visitedTypes[inputObj.name] = true; + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + + for (const field of fields) { + if ( + (0, _definition.isNonNullType)(field.type) && + (0, _definition.isInputObjectType)(field.type.ofType) + ) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push(field); + + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); + context.reportError( + `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, + cyclePath.map((fieldObj) => fieldObj.astNode), + ); + } + + fieldPath.pop(); + } + } + + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} + +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((typeNode) => { + var _typeNode$interfaces; + + return ( + /* c8 ignore next */ + (_typeNode$interfaces = typeNode.interfaces) !== null && + _typeNode$interfaces !== void 0 + ? _typeNode$interfaces + : [] + ); + }) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} + +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((unionNode) => { + var _unionNode$types; + + return ( + /* c8 ignore next */ + (_unionNode$types = unionNode.types) !== null && + _unionNode$types !== void 0 + ? _unionNode$types + : [] + ); + }) + .filter((typeNode) => typeNode.name.value === typeName); +} + +function getDeprecatedDirectiveNode(definitionNode) { + var _definitionNode$direc; + + return definitionNode === null || definitionNode === void 0 + ? void 0 + : (_definitionNode$direc = definitionNode.directives) === null || + _definitionNode$direc === void 0 + ? void 0 + : _definitionNode$direc.find( + (node) => + node.name.value === _directives.GraphQLDeprecatedDirective.name, + ); +} + + +/***/ }), + +/***/ 95756: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.TypeInfo = void 0; +exports.visitWithTypeInfo = visitWithTypeInfo; + +var _ast = __nccwpck_require__(20727); + +var _kinds = __nccwpck_require__(19542); + +var _visitor = __nccwpck_require__(45946); + +var _definition = __nccwpck_require__(49492); + +var _introspection = __nccwpck_require__(98029); + +var _typeFromAST = __nccwpck_require__(73461); + +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +class TypeInfo { + constructor( + schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, + /** @deprecated will be removed in 17.0.0 */ + getFieldDefFn, + ) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._getFieldDef = + getFieldDefFn !== null && getFieldDefFn !== void 0 + ? getFieldDefFn + : getFieldDef; + + if (initialType) { + if ((0, _definition.isInputType)(initialType)) { + this._inputTypeStack.push(initialType); + } + + if ((0, _definition.isCompositeType)(initialType)) { + this._parentTypeStack.push(initialType); + } + + if ((0, _definition.isOutputType)(initialType)) { + this._typeStack.push(initialType); + } + } + } + + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + + getType() { + if (this._typeStack.length > 0) { + return this._typeStack[this._typeStack.length - 1]; + } + } + + getParentType() { + if (this._parentTypeStack.length > 0) { + return this._parentTypeStack[this._parentTypeStack.length - 1]; + } + } + + getInputType() { + if (this._inputTypeStack.length > 0) { + return this._inputTypeStack[this._inputTypeStack.length - 1]; + } + } + + getParentInputType() { + if (this._inputTypeStack.length > 1) { + return this._inputTypeStack[this._inputTypeStack.length - 2]; + } + } + + getFieldDef() { + if (this._fieldDefStack.length > 0) { + return this._fieldDefStack[this._fieldDefStack.length - 1]; + } + } + + getDefaultValue() { + if (this._defaultValueStack.length > 0) { + return this._defaultValueStack[this._defaultValueStack.length - 1]; + } + } + + getDirective() { + return this._directive; + } + + getArgument() { + return this._argument; + } + + getEnumValue() { + return this._enumValue; + } + + enter(node) { + const schema = this._schema; // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: { + const namedType = (0, _definition.getNamedType)(this.getType()); + + this._parentTypeStack.push( + (0, _definition.isCompositeType)(namedType) ? namedType : undefined, + ); + + break; + } + + case _kinds.Kind.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + + if (parentType) { + fieldDef = this._getFieldDef(schema, parentType, node); + + if (fieldDef) { + fieldType = fieldDef.type; + } + } + + this._fieldDefStack.push(fieldDef); + + this._typeStack.push( + (0, _definition.isOutputType)(fieldType) ? fieldType : undefined, + ); + + break; + } + + case _kinds.Kind.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + + case _kinds.Kind.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + + this._typeStack.push( + (0, _definition.isObjectType)(rootType) ? rootType : undefined, + ); + + break; + } + + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) + : (0, _definition.getNamedType)(this.getType()); + + this._typeStack.push( + (0, _definition.isOutputType)(outputType) ? outputType : undefined, + ); + + break; + } + + case _kinds.Kind.VARIABLE_DEFINITION: { + const inputType = (0, _typeFromAST.typeFromAST)(schema, node.type); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputType) ? inputType : undefined, + ); + + break; + } + + case _kinds.Kind.ARGUMENT: { + var _this$getDirective; + + let argDef; + let argType; + const fieldOrDirective = + (_this$getDirective = this.getDirective()) !== null && + _this$getDirective !== void 0 + ? _this$getDirective + : this.getFieldDef(); + + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find( + (arg) => arg.name === node.name.value, + ); + + if (argDef) { + argType = argDef.type; + } + } + + this._argument = argDef; + + this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(argType) ? argType : undefined, + ); + + break; + } + + case _kinds.Kind.LIST: { + const listType = (0, _definition.getNullableType)(this.getInputType()); + const itemType = (0, _definition.isListType)(listType) + ? listType.ofType + : listType; // List positions never have a default value. + + this._defaultValueStack.push(undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(itemType) ? itemType : undefined, + ); + + break; + } + + case _kinds.Kind.OBJECT_FIELD: { + const objectType = (0, _definition.getNamedType)(this.getInputType()); + let inputFieldType; + let inputField; + + if ((0, _definition.isInputObjectType)(objectType)) { + inputField = objectType.getFields()[node.name.value]; + + if (inputField) { + inputFieldType = inputField.type; + } + } + + this._defaultValueStack.push( + inputField ? inputField.defaultValue : undefined, + ); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputFieldType) + ? inputFieldType + : undefined, + ); + + break; + } + + case _kinds.Kind.ENUM: { + const enumType = (0, _definition.getNamedType)(this.getInputType()); + let enumValue; + + if ((0, _definition.isEnumType)(enumType)) { + enumValue = enumType.getValue(node.value); + } + + this._enumValue = enumValue; + break; + } + + default: // Ignore other nodes + } + } + + leave(node) { + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: + this._parentTypeStack.pop(); + + break; + + case _kinds.Kind.FIELD: + this._fieldDefStack.pop(); + + this._typeStack.pop(); + + break; + + case _kinds.Kind.DIRECTIVE: + this._directive = null; + break; + + case _kinds.Kind.OPERATION_DEFINITION: + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: + this._typeStack.pop(); + + break; + + case _kinds.Kind.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.ARGUMENT: + this._argument = null; + + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.LIST: + case _kinds.Kind.OBJECT_FIELD: + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.ENUM: + this._enumValue = null; + break; + + default: // Ignore other nodes + } + } +} + +exports.TypeInfo = TypeInfo; + +/** + * Not exactly the same as the executor's definition of getFieldDef, in this + * statically evaluated environment we do not always have an Object type, + * and need to handle Interface and Union types. + */ +function getFieldDef(schema, parentType, fieldNode) { + const name = fieldNode.name.value; + + if ( + name === _introspection.SchemaMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.SchemaMetaFieldDef; + } + + if ( + name === _introspection.TypeMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.TypeMetaFieldDef; + } + + if ( + name === _introspection.TypeNameMetaFieldDef.name && + (0, _definition.isCompositeType)(parentType) + ) { + return _introspection.TypeNameMetaFieldDef; + } + + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + return parentType.getFields()[name]; + } +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ + +function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).enter; + + if (fn) { + const result = fn.apply(visitor, args); + + if (result !== undefined) { + typeInfo.leave(node); + + if ((0, _ast.isNode)(result)) { + typeInfo.enter(result); + } + } + + return result; + } + }, + + leave(...args) { + const node = args[0]; + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).leave; + let result; + + if (fn) { + result = fn.apply(visitor, args); + } + + typeInfo.leave(node); + return result; + }, + }; +} + + +/***/ }), + +/***/ 74411: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidName = assertValidName; +exports.isValidNameError = isValidNameError; + +var _devAssert = __nccwpck_require__(60645); + +var _GraphQLError = __nccwpck_require__(66807); + +var _assertName = __nccwpck_require__(52223); + +/* c8 ignore start */ + +/** + * Upholds the spec rules about naming. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ +function assertValidName(name) { + const error = isValidNameError(name); + + if (error) { + throw error; + } + + return name; +} +/** + * Returns an Error if a name is invalid. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ + +function isValidNameError(name) { + typeof name === 'string' || + (0, _devAssert.devAssert)(false, 'Expected name to be a string.'); + + if (name.startsWith('__')) { + return new _GraphQLError.GraphQLError( + `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, + ); + } + + try { + (0, _assertName.assertName)(name); + } catch (error) { + return error; + } +} +/* c8 ignore stop */ + + +/***/ }), + +/***/ 68906: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.astFromValue = astFromValue; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _isIterableObject = __nccwpck_require__(45988); + +var _isObjectLike = __nccwpck_require__(63457); + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +var _scalars = __nccwpck_require__(14544); + +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + */ +function astFromValue(value, type) { + if ((0, _definition.isNonNullType)(type)) { + const astValue = astFromValue(value, type.ofType); + + if ( + (astValue === null || astValue === void 0 ? void 0 : astValue.kind) === + _kinds.Kind.NULL + ) { + return null; + } + + return astValue; + } // only explicit null, not undefined, NaN + + if (value === null) { + return { + kind: _kinds.Kind.NULL, + }; + } // undefined + + if (value === undefined) { + return null; + } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if ((0, _isIterableObject.isIterableObject)(value)) { + const valuesNodes = []; + + for (const item of value) { + const itemNode = astFromValue(item, itemType); + + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + + return { + kind: _kinds.Kind.LIST, + values: valuesNodes, + }; + } + + return astFromValue(value, itemType); + } // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(value)) { + return null; + } + + const fieldNodes = []; + + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + + if (fieldValue) { + fieldNodes.push({ + kind: _kinds.Kind.OBJECT_FIELD, + name: { + kind: _kinds.Kind.NAME, + value: field.name, + }, + value: fieldValue, + }); + } + } + + return { + kind: _kinds.Kind.OBJECT, + fields: fieldNodes, + }; + } + + if ((0, _definition.isLeafType)(type)) { + // Since value is an internally represented value, it must be serialized + // to an externally represented value before converting into an AST. + const serialized = type.serialize(value); + + if (serialized == null) { + return null; + } // Others serialize based on their corresponding JavaScript scalar types. + + if (typeof serialized === 'boolean') { + return { + kind: _kinds.Kind.BOOLEAN, + value: serialized, + }; + } // JavaScript numbers can be Int or Float values. + + if (typeof serialized === 'number' && Number.isFinite(serialized)) { + const stringNum = String(serialized); + return integerStringRegExp.test(stringNum) + ? { + kind: _kinds.Kind.INT, + value: stringNum, + } + : { + kind: _kinds.Kind.FLOAT, + value: stringNum, + }; + } + + if (typeof serialized === 'string') { + // Enum types use Enum literals. + if ((0, _definition.isEnumType)(type)) { + return { + kind: _kinds.Kind.ENUM, + value: serialized, + }; + } // ID types can use Int literals. + + if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) { + return { + kind: _kinds.Kind.INT, + value: serialized, + }; + } + + return { + kind: _kinds.Kind.STRING, + value: serialized, + }; + } + + throw new TypeError( + `Cannot convert value to AST: ${(0, _inspect.inspect)(serialized)}.`, + ); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ + +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; + + +/***/ }), + +/***/ 36570: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.buildASTSchema = buildASTSchema; +exports.buildSchema = buildSchema; + +var _devAssert = __nccwpck_require__(60645); + +var _kinds = __nccwpck_require__(19542); + +var _parser = __nccwpck_require__(39927); + +var _directives = __nccwpck_require__(34154); + +var _schema = __nccwpck_require__(80613); + +var _validate = __nccwpck_require__(17329); + +var _extendSchema = __nccwpck_require__(43476); + +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +function buildASTSchema(documentAST, options) { + (documentAST != null && documentAST.kind === _kinds.Kind.DOCUMENT) || + (0, _devAssert.devAssert)(false, 'Must provide valid Document AST.'); + + if ( + (options === null || options === void 0 ? void 0 : options.assumeValid) !== + true && + (options === null || options === void 0 + ? void 0 + : options.assumeValidSDL) !== true + ) { + (0, _validate.assertValidSDL)(documentAST); + } + + const emptySchemaConfig = { + description: undefined, + types: [], + directives: [], + extensions: Object.create(null), + extensionASTNodes: [], + assumeValid: false, + }; + const config = (0, _extendSchema.extendSchemaImpl)( + emptySchemaConfig, + documentAST, + options, + ); + + if (config.astNode == null) { + for (const type of config.types) { + switch (type.name) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + case 'Query': + // @ts-expect-error validated in `validateSchema` + config.query = type; + break; + + case 'Mutation': + // @ts-expect-error validated in `validateSchema` + config.mutation = type; + break; + + case 'Subscription': + // @ts-expect-error validated in `validateSchema` + config.subscription = type; + break; + } + } + } + + const directives = [ + ...config.directives, // If specified directives were not explicitly declared, add them. + ..._directives.specifiedDirectives.filter((stdDirective) => + config.directives.every( + (directive) => directive.name !== stdDirective.name, + ), + ), + ]; + return new _schema.GraphQLSchema({ ...config, directives }); +} +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ + +function buildSchema(source, options) { + const document = (0, _parser.parse)(source, { + noLocation: + options === null || options === void 0 ? void 0 : options.noLocation, + allowLegacyFragmentVariables: + options === null || options === void 0 + ? void 0 + : options.allowLegacyFragmentVariables, + }); + return buildASTSchema(document, { + assumeValidSDL: + options === null || options === void 0 ? void 0 : options.assumeValidSDL, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); +} + + +/***/ }), + +/***/ 10404: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.buildClientSchema = buildClientSchema; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _isObjectLike = __nccwpck_require__(63457); + +var _keyValMap = __nccwpck_require__(69662); + +var _parser = __nccwpck_require__(39927); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +var _scalars = __nccwpck_require__(14544); + +var _schema = __nccwpck_require__(80613); + +var _valueFromAST = __nccwpck_require__(81172); + +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "parse" or "serialize" functions or any other + * server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ +function buildClientSchema(introspection, options) { + ((0, _isObjectLike.isObjectLike)(introspection) && + (0, _isObjectLike.isObjectLike)(introspection.__schema)) || + (0, _devAssert.devAssert)( + false, + `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${(0, + _inspect.inspect)(introspection)}.`, + ); // Get the schema from the introspection result. + + const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each. + + const typeMap = (0, _keyValMap.keyValMap)( + schemaIntrospection.types, + (typeIntrospection) => typeIntrospection.name, + (typeIntrospection) => buildType(typeIntrospection), + ); // Include standard types only if they are used. + + for (const stdType of [ + ..._scalars.specifiedScalarTypes, + ..._introspection.introspectionTypes, + ]) { + if (typeMap[stdType.name]) { + typeMap[stdType.name] = stdType; + } + } // Get the root Query, Mutation, and Subscription types. + + const queryType = schemaIntrospection.queryType + ? getObjectType(schemaIntrospection.queryType) + : null; + const mutationType = schemaIntrospection.mutationType + ? getObjectType(schemaIntrospection.mutationType) + : null; + const subscriptionType = schemaIntrospection.subscriptionType + ? getObjectType(schemaIntrospection.subscriptionType) + : null; // Get the directives supported by Introspection, assuming empty-set if + // directives were not queried for. + + const directives = schemaIntrospection.directives + ? schemaIntrospection.directives.map(buildDirective) + : []; // Then produce and return a Schema with these types. + + return new _schema.GraphQLSchema({ + description: schemaIntrospection.description, + query: queryType, + mutation: mutationType, + subscription: subscriptionType, + types: Object.values(typeMap), + directives, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); // Given a type reference in introspection, return the GraphQLType instance. + // preferring cached instances before building new instances. + + function getType(typeRef) { + if (typeRef.kind === _introspection.TypeKind.LIST) { + const itemRef = typeRef.ofType; + + if (!itemRef) { + throw new Error('Decorated type deeper than introspection query.'); + } + + return new _definition.GraphQLList(getType(itemRef)); + } + + if (typeRef.kind === _introspection.TypeKind.NON_NULL) { + const nullableRef = typeRef.ofType; + + if (!nullableRef) { + throw new Error('Decorated type deeper than introspection query.'); + } + + const nullableType = getType(nullableRef); + return new _definition.GraphQLNonNull( + (0, _definition.assertNullableType)(nullableType), + ); + } + + return getNamedType(typeRef); + } + + function getNamedType(typeRef) { + const typeName = typeRef.name; + + if (!typeName) { + throw new Error( + `Unknown type reference: ${(0, _inspect.inspect)(typeRef)}.`, + ); + } + + const type = typeMap[typeName]; + + if (!type) { + throw new Error( + `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`, + ); + } + + return type; + } + + function getObjectType(typeRef) { + return (0, _definition.assertObjectType)(getNamedType(typeRef)); + } + + function getInterfaceType(typeRef) { + return (0, _definition.assertInterfaceType)(getNamedType(typeRef)); + } // Given a type's introspection result, construct the correct + // GraphQLType instance. + + function buildType(type) { + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain + if (type != null && type.name != null && type.kind != null) { + // FIXME: Properly type IntrospectionType, it's a breaking change so fix in v17 + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check + switch (type.kind) { + case _introspection.TypeKind.SCALAR: + return buildScalarDef(type); + + case _introspection.TypeKind.OBJECT: + return buildObjectDef(type); + + case _introspection.TypeKind.INTERFACE: + return buildInterfaceDef(type); + + case _introspection.TypeKind.UNION: + return buildUnionDef(type); + + case _introspection.TypeKind.ENUM: + return buildEnumDef(type); + + case _introspection.TypeKind.INPUT_OBJECT: + return buildInputObjectDef(type); + } + } + + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`, + ); + } + + function buildScalarDef(scalarIntrospection) { + return new _definition.GraphQLScalarType({ + name: scalarIntrospection.name, + description: scalarIntrospection.description, + specifiedByURL: scalarIntrospection.specifiedByURL, + }); + } + + function buildImplementationsList(implementingIntrospection) { + // TODO: Temporary workaround until GraphQL ecosystem will fully support + // 'interfaces' on interface types. + if ( + implementingIntrospection.interfaces === null && + implementingIntrospection.kind === _introspection.TypeKind.INTERFACE + ) { + return []; + } + + if (!implementingIntrospection.interfaces) { + const implementingIntrospectionStr = (0, _inspect.inspect)( + implementingIntrospection, + ); + throw new Error( + `Introspection result missing interfaces: ${implementingIntrospectionStr}.`, + ); + } + + return implementingIntrospection.interfaces.map(getInterfaceType); + } + + function buildObjectDef(objectIntrospection) { + return new _definition.GraphQLObjectType({ + name: objectIntrospection.name, + description: objectIntrospection.description, + interfaces: () => buildImplementationsList(objectIntrospection), + fields: () => buildFieldDefMap(objectIntrospection), + }); + } + + function buildInterfaceDef(interfaceIntrospection) { + return new _definition.GraphQLInterfaceType({ + name: interfaceIntrospection.name, + description: interfaceIntrospection.description, + interfaces: () => buildImplementationsList(interfaceIntrospection), + fields: () => buildFieldDefMap(interfaceIntrospection), + }); + } + + function buildUnionDef(unionIntrospection) { + if (!unionIntrospection.possibleTypes) { + const unionIntrospectionStr = (0, _inspect.inspect)(unionIntrospection); + throw new Error( + `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`, + ); + } + + return new _definition.GraphQLUnionType({ + name: unionIntrospection.name, + description: unionIntrospection.description, + types: () => unionIntrospection.possibleTypes.map(getObjectType), + }); + } + + function buildEnumDef(enumIntrospection) { + if (!enumIntrospection.enumValues) { + const enumIntrospectionStr = (0, _inspect.inspect)(enumIntrospection); + throw new Error( + `Introspection result missing enumValues: ${enumIntrospectionStr}.`, + ); + } + + return new _definition.GraphQLEnumType({ + name: enumIntrospection.name, + description: enumIntrospection.description, + values: (0, _keyValMap.keyValMap)( + enumIntrospection.enumValues, + (valueIntrospection) => valueIntrospection.name, + (valueIntrospection) => ({ + description: valueIntrospection.description, + deprecationReason: valueIntrospection.deprecationReason, + }), + ), + }); + } + + function buildInputObjectDef(inputObjectIntrospection) { + if (!inputObjectIntrospection.inputFields) { + const inputObjectIntrospectionStr = (0, _inspect.inspect)( + inputObjectIntrospection, + ); + throw new Error( + `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`, + ); + } + + return new _definition.GraphQLInputObjectType({ + name: inputObjectIntrospection.name, + description: inputObjectIntrospection.description, + fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), + }); + } + + function buildFieldDefMap(typeIntrospection) { + if (!typeIntrospection.fields) { + throw new Error( + `Introspection result missing fields: ${(0, _inspect.inspect)( + typeIntrospection, + )}.`, + ); + } + + return (0, _keyValMap.keyValMap)( + typeIntrospection.fields, + (fieldIntrospection) => fieldIntrospection.name, + buildField, + ); + } + + function buildField(fieldIntrospection) { + const type = getType(fieldIntrospection.type); + + if (!(0, _definition.isOutputType)(type)) { + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Introspection must provide output type for fields, but received: ${typeStr}.`, + ); + } + + if (!fieldIntrospection.args) { + const fieldIntrospectionStr = (0, _inspect.inspect)(fieldIntrospection); + throw new Error( + `Introspection result missing field args: ${fieldIntrospectionStr}.`, + ); + } + + return { + description: fieldIntrospection.description, + deprecationReason: fieldIntrospection.deprecationReason, + type, + args: buildInputValueDefMap(fieldIntrospection.args), + }; + } + + function buildInputValueDefMap(inputValueIntrospections) { + return (0, _keyValMap.keyValMap)( + inputValueIntrospections, + (inputValue) => inputValue.name, + buildInputValue, + ); + } + + function buildInputValue(inputValueIntrospection) { + const type = getType(inputValueIntrospection.type); + + if (!(0, _definition.isInputType)(type)) { + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Introspection must provide input type for arguments, but received: ${typeStr}.`, + ); + } + + const defaultValue = + inputValueIntrospection.defaultValue != null + ? (0, _valueFromAST.valueFromAST)( + (0, _parser.parseValue)(inputValueIntrospection.defaultValue), + type, + ) + : undefined; + return { + description: inputValueIntrospection.description, + type, + defaultValue, + deprecationReason: inputValueIntrospection.deprecationReason, + }; + } + + function buildDirective(directiveIntrospection) { + if (!directiveIntrospection.args) { + const directiveIntrospectionStr = (0, _inspect.inspect)( + directiveIntrospection, + ); + throw new Error( + `Introspection result missing directive args: ${directiveIntrospectionStr}.`, + ); + } + + if (!directiveIntrospection.locations) { + const directiveIntrospectionStr = (0, _inspect.inspect)( + directiveIntrospection, + ); + throw new Error( + `Introspection result missing directive locations: ${directiveIntrospectionStr}.`, + ); + } + + return new _directives.GraphQLDirective({ + name: directiveIntrospection.name, + description: directiveIntrospection.description, + isRepeatable: directiveIntrospection.isRepeatable, + locations: directiveIntrospection.locations.slice(), + args: buildInputValueDefMap(directiveIntrospection.args), + }); + } +} + + +/***/ }), + +/***/ 71623: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.coerceInputValue = coerceInputValue; + +var _didYouMean = __nccwpck_require__(94476); + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _isIterableObject = __nccwpck_require__(45988); + +var _isObjectLike = __nccwpck_require__(63457); + +var _Path = __nccwpck_require__(80333); + +var _printPathArray = __nccwpck_require__(49802); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * Coerces a JavaScript value given a GraphQL Input Type. + */ +function coerceInputValue(inputValue, type, onError = defaultOnError) { + return coerceInputValueImpl(inputValue, type, onError, undefined); +} + +function defaultOnError(path, invalidValue, error) { + let errorPrefix = 'Invalid value ' + (0, _inspect.inspect)(invalidValue); + + if (path.length > 0) { + errorPrefix += ` at "value${(0, _printPathArray.printPathArray)(path)}"`; + } + + error.message = errorPrefix + ': ' + error.message; + throw error; +} + +function coerceInputValueImpl(inputValue, type, onError, path) { + if ((0, _definition.isNonNullType)(type)) { + if (inputValue != null) { + return coerceInputValueImpl(inputValue, type.ofType, onError, path); + } + + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected non-nullable type "${(0, _inspect.inspect)( + type, + )}" not to be null.`, + ), + ); + return; + } + + if (inputValue == null) { + // Explicitly return the value null. + return null; + } + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if ((0, _isIterableObject.isIterableObject)(inputValue)) { + return Array.from(inputValue, (itemValue, index) => { + const itemPath = (0, _Path.addPath)(path, index, undefined); + return coerceInputValueImpl(itemValue, itemType, onError, itemPath); + }); + } // Lists accept a non-list value as a list of one. + + return [coerceInputValueImpl(inputValue, itemType, onError, path)]; + } + + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(inputValue)) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}" to be an object.`, + ), + ); + return; + } + + const coercedValue = {}; + const fieldDefs = type.getFields(); + + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + + if (fieldValue === undefined) { + if (field.defaultValue !== undefined) { + coercedValue[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + const typeStr = (0, _inspect.inspect)(field.type); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${field.name}" of required type "${typeStr}" was not provided.`, + ), + ); + } + + continue; + } + + coercedValue[field.name] = coerceInputValueImpl( + fieldValue, + field.type, + onError, + (0, _Path.addPath)(path, field.name, type.name), + ); + } // Ensure every provided field is defined. + + for (const fieldName of Object.keys(inputValue)) { + if (!fieldDefs[fieldName]) { + const suggestions = (0, _suggestionList.suggestionList)( + fieldName, + Object.keys(type.getFields()), + ); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${fieldName}" is not defined by type "${type.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + ), + ); + } + } + + return coercedValue; + } + + if ((0, _definition.isLeafType)(type)) { + let parseResult; // Scalars and Enums determine if a input value is valid via parseValue(), + // which can throw to indicate failure. If it throws, maintain a reference + // to the original error. + + try { + parseResult = type.parseValue(inputValue); + } catch (error) { + if (error instanceof _GraphQLError.GraphQLError) { + onError((0, _Path.pathToArray)(path), inputValue, error); + } else { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}". ` + error.message, + { + originalError: error, + }, + ), + ); + } + + return; + } + + if (parseResult === undefined) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError(`Expected type "${type.name}".`), + ); + } + + return parseResult; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} + + +/***/ }), + +/***/ 50066: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.concatAST = concatAST; + +var _kinds = __nccwpck_require__(19542); + +/** + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. + */ +function concatAST(documents) { + const definitions = []; + + for (const doc of documents) { + definitions.push(...doc.definitions); + } + + return { + kind: _kinds.Kind.DOCUMENT, + definitions, + }; +} + + +/***/ }), + +/***/ 43476: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.extendSchema = extendSchema; +exports.extendSchemaImpl = extendSchemaImpl; + +var _devAssert = __nccwpck_require__(60645); + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _keyMap = __nccwpck_require__(35053); + +var _mapValue = __nccwpck_require__(31687); + +var _kinds = __nccwpck_require__(19542); + +var _predicates = __nccwpck_require__(2493); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +var _scalars = __nccwpck_require__(14544); + +var _schema = __nccwpck_require__(80613); + +var _validate = __nccwpck_require__(17329); + +var _values = __nccwpck_require__(30848); + +var _valueFromAST = __nccwpck_require__(81172); + +/** + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. + * + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. + * + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. + */ +function extendSchema(schema, documentAST, options) { + (0, _schema.assertSchema)(schema); + (documentAST != null && documentAST.kind === _kinds.Kind.DOCUMENT) || + (0, _devAssert.devAssert)(false, 'Must provide valid Document AST.'); + + if ( + (options === null || options === void 0 ? void 0 : options.assumeValid) !== + true && + (options === null || options === void 0 + ? void 0 + : options.assumeValidSDL) !== true + ) { + (0, _validate.assertValidSDLExtension)(documentAST, schema); + } + + const schemaConfig = schema.toConfig(); + const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); + return schemaConfig === extendedConfig + ? schema + : new _schema.GraphQLSchema(extendedConfig); +} +/** + * @internal + */ + +function extendSchemaImpl(schemaConfig, documentAST, options) { + var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid; + + // Collect the type definitions and extensions found in the document. + const typeDefs = []; + const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can + // have the same name. For example, a type named "skip". + + const directiveDefs = []; + let schemaDef; // Schema extensions are collected which may add additional operation types. + + const schemaExtensions = []; + + for (const def of documentAST.definitions) { + if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) { + schemaDef = def; + } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) { + schemaExtensions.push(def); + } else if ((0, _predicates.isTypeDefinitionNode)(def)) { + typeDefs.push(def); + } else if ((0, _predicates.isTypeExtensionNode)(def)) { + const extendedTypeName = def.name.value; + const existingTypeExtensions = typeExtensionsMap[extendedTypeName]; + typeExtensionsMap[extendedTypeName] = existingTypeExtensions + ? existingTypeExtensions.concat([def]) + : [def]; + } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + directiveDefs.push(def); + } + } // If this document contains no new types, extensions, or directives then + // return the same unmodified GraphQLSchema instance. + + if ( + Object.keys(typeExtensionsMap).length === 0 && + typeDefs.length === 0 && + directiveDefs.length === 0 && + schemaExtensions.length === 0 && + schemaDef == null + ) { + return schemaConfig; + } + + const typeMap = Object.create(null); + + for (const existingType of schemaConfig.types) { + typeMap[existingType.name] = extendNamedType(existingType); + } + + for (const typeNode of typeDefs) { + var _stdTypeMap$name; + + const name = typeNode.name.value; + typeMap[name] = + (_stdTypeMap$name = stdTypeMap[name]) !== null && + _stdTypeMap$name !== void 0 + ? _stdTypeMap$name + : buildType(typeNode); + } + + const operationTypes = { + // Get the extended root operation types. + query: schemaConfig.query && replaceNamedType(schemaConfig.query), + mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation), + subscription: + schemaConfig.subscription && replaceNamedType(schemaConfig.subscription), + // Then, incorporate schema definition and all schema extensions. + ...(schemaDef && getOperationTypes([schemaDef])), + ...getOperationTypes(schemaExtensions), + }; // Then produce and return a Schema config with these types. + + return { + description: + (_schemaDef = schemaDef) === null || _schemaDef === void 0 + ? void 0 + : (_schemaDef$descriptio = _schemaDef.description) === null || + _schemaDef$descriptio === void 0 + ? void 0 + : _schemaDef$descriptio.value, + ...operationTypes, + types: Object.values(typeMap), + directives: [ + ...schemaConfig.directives.map(replaceDirective), + ...directiveDefs.map(buildDirective), + ], + extensions: Object.create(null), + astNode: + (_schemaDef2 = schemaDef) !== null && _schemaDef2 !== void 0 + ? _schemaDef2 + : schemaConfig.astNode, + extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), + assumeValid: + (_options$assumeValid = + options === null || options === void 0 + ? void 0 + : options.assumeValid) !== null && _options$assumeValid !== void 0 + ? _options$assumeValid + : false, + }; // Below are functions used for producing this schema that have closed over + // this scope and have access to the schema, cache, and newly defined types. + + function replaceType(type) { + if ((0, _definition.isListType)(type)) { + // @ts-expect-error + return new _definition.GraphQLList(replaceType(type.ofType)); + } + + if ((0, _definition.isNonNullType)(type)) { + // @ts-expect-error + return new _definition.GraphQLNonNull(replaceType(type.ofType)); + } // @ts-expect-error FIXME + + return replaceNamedType(type); + } + + function replaceNamedType(type) { + // Note: While this could make early assertions to get the correctly + // typed values, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + return typeMap[type.name]; + } + + function replaceDirective(directive) { + const config = directive.toConfig(); + return new _directives.GraphQLDirective({ + ...config, + args: (0, _mapValue.mapValue)(config.args, extendArg), + }); + } + + function extendNamedType(type) { + if ( + (0, _introspection.isIntrospectionType)(type) || + (0, _scalars.isSpecifiedScalarType)(type) + ) { + // Builtin types are not extended. + return type; + } + + if ((0, _definition.isScalarType)(type)) { + return extendScalarType(type); + } + + if ((0, _definition.isObjectType)(type)) { + return extendObjectType(type); + } + + if ((0, _definition.isInterfaceType)(type)) { + return extendInterfaceType(type); + } + + if ((0, _definition.isUnionType)(type)) { + return extendUnionType(type); + } + + if ((0, _definition.isEnumType)(type)) { + return extendEnumType(type); + } + + if ((0, _definition.isInputObjectType)(type)) { + return extendInputObjectType(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible type definition nodes have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); + } + + function extendInputObjectType(type) { + var _typeExtensionsMap$co; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co !== void 0 + ? _typeExtensionsMap$co + : []; + return new _definition.GraphQLInputObjectType({ + ...config, + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, (field) => ({ + ...field, + type: replaceType(field.type), + })), + ...buildInputFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendEnumType(type) { + var _typeExtensionsMap$ty; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && + _typeExtensionsMap$ty !== void 0 + ? _typeExtensionsMap$ty + : []; + return new _definition.GraphQLEnumType({ + ...config, + values: { ...config.values, ...buildEnumValueMap(extensions) }, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendScalarType(type) { + var _typeExtensionsMap$co2; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co2 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co2 !== void 0 + ? _typeExtensionsMap$co2 + : []; + let specifiedByURL = config.specifiedByURL; + + for (const extensionNode of extensions) { + var _getSpecifiedByURL; + + specifiedByURL = + (_getSpecifiedByURL = getSpecifiedByURL(extensionNode)) !== null && + _getSpecifiedByURL !== void 0 + ? _getSpecifiedByURL + : specifiedByURL; + } + + return new _definition.GraphQLScalarType({ + ...config, + specifiedByURL, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendObjectType(type) { + var _typeExtensionsMap$co3; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co3 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co3 !== void 0 + ? _typeExtensionsMap$co3 + : []; + return new _definition.GraphQLObjectType({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendInterfaceType(type) { + var _typeExtensionsMap$co4; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co4 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co4 !== void 0 + ? _typeExtensionsMap$co4 + : []; + return new _definition.GraphQLInterfaceType({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendUnionType(type) { + var _typeExtensionsMap$co5; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co5 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co5 !== void 0 + ? _typeExtensionsMap$co5 + : []; + return new _definition.GraphQLUnionType({ + ...config, + types: () => [ + ...type.getTypes().map(replaceNamedType), + ...buildUnionTypes(extensions), + ], + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendField(field) { + return { + ...field, + type: replaceType(field.type), + args: field.args && (0, _mapValue.mapValue)(field.args, extendArg), + }; + } + + function extendArg(arg) { + return { ...arg, type: replaceType(arg.type) }; + } + + function getOperationTypes(nodes) { + const opTypes = {}; + + for (const node of nodes) { + var _node$operationTypes; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const operationTypesNodes = + /* c8 ignore next */ + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + opTypes[operationType.operation] = getNamedType(operationType.type); + } + } + + return opTypes; + } + + function getNamedType(node) { + var _stdTypeMap$name2; + + const name = node.name.value; + const type = + (_stdTypeMap$name2 = stdTypeMap[name]) !== null && + _stdTypeMap$name2 !== void 0 + ? _stdTypeMap$name2 + : typeMap[name]; + + if (type === undefined) { + throw new Error(`Unknown type: "${name}".`); + } + + return type; + } + + function getWrappedType(node) { + if (node.kind === _kinds.Kind.LIST_TYPE) { + return new _definition.GraphQLList(getWrappedType(node.type)); + } + + if (node.kind === _kinds.Kind.NON_NULL_TYPE) { + return new _definition.GraphQLNonNull(getWrappedType(node.type)); + } + + return getNamedType(node); + } + + function buildDirective(node) { + var _node$description; + + return new _directives.GraphQLDirective({ + name: node.name.value, + description: + (_node$description = node.description) === null || + _node$description === void 0 + ? void 0 + : _node$description.value, + // @ts-expect-error + locations: node.locations.map(({ value }) => value), + isRepeatable: node.repeatable, + args: buildArgumentMap(node.arguments), + astNode: node, + }); + } + + function buildFieldMap(nodes) { + const fieldConfigMap = Object.create(null); + + for (const node of nodes) { + var _node$fields; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const nodeFields = + /* c8 ignore next */ + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + + for (const field of nodeFields) { + var _field$description; + + fieldConfigMap[field.name.value] = { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + type: getWrappedType(field.type), + description: + (_field$description = field.description) === null || + _field$description === void 0 + ? void 0 + : _field$description.value, + args: buildArgumentMap(field.arguments), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + + return fieldConfigMap; + } + + function buildArgumentMap(args) { + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const argsNodes = + /* c8 ignore next */ + args !== null && args !== void 0 ? args : []; + const argConfigMap = Object.create(null); + + for (const arg of argsNodes) { + var _arg$description; + + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(arg.type); + argConfigMap[arg.name.value] = { + type, + description: + (_arg$description = arg.description) === null || + _arg$description === void 0 + ? void 0 + : _arg$description.value, + defaultValue: (0, _valueFromAST.valueFromAST)(arg.defaultValue, type), + deprecationReason: getDeprecationReason(arg), + astNode: arg, + }; + } + + return argConfigMap; + } + + function buildInputFieldMap(nodes) { + const inputFieldMap = Object.create(null); + + for (const node of nodes) { + var _node$fields2; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const fieldsNodes = + /* c8 ignore next */ + (_node$fields2 = node.fields) !== null && _node$fields2 !== void 0 + ? _node$fields2 + : []; + + for (const field of fieldsNodes) { + var _field$description2; + + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(field.type); + inputFieldMap[field.name.value] = { + type, + description: + (_field$description2 = field.description) === null || + _field$description2 === void 0 + ? void 0 + : _field$description2.value, + defaultValue: (0, _valueFromAST.valueFromAST)( + field.defaultValue, + type, + ), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + + return inputFieldMap; + } + + function buildEnumValueMap(nodes) { + const enumValueMap = Object.create(null); + + for (const node of nodes) { + var _node$values; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const valuesNodes = + /* c8 ignore next */ + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + + for (const value of valuesNodes) { + var _value$description; + + enumValueMap[value.name.value] = { + description: + (_value$description = value.description) === null || + _value$description === void 0 + ? void 0 + : _value$description.value, + deprecationReason: getDeprecationReason(value), + astNode: value, + }; + } + } + + return enumValueMap; + } + + function buildInterfaces(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$interfaces$map, _node$interfaces; + + return ( + /* c8 ignore next */ + (_node$interfaces$map = + (_node$interfaces = node.interfaces) === null || + _node$interfaces === void 0 + ? void 0 + : _node$interfaces.map(getNamedType)) !== null && + _node$interfaces$map !== void 0 + ? _node$interfaces$map + : [] + ); + }, + ); + } + + function buildUnionTypes(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$types$map, _node$types; + + return ( + /* c8 ignore next */ + (_node$types$map = + (_node$types = node.types) === null || _node$types === void 0 + ? void 0 + : _node$types.map(getNamedType)) !== null && + _node$types$map !== void 0 + ? _node$types$map + : [] + ); + }, + ); + } + + function buildType(astNode) { + var _typeExtensionsMap$na; + + const name = astNode.name.value; + const extensionASTNodes = + (_typeExtensionsMap$na = typeExtensionsMap[name]) !== null && + _typeExtensionsMap$na !== void 0 + ? _typeExtensionsMap$na + : []; + + switch (astNode.kind) { + case _kinds.Kind.OBJECT_TYPE_DEFINITION: { + var _astNode$description; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLObjectType({ + name, + description: + (_astNode$description = astNode.description) === null || + _astNode$description === void 0 + ? void 0 + : _astNode$description.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _kinds.Kind.INTERFACE_TYPE_DEFINITION: { + var _astNode$description2; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLInterfaceType({ + name, + description: + (_astNode$description2 = astNode.description) === null || + _astNode$description2 === void 0 + ? void 0 + : _astNode$description2.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _kinds.Kind.ENUM_TYPE_DEFINITION: { + var _astNode$description3; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLEnumType({ + name, + description: + (_astNode$description3 = astNode.description) === null || + _astNode$description3 === void 0 + ? void 0 + : _astNode$description3.value, + values: buildEnumValueMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _kinds.Kind.UNION_TYPE_DEFINITION: { + var _astNode$description4; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLUnionType({ + name, + description: + (_astNode$description4 = astNode.description) === null || + _astNode$description4 === void 0 + ? void 0 + : _astNode$description4.value, + types: () => buildUnionTypes(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _kinds.Kind.SCALAR_TYPE_DEFINITION: { + var _astNode$description5; + + return new _definition.GraphQLScalarType({ + name, + description: + (_astNode$description5 = astNode.description) === null || + _astNode$description5 === void 0 + ? void 0 + : _astNode$description5.value, + specifiedByURL: getSpecifiedByURL(astNode), + astNode, + extensionASTNodes, + }); + } + + case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: { + var _astNode$description6; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLInputObjectType({ + name, + description: + (_astNode$description6 = astNode.description) === null || + _astNode$description6 === void 0 + ? void 0 + : _astNode$description6.value, + fields: () => buildInputFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + } + } +} + +const stdTypeMap = (0, _keyMap.keyMap)( + [..._scalars.specifiedScalarTypes, ..._introspection.introspectionTypes], + (type) => type.name, +); +/** + * Given a field or enum value node, returns the string value for the + * deprecation reason. + */ + +function getDeprecationReason(node) { + const deprecated = (0, _values.getDirectiveValues)( + _directives.GraphQLDeprecatedDirective, + node, + ); // @ts-expect-error validated by `getDirectiveValues` + + return deprecated === null || deprecated === void 0 + ? void 0 + : deprecated.reason; +} +/** + * Given a scalar node, returns the string value for the specifiedByURL. + */ + +function getSpecifiedByURL(node) { + const specifiedBy = (0, _values.getDirectiveValues)( + _directives.GraphQLSpecifiedByDirective, + node, + ); // @ts-expect-error validated by `getDirectiveValues` + + return specifiedBy === null || specifiedBy === void 0 + ? void 0 + : specifiedBy.url; +} + + +/***/ }), + +/***/ 85927: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.DangerousChangeType = exports.BreakingChangeType = void 0; +exports.findBreakingChanges = findBreakingChanges; +exports.findDangerousChanges = findDangerousChanges; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _keyMap = __nccwpck_require__(35053); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _scalars = __nccwpck_require__(14544); + +var _astFromValue = __nccwpck_require__(68906); + +var _sortValueNode = __nccwpck_require__(21826); + +var BreakingChangeType; +exports.BreakingChangeType = BreakingChangeType; + +(function (BreakingChangeType) { + BreakingChangeType['TYPE_REMOVED'] = 'TYPE_REMOVED'; + BreakingChangeType['TYPE_CHANGED_KIND'] = 'TYPE_CHANGED_KIND'; + BreakingChangeType['TYPE_REMOVED_FROM_UNION'] = 'TYPE_REMOVED_FROM_UNION'; + BreakingChangeType['VALUE_REMOVED_FROM_ENUM'] = 'VALUE_REMOVED_FROM_ENUM'; + BreakingChangeType['REQUIRED_INPUT_FIELD_ADDED'] = + 'REQUIRED_INPUT_FIELD_ADDED'; + BreakingChangeType['IMPLEMENTED_INTERFACE_REMOVED'] = + 'IMPLEMENTED_INTERFACE_REMOVED'; + BreakingChangeType['FIELD_REMOVED'] = 'FIELD_REMOVED'; + BreakingChangeType['FIELD_CHANGED_KIND'] = 'FIELD_CHANGED_KIND'; + BreakingChangeType['REQUIRED_ARG_ADDED'] = 'REQUIRED_ARG_ADDED'; + BreakingChangeType['ARG_REMOVED'] = 'ARG_REMOVED'; + BreakingChangeType['ARG_CHANGED_KIND'] = 'ARG_CHANGED_KIND'; + BreakingChangeType['DIRECTIVE_REMOVED'] = 'DIRECTIVE_REMOVED'; + BreakingChangeType['DIRECTIVE_ARG_REMOVED'] = 'DIRECTIVE_ARG_REMOVED'; + BreakingChangeType['REQUIRED_DIRECTIVE_ARG_ADDED'] = + 'REQUIRED_DIRECTIVE_ARG_ADDED'; + BreakingChangeType['DIRECTIVE_REPEATABLE_REMOVED'] = + 'DIRECTIVE_REPEATABLE_REMOVED'; + BreakingChangeType['DIRECTIVE_LOCATION_REMOVED'] = + 'DIRECTIVE_LOCATION_REMOVED'; +})( + BreakingChangeType || (exports.BreakingChangeType = BreakingChangeType = {}), +); + +var DangerousChangeType; +exports.DangerousChangeType = DangerousChangeType; + +(function (DangerousChangeType) { + DangerousChangeType['VALUE_ADDED_TO_ENUM'] = 'VALUE_ADDED_TO_ENUM'; + DangerousChangeType['TYPE_ADDED_TO_UNION'] = 'TYPE_ADDED_TO_UNION'; + DangerousChangeType['OPTIONAL_INPUT_FIELD_ADDED'] = + 'OPTIONAL_INPUT_FIELD_ADDED'; + DangerousChangeType['OPTIONAL_ARG_ADDED'] = 'OPTIONAL_ARG_ADDED'; + DangerousChangeType['IMPLEMENTED_INTERFACE_ADDED'] = + 'IMPLEMENTED_INTERFACE_ADDED'; + DangerousChangeType['ARG_DEFAULT_VALUE_CHANGE'] = 'ARG_DEFAULT_VALUE_CHANGE'; +})( + DangerousChangeType || + (exports.DangerousChangeType = DangerousChangeType = {}), +); + +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. + */ +function findBreakingChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in BreakingChangeType, + ); +} +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + */ + +function findDangerousChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in DangerousChangeType, + ); +} + +function findSchemaChanges(oldSchema, newSchema) { + return [ + ...findTypeChanges(oldSchema, newSchema), + ...findDirectiveChanges(oldSchema, newSchema), + ]; +} + +function findDirectiveChanges(oldSchema, newSchema) { + const schemaChanges = []; + const directivesDiff = diff( + oldSchema.getDirectives(), + newSchema.getDirectives(), + ); + + for (const oldDirective of directivesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REMOVED, + description: `${oldDirective.name} was removed.`, + }); + } + + for (const [oldDirective, newDirective] of directivesDiff.persisted) { + const argsDiff = diff(oldDirective.args, newDirective.args); + + for (const newArg of argsDiff.added) { + if ((0, _definition.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, + description: `A required arg ${newArg.name} on directive ${oldDirective.name} was added.`, + }); + } + } + + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, + description: `${oldArg.name} was removed from ${oldDirective.name}.`, + }); + } + + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, + description: `Repeatable flag was removed from ${oldDirective.name}.`, + }); + } + + for (const location of oldDirective.locations) { + if (!newDirective.locations.includes(location)) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, + description: `${location} was removed from ${oldDirective.name}.`, + }); + } + } + } + + return schemaChanges; +} + +function findTypeChanges(oldSchema, newSchema) { + const schemaChanges = []; + const typesDiff = diff( + Object.values(oldSchema.getTypeMap()), + Object.values(newSchema.getTypeMap()), + ); + + for (const oldType of typesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED, + description: (0, _scalars.isSpecifiedScalarType)(oldType) + ? `Standard scalar ${oldType.name} was removed because it is not referenced anymore.` + : `${oldType.name} was removed.`, + }); + } + + for (const [oldType, newType] of typesDiff.persisted) { + if ( + (0, _definition.isEnumType)(oldType) && + (0, _definition.isEnumType)(newType) + ) { + schemaChanges.push(...findEnumTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isUnionType)(oldType) && + (0, _definition.isUnionType)(newType) + ) { + schemaChanges.push(...findUnionTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isInputObjectType)(oldType) && + (0, _definition.isInputObjectType)(newType) + ) { + schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isObjectType)(oldType) && + (0, _definition.isObjectType)(newType) + ) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), + ); + } else if ( + (0, _definition.isInterfaceType)(oldType) && + (0, _definition.isInterfaceType)(newType) + ) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), + ); + } else if (oldType.constructor !== newType.constructor) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_CHANGED_KIND, + description: + `${oldType.name} changed from ` + + `${typeKindName(oldType)} to ${typeKindName(newType)}.`, + }); + } + } + + return schemaChanges; +} + +function findInputObjectTypeChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); + + for (const newField of fieldsDiff.added) { + if ((0, _definition.isRequiredInputField)(newField)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, + description: `A required field ${newField.name} on input type ${oldType.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, + description: `An optional field ${newField.name} on input type ${oldType.name} was added.`, + }); + } + } + + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } + + for (const [oldField, newField] of fieldsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldField.type, + newField.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + } + + return schemaChanges; +} + +function findUnionTypeChanges(oldType, newType) { + const schemaChanges = []; + const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); + + for (const newPossibleType of possibleTypesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.TYPE_ADDED_TO_UNION, + description: `${newPossibleType.name} was added to union type ${oldType.name}.`, + }); + } + + for (const oldPossibleType of possibleTypesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, + description: `${oldPossibleType.name} was removed from union type ${oldType.name}.`, + }); + } + + return schemaChanges; +} + +function findEnumTypeChanges(oldType, newType) { + const schemaChanges = []; + const valuesDiff = diff(oldType.getValues(), newType.getValues()); + + for (const newValue of valuesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.VALUE_ADDED_TO_ENUM, + description: `${newValue.name} was added to enum type ${oldType.name}.`, + }); + } + + for (const oldValue of valuesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, + description: `${oldValue.name} was removed from enum type ${oldType.name}.`, + }); + } + + return schemaChanges; +} + +function findImplementedInterfacesChanges(oldType, newType) { + const schemaChanges = []; + const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); + + for (const newInterface of interfacesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, + description: `${newInterface.name} added to interfaces implemented by ${oldType.name}.`, + }); + } + + for (const oldInterface of interfacesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, + description: `${oldType.name} no longer implements interface ${oldInterface.name}.`, + }); + } + + return schemaChanges; +} + +function findFieldChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); + + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } + + for (const [oldField, newField] of fieldsDiff.persisted) { + schemaChanges.push(...findArgChanges(oldType, oldField, newField)); + const isSafe = isChangeSafeForObjectOrInterfaceField( + oldField.type, + newField.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + } + + return schemaChanges; +} + +function findArgChanges(oldType, oldField, newField) { + const schemaChanges = []; + const argsDiff = diff(oldField.args, newField.args); + + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.ARG_REMOVED, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`, + }); + } + + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldArg.type, + newArg.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.ARG_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } else if (oldArg.defaultValue !== undefined) { + if (newArg.defaultValue === undefined) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, + }); + } else { + // Since we looking only for client's observable changes we should + // compare default values in the same representation as they are + // represented inside introspection. + const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type); + const newValueStr = stringifyValue(newArg.defaultValue, newArg.type); + + if (oldValueStr !== newValueStr) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`, + }); + } + } + } + } + + for (const newArg of argsDiff.added) { + if ((0, _definition.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_ARG_ADDED, + description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_ARG_ADDED, + description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } + } + + return schemaChanges; +} + +function isChangeSafeForObjectOrInterfaceField(oldType, newType) { + if ((0, _definition.isListType)(oldType)) { + return ( + // if they're both lists, make sure the underlying types are compatible + ((0, _definition.isListType)(newType) && + isChangeSafeForObjectOrInterfaceField( + oldType.ofType, + newType.ofType, + )) || // moving from nullable to non-null of the same underlying type is safe + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); + } + + if ((0, _definition.isNonNullType)(oldType)) { + // if they're both non-null, make sure the underlying types are compatible + return ( + (0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) + ); + } + + return ( + // if they're both named types, see if their names are equivalent + ((0, _definition.isNamedType)(newType) && oldType.name === newType.name) || // moving from nullable to non-null of the same underlying type is safe + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); +} + +function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { + if ((0, _definition.isListType)(oldType)) { + // if they're both lists, make sure the underlying types are compatible + return ( + (0, _definition.isListType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) + ); + } + + if ((0, _definition.isNonNullType)(oldType)) { + return ( + // if they're both non-null, make sure the underlying types are + // compatible + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg( + oldType.ofType, + newType.ofType, + )) || // moving from non-null to nullable of the same underlying type is safe + (!(0, _definition.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)) + ); + } // if they're both named types, see if their names are equivalent + + return (0, _definition.isNamedType)(newType) && oldType.name === newType.name; +} + +function typeKindName(type) { + if ((0, _definition.isScalarType)(type)) { + return 'a Scalar type'; + } + + if ((0, _definition.isObjectType)(type)) { + return 'an Object type'; + } + + if ((0, _definition.isInterfaceType)(type)) { + return 'an Interface type'; + } + + if ((0, _definition.isUnionType)(type)) { + return 'a Union type'; + } + + if ((0, _definition.isEnumType)(type)) { + return 'an Enum type'; + } + + if ((0, _definition.isInputObjectType)(type)) { + return 'an Input type'; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} + +function stringifyValue(value, type) { + const ast = (0, _astFromValue.astFromValue)(value, type); + ast != null || (0, _invariant.invariant)(false); + return (0, _printer.print)((0, _sortValueNode.sortValueNode)(ast)); +} + +function diff(oldArray, newArray) { + const added = []; + const removed = []; + const persisted = []; + const oldMap = (0, _keyMap.keyMap)(oldArray, ({ name }) => name); + const newMap = (0, _keyMap.keyMap)(newArray, ({ name }) => name); + + for (const oldItem of oldArray) { + const newItem = newMap[oldItem.name]; + + if (newItem === undefined) { + removed.push(oldItem); + } else { + persisted.push([oldItem, newItem]); + } + } + + for (const newItem of newArray) { + if (oldMap[newItem.name] === undefined) { + added.push(newItem); + } + } + + return { + added, + persisted, + removed, + }; +} + + +/***/ }), + +/***/ 51631: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getIntrospectionQuery = getIntrospectionQuery; + +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +function getIntrospectionQuery(options) { + const optionsWithDefault = { + descriptions: true, + specifiedByUrl: false, + directiveIsRepeatable: false, + schemaDescription: false, + inputValueDeprecation: false, + ...options, + }; + const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; + const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable + ? 'isRepeatable' + : ''; + const schemaDescription = optionsWithDefault.schemaDescription + ? descriptions + : ''; + + function inputDeprecation(str) { + return optionsWithDefault.inputValueDeprecation ? str : ''; + } + + return ` + query IntrospectionQuery { + __schema { + ${schemaDescription} + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + ${descriptions} + ${directiveIsRepeatable} + locations + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + } + } + } + + fragment FullType on __Type { + kind + name + ${descriptions} + ${specifiedByUrl} + fields(includeDeprecated: true) { + name + ${descriptions} + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + ${descriptions} + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + + fragment InputValue on __InputValue { + name + ${descriptions} + type { ...TypeRef } + defaultValue + ${inputDeprecation('isDeprecated')} + ${inputDeprecation('deprecationReason')} + } + + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + `; +} + + +/***/ }), + +/***/ 45242: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getOperationAST = getOperationAST; + +var _kinds = __nccwpck_require__(19542); + +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ +function getOperationAST(documentAST, operationName) { + let operation = null; + + for (const definition of documentAST.definitions) { + if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) { + var _definition$name; + + if (operationName == null) { + // If no operation name was provided, only return an Operation if there + // is one defined in the document. Upon encountering the second, return + // null. + if (operation) { + return null; + } + + operation = definition; + } else if ( + ((_definition$name = definition.name) === null || + _definition$name === void 0 + ? void 0 + : _definition$name.value) === operationName + ) { + return definition; + } + } + } + + return operation; +} + + +/***/ }), + +/***/ 59293: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getOperationRootType = getOperationRootType; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Extracts the root type of the operation from the schema. + * + * @deprecated Please use `GraphQLSchema.getRootType` instead. Will be removed in v17 + */ +function getOperationRootType(schema, operation) { + if (operation.operation === 'query') { + const queryType = schema.getQueryType(); + + if (!queryType) { + throw new _GraphQLError.GraphQLError( + 'Schema does not define the required query root type.', + { + nodes: operation, + }, + ); + } + + return queryType; + } + + if (operation.operation === 'mutation') { + const mutationType = schema.getMutationType(); + + if (!mutationType) { + throw new _GraphQLError.GraphQLError( + 'Schema is not configured for mutations.', + { + nodes: operation, + }, + ); + } + + return mutationType; + } + + if (operation.operation === 'subscription') { + const subscriptionType = schema.getSubscriptionType(); + + if (!subscriptionType) { + throw new _GraphQLError.GraphQLError( + 'Schema is not configured for subscriptions.', + { + nodes: operation, + }, + ); + } + + return subscriptionType; + } + + throw new _GraphQLError.GraphQLError( + 'Can only have query, mutation and subscription operations.', + { + nodes: operation, + }, + ); +} + + +/***/ }), + +/***/ 39167: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "BreakingChangeType", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.BreakingChangeType; + }, +})); +Object.defineProperty(exports, "DangerousChangeType", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.DangerousChangeType; + }, +})); +Object.defineProperty(exports, "TypeInfo", ({ + enumerable: true, + get: function () { + return _TypeInfo.TypeInfo; + }, +})); +Object.defineProperty(exports, "assertValidName", ({ + enumerable: true, + get: function () { + return _assertValidName.assertValidName; + }, +})); +Object.defineProperty(exports, "astFromValue", ({ + enumerable: true, + get: function () { + return _astFromValue.astFromValue; + }, +})); +Object.defineProperty(exports, "buildASTSchema", ({ + enumerable: true, + get: function () { + return _buildASTSchema.buildASTSchema; + }, +})); +Object.defineProperty(exports, "buildClientSchema", ({ + enumerable: true, + get: function () { + return _buildClientSchema.buildClientSchema; + }, +})); +Object.defineProperty(exports, "buildSchema", ({ + enumerable: true, + get: function () { + return _buildASTSchema.buildSchema; + }, +})); +Object.defineProperty(exports, "coerceInputValue", ({ + enumerable: true, + get: function () { + return _coerceInputValue.coerceInputValue; + }, +})); +Object.defineProperty(exports, "concatAST", ({ + enumerable: true, + get: function () { + return _concatAST.concatAST; + }, +})); +Object.defineProperty(exports, "doTypesOverlap", ({ + enumerable: true, + get: function () { + return _typeComparators.doTypesOverlap; + }, +})); +Object.defineProperty(exports, "extendSchema", ({ + enumerable: true, + get: function () { + return _extendSchema.extendSchema; + }, +})); +Object.defineProperty(exports, "findBreakingChanges", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.findBreakingChanges; + }, +})); +Object.defineProperty(exports, "findDangerousChanges", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.findDangerousChanges; + }, +})); +Object.defineProperty(exports, "getIntrospectionQuery", ({ + enumerable: true, + get: function () { + return _getIntrospectionQuery.getIntrospectionQuery; + }, +})); +Object.defineProperty(exports, "getOperationAST", ({ + enumerable: true, + get: function () { + return _getOperationAST.getOperationAST; + }, +})); +Object.defineProperty(exports, "getOperationRootType", ({ + enumerable: true, + get: function () { + return _getOperationRootType.getOperationRootType; + }, +})); +Object.defineProperty(exports, "introspectionFromSchema", ({ + enumerable: true, + get: function () { + return _introspectionFromSchema.introspectionFromSchema; + }, +})); +Object.defineProperty(exports, "isEqualType", ({ + enumerable: true, + get: function () { + return _typeComparators.isEqualType; + }, +})); +Object.defineProperty(exports, "isTypeSubTypeOf", ({ + enumerable: true, + get: function () { + return _typeComparators.isTypeSubTypeOf; + }, +})); +Object.defineProperty(exports, "isValidNameError", ({ + enumerable: true, + get: function () { + return _assertValidName.isValidNameError; + }, +})); +Object.defineProperty(exports, "lexicographicSortSchema", ({ + enumerable: true, + get: function () { + return _lexicographicSortSchema.lexicographicSortSchema; + }, +})); +Object.defineProperty(exports, "printIntrospectionSchema", ({ + enumerable: true, + get: function () { + return _printSchema.printIntrospectionSchema; + }, +})); +Object.defineProperty(exports, "printSchema", ({ + enumerable: true, + get: function () { + return _printSchema.printSchema; + }, +})); +Object.defineProperty(exports, "printType", ({ + enumerable: true, + get: function () { + return _printSchema.printType; + }, +})); +Object.defineProperty(exports, "separateOperations", ({ + enumerable: true, + get: function () { + return _separateOperations.separateOperations; + }, +})); +Object.defineProperty(exports, "stripIgnoredCharacters", ({ + enumerable: true, + get: function () { + return _stripIgnoredCharacters.stripIgnoredCharacters; + }, +})); +Object.defineProperty(exports, "typeFromAST", ({ + enumerable: true, + get: function () { + return _typeFromAST.typeFromAST; + }, +})); +Object.defineProperty(exports, "valueFromAST", ({ + enumerable: true, + get: function () { + return _valueFromAST.valueFromAST; + }, +})); +Object.defineProperty(exports, "valueFromASTUntyped", ({ + enumerable: true, + get: function () { + return _valueFromASTUntyped.valueFromASTUntyped; + }, +})); +Object.defineProperty(exports, "visitWithTypeInfo", ({ + enumerable: true, + get: function () { + return _TypeInfo.visitWithTypeInfo; + }, +})); + +var _getIntrospectionQuery = __nccwpck_require__(51631); + +var _getOperationAST = __nccwpck_require__(45242); + +var _getOperationRootType = __nccwpck_require__(59293); + +var _introspectionFromSchema = __nccwpck_require__(84323); + +var _buildClientSchema = __nccwpck_require__(10404); + +var _buildASTSchema = __nccwpck_require__(36570); + +var _extendSchema = __nccwpck_require__(43476); + +var _lexicographicSortSchema = __nccwpck_require__(5486); + +var _printSchema = __nccwpck_require__(47178); + +var _typeFromAST = __nccwpck_require__(73461); + +var _valueFromAST = __nccwpck_require__(81172); + +var _valueFromASTUntyped = __nccwpck_require__(64539); + +var _astFromValue = __nccwpck_require__(68906); + +var _TypeInfo = __nccwpck_require__(95756); + +var _coerceInputValue = __nccwpck_require__(71623); + +var _concatAST = __nccwpck_require__(50066); + +var _separateOperations = __nccwpck_require__(55593); + +var _stripIgnoredCharacters = __nccwpck_require__(12828); + +var _typeComparators = __nccwpck_require__(60700); + +var _assertValidName = __nccwpck_require__(74411); + +var _findBreakingChanges = __nccwpck_require__(85927); + + +/***/ }), + +/***/ 84323: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.introspectionFromSchema = introspectionFromSchema; + +var _invariant = __nccwpck_require__(52810); + +var _parser = __nccwpck_require__(39927); + +var _execute = __nccwpck_require__(11184); + +var _getIntrospectionQuery = __nccwpck_require__(51631); + +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ +function introspectionFromSchema(schema, options) { + const optionsWithDefaults = { + specifiedByUrl: true, + directiveIsRepeatable: true, + schemaDescription: true, + inputValueDeprecation: true, + ...options, + }; + const document = (0, _parser.parse)( + (0, _getIntrospectionQuery.getIntrospectionQuery)(optionsWithDefaults), + ); + const result = (0, _execute.executeSync)({ + schema, + document, + }); + (!result.errors && result.data) || (0, _invariant.invariant)(false); + return result.data; +} + + +/***/ }), + +/***/ 5486: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.lexicographicSortSchema = lexicographicSortSchema; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _keyValMap = __nccwpck_require__(69662); + +var _naturalCompare = __nccwpck_require__(29329); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +var _schema = __nccwpck_require__(80613); + +/** + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. + */ +function lexicographicSortSchema(schema) { + const schemaConfig = schema.toConfig(); + const typeMap = (0, _keyValMap.keyValMap)( + sortByName(schemaConfig.types), + (type) => type.name, + sortNamedType, + ); + return new _schema.GraphQLSchema({ + ...schemaConfig, + types: Object.values(typeMap), + directives: sortByName(schemaConfig.directives).map(sortDirective), + query: replaceMaybeType(schemaConfig.query), + mutation: replaceMaybeType(schemaConfig.mutation), + subscription: replaceMaybeType(schemaConfig.subscription), + }); + + function replaceType(type) { + if ((0, _definition.isListType)(type)) { + // @ts-expect-error + return new _definition.GraphQLList(replaceType(type.ofType)); + } else if ((0, _definition.isNonNullType)(type)) { + // @ts-expect-error + return new _definition.GraphQLNonNull(replaceType(type.ofType)); + } // @ts-expect-error FIXME: TS Conversion + + return replaceNamedType(type); + } + + function replaceNamedType(type) { + return typeMap[type.name]; + } + + function replaceMaybeType(maybeType) { + return maybeType && replaceNamedType(maybeType); + } + + function sortDirective(directive) { + const config = directive.toConfig(); + return new _directives.GraphQLDirective({ + ...config, + locations: sortBy(config.locations, (x) => x), + args: sortArgs(config.args), + }); + } + + function sortArgs(args) { + return sortObjMap(args, (arg) => ({ ...arg, type: replaceType(arg.type) })); + } + + function sortFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + args: field.args && sortArgs(field.args), + })); + } + + function sortInputFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + })); + } + + function sortTypes(array) { + return sortByName(array).map(replaceNamedType); + } + + function sortNamedType(type) { + if ( + (0, _definition.isScalarType)(type) || + (0, _introspection.isIntrospectionType)(type) + ) { + return type; + } + + if ((0, _definition.isObjectType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLObjectType({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), + }); + } + + if ((0, _definition.isInterfaceType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLInterfaceType({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), + }); + } + + if ((0, _definition.isUnionType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLUnionType({ + ...config, + types: () => sortTypes(config.types), + }); + } + + if ((0, _definition.isEnumType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLEnumType({ + ...config, + values: sortObjMap(config.values, (value) => value), + }); + } + + if ((0, _definition.isInputObjectType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLInputObjectType({ + ...config, + fields: () => sortInputFields(config.fields), + }); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); + } +} + +function sortObjMap(map, sortValueFn) { + const sortedMap = Object.create(null); + + for (const key of Object.keys(map).sort(_naturalCompare.naturalCompare)) { + sortedMap[key] = sortValueFn(map[key]); + } + + return sortedMap; +} + +function sortByName(array) { + return sortBy(array, (obj) => obj.name); +} + +function sortBy(array, mapToKey) { + return array.slice().sort((obj1, obj2) => { + const key1 = mapToKey(obj1); + const key2 = mapToKey(obj2); + return (0, _naturalCompare.naturalCompare)(key1, key2); + }); +} + + +/***/ }), + +/***/ 47178: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printIntrospectionSchema = printIntrospectionSchema; +exports.printSchema = printSchema; +exports.printType = printType; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _blockString = __nccwpck_require__(79685); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +var _introspection = __nccwpck_require__(98029); + +var _scalars = __nccwpck_require__(14544); + +var _astFromValue = __nccwpck_require__(68906); + +function printSchema(schema) { + return printFilteredSchema( + schema, + (n) => !(0, _directives.isSpecifiedDirective)(n), + isDefinedType, + ); +} + +function printIntrospectionSchema(schema) { + return printFilteredSchema( + schema, + _directives.isSpecifiedDirective, + _introspection.isIntrospectionType, + ); +} + +function isDefinedType(type) { + return ( + !(0, _scalars.isSpecifiedScalarType)(type) && + !(0, _introspection.isIntrospectionType)(type) + ); +} + +function printFilteredSchema(schema, directiveFilter, typeFilter) { + const directives = schema.getDirectives().filter(directiveFilter); + const types = Object.values(schema.getTypeMap()).filter(typeFilter); + return [ + printSchemaDefinition(schema), + ...directives.map((directive) => printDirective(directive)), + ...types.map((type) => printType(type)), + ] + .filter(Boolean) + .join('\n\n'); +} + +function printSchemaDefinition(schema) { + if (schema.description == null && isSchemaOfCommonNames(schema)) { + return; + } + + const operationTypes = []; + const queryType = schema.getQueryType(); + + if (queryType) { + operationTypes.push(` query: ${queryType.name}`); + } + + const mutationType = schema.getMutationType(); + + if (mutationType) { + operationTypes.push(` mutation: ${mutationType.name}`); + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + operationTypes.push(` subscription: ${subscriptionType.name}`); + } + + return printDescription(schema) + `schema {\n${operationTypes.join('\n')}\n}`; +} +/** + * GraphQL schema define root types for each type of operation. These types are + * the same as any other type and can be named in any manner, however there is + * a common naming convention: + * + * ```graphql + * schema { + * query: Query + * mutation: Mutation + * subscription: Subscription + * } + * ``` + * + * When using this naming convention, the schema description can be omitted. + */ + +function isSchemaOfCommonNames(schema) { + const queryType = schema.getQueryType(); + + if (queryType && queryType.name !== 'Query') { + return false; + } + + const mutationType = schema.getMutationType(); + + if (mutationType && mutationType.name !== 'Mutation') { + return false; + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType && subscriptionType.name !== 'Subscription') { + return false; + } + + return true; +} + +function printType(type) { + if ((0, _definition.isScalarType)(type)) { + return printScalar(type); + } + + if ((0, _definition.isObjectType)(type)) { + return printObject(type); + } + + if ((0, _definition.isInterfaceType)(type)) { + return printInterface(type); + } + + if ((0, _definition.isUnionType)(type)) { + return printUnion(type); + } + + if ((0, _definition.isEnumType)(type)) { + return printEnum(type); + } + + if ((0, _definition.isInputObjectType)(type)) { + return printInputObject(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} + +function printScalar(type) { + return ( + printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) + ); +} + +function printImplementedInterfaces(type) { + const interfaces = type.getInterfaces(); + return interfaces.length + ? ' implements ' + interfaces.map((i) => i.name).join(' & ') + : ''; +} + +function printObject(type) { + return ( + printDescription(type) + + `type ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} + +function printInterface(type) { + return ( + printDescription(type) + + `interface ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} + +function printUnion(type) { + const types = type.getTypes(); + const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; + return printDescription(type) + 'union ' + type.name + possibleTypes; +} + +function printEnum(type) { + const values = type + .getValues() + .map( + (value, i) => + printDescription(value, ' ', !i) + + ' ' + + value.name + + printDeprecated(value.deprecationReason), + ); + return printDescription(type) + `enum ${type.name}` + printBlock(values); +} + +function printInputObject(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), + ); + return printDescription(type) + `input ${type.name}` + printBlock(fields); +} + +function printFields(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => + printDescription(f, ' ', !i) + + ' ' + + f.name + + printArgs(f.args, ' ') + + ': ' + + String(f.type) + + printDeprecated(f.deprecationReason), + ); + return printBlock(fields); +} + +function printBlock(items) { + return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; +} + +function printArgs(args, indentation = '') { + if (args.length === 0) { + return ''; + } // If every arg does not have a description, print them on one line. + + if (args.every((arg) => !arg.description)) { + return '(' + args.map(printInputValue).join(', ') + ')'; + } + + return ( + '(\n' + + args + .map( + (arg, i) => + printDescription(arg, ' ' + indentation, !i) + + ' ' + + indentation + + printInputValue(arg), + ) + .join('\n') + + '\n' + + indentation + + ')' + ); +} + +function printInputValue(arg) { + const defaultAST = (0, _astFromValue.astFromValue)( + arg.defaultValue, + arg.type, + ); + let argDecl = arg.name + ': ' + String(arg.type); + + if (defaultAST) { + argDecl += ` = ${(0, _printer.print)(defaultAST)}`; + } + + return argDecl + printDeprecated(arg.deprecationReason); +} + +function printDirective(directive) { + return ( + printDescription(directive) + + 'directive @' + + directive.name + + printArgs(directive.args) + + (directive.isRepeatable ? ' repeatable' : '') + + ' on ' + + directive.locations.join(' | ') + ); +} + +function printDeprecated(reason) { + if (reason == null) { + return ''; + } + + if (reason !== _directives.DEFAULT_DEPRECATION_REASON) { + const astValue = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: reason, + }); + return ` @deprecated(reason: ${astValue})`; + } + + return ' @deprecated'; +} + +function printSpecifiedByURL(scalar) { + if (scalar.specifiedByURL == null) { + return ''; + } + + const astValue = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: scalar.specifiedByURL, + }); + return ` @specifiedBy(url: ${astValue})`; +} + +function printDescription(def, indentation = '', firstInBlock = true) { + const { description } = def; + + if (description == null) { + return ''; + } + + const blockString = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: description, + block: (0, _blockString.isPrintableAsBlockString)(description), + }); + const prefix = + indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; +} + + +/***/ }), + +/***/ 55593: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.separateOperations = separateOperations; + +var _kinds = __nccwpck_require__(19542); + +var _visitor = __nccwpck_require__(45946); + +/** + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. + */ +function separateOperations(documentAST) { + const operations = []; + const depGraph = Object.create(null); // Populate metadata and build a dependency graph. + + for (const definitionNode of documentAST.definitions) { + switch (definitionNode.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + operations.push(definitionNode); + break; + + case _kinds.Kind.FRAGMENT_DEFINITION: + depGraph[definitionNode.name.value] = collectDependencies( + definitionNode.selectionSet, + ); + break; + + default: // ignore non-executable definitions + } + } // For each operation, produce a new synthesized AST which includes only what + // is necessary for completing that operation. + + const separatedDocumentASTs = Object.create(null); + + for (const operation of operations) { + const dependencies = new Set(); + + for (const fragmentName of collectDependencies(operation.selectionSet)) { + collectTransitiveDependencies(dependencies, depGraph, fragmentName); + } // Provides the empty string for anonymous operations. + + const operationName = operation.name ? operation.name.value : ''; // The list of definition nodes to be included for this operation, sorted + // to retain the same order as the original document. + + separatedDocumentASTs[operationName] = { + kind: _kinds.Kind.DOCUMENT, + definitions: documentAST.definitions.filter( + (node) => + node === operation || + (node.kind === _kinds.Kind.FRAGMENT_DEFINITION && + dependencies.has(node.name.value)), + ), + }; + } + + return separatedDocumentASTs; +} + +// From a dependency graph, collects a list of transitive dependencies by +// recursing through a dependency graph. +function collectTransitiveDependencies(collected, depGraph, fromName) { + if (!collected.has(fromName)) { + collected.add(fromName); + const immediateDeps = depGraph[fromName]; + + if (immediateDeps !== undefined) { + for (const toName of immediateDeps) { + collectTransitiveDependencies(collected, depGraph, toName); + } + } + } +} + +function collectDependencies(selectionSet) { + const dependencies = []; + (0, _visitor.visit)(selectionSet, { + FragmentSpread(node) { + dependencies.push(node.name.value); + }, + }); + return dependencies; +} + + +/***/ }), + +/***/ 21826: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.sortValueNode = sortValueNode; + +var _naturalCompare = __nccwpck_require__(29329); + +var _kinds = __nccwpck_require__(19542); + +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ +function sortValueNode(valueNode) { + switch (valueNode.kind) { + case _kinds.Kind.OBJECT: + return { ...valueNode, fields: sortFields(valueNode.fields) }; + + case _kinds.Kind.LIST: + return { ...valueNode, values: valueNode.values.map(sortValueNode) }; + + case _kinds.Kind.INT: + case _kinds.Kind.FLOAT: + case _kinds.Kind.STRING: + case _kinds.Kind.BOOLEAN: + case _kinds.Kind.NULL: + case _kinds.Kind.ENUM: + case _kinds.Kind.VARIABLE: + return valueNode; + } +} + +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => + (0, _naturalCompare.naturalCompare)(fieldA.name.value, fieldB.name.value), + ); +} + + +/***/ }), + +/***/ 12828: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.stripIgnoredCharacters = stripIgnoredCharacters; + +var _blockString = __nccwpck_require__(79685); + +var _lexer = __nccwpck_require__(21363); + +var _source = __nccwpck_require__(29915); + +var _tokenKind = __nccwpck_require__(43148); + +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ +function stripIgnoredCharacters(source) { + const sourceObj = (0, _source.isSource)(source) + ? source + : new _source.Source(source); + const body = sourceObj.body; + const lexer = new _lexer.Lexer(sourceObj); + let strippedBody = ''; + let wasLastAddedTokenNonPunctuator = false; + + while (lexer.advance().kind !== _tokenKind.TokenKind.EOF) { + const currentToken = lexer.token; + const tokenKind = currentToken.kind; + /** + * Every two non-punctuator tokens should have space between them. + * Also prevent case of non-punctuator token following by spread resulting + * in invalid token (e.g. `1...` is invalid Float token). + */ + + const isNonPunctuator = !(0, _lexer.isPunctuatorTokenKind)( + currentToken.kind, + ); + + if (wasLastAddedTokenNonPunctuator) { + if ( + isNonPunctuator || + currentToken.kind === _tokenKind.TokenKind.SPREAD + ) { + strippedBody += ' '; + } + } + + const tokenBody = body.slice(currentToken.start, currentToken.end); + + if (tokenKind === _tokenKind.TokenKind.BLOCK_STRING) { + strippedBody += (0, _blockString.printBlockString)(currentToken.value, { + minimize: true, + }); + } else { + strippedBody += tokenBody; + } + + wasLastAddedTokenNonPunctuator = isNonPunctuator; + } + + return strippedBody; +} + + +/***/ }), + +/***/ 60700: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.doTypesOverlap = doTypesOverlap; +exports.isEqualType = isEqualType; +exports.isTypeSubTypeOf = isTypeSubTypeOf; + +var _definition = __nccwpck_require__(49492); + +/** + * Provided two types, return true if the types are equal (invariant). + */ +function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } // If either type is non-null, the other must also be non-null. + + if ( + (0, _definition.isNonNullType)(typeA) && + (0, _definition.isNonNullType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // If either type is a list, the other must also be a list. + + if ( + (0, _definition.isListType)(typeA) && + (0, _definition.isListType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // Otherwise the types are not equal. + + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ + +function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } // If superType is non-null, maybeSubType must also be non-null. + + if ((0, _definition.isNonNullType)(superType)) { + if ((0, _definition.isNonNullType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0, _definition.isNonNullType)(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } // If superType type is a list, maybeSubType type must also be a list. + + if ((0, _definition.isListType)(superType)) { + if ((0, _definition.isListType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0, _definition.isListType)(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. + + return ( + (0, _definition.isAbstractType)(superType) && + ((0, _definition.isInterfaceType)(maybeSubType) || + (0, _definition.isObjectType)(maybeSubType)) && + schema.isSubType(superType, maybeSubType) + ); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ + +function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } + + if ((0, _definition.isAbstractType)(typeA)) { + if ((0, _definition.isAbstractType)(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } // Determine if the latter type is a possible concrete type of the former. + + return schema.isSubType(typeA, typeB); + } + + if ((0, _definition.isAbstractType)(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } // Otherwise the types do not overlap. + + return false; +} + + +/***/ }), + +/***/ 73461: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.typeFromAST = typeFromAST; + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case _kinds.Kind.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLList(innerType); + } + + case _kinds.Kind.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLNonNull(innerType); + } + + case _kinds.Kind.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } +} + + +/***/ }), + +/***/ 81172: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.valueFromAST = valueFromAST; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _keyMap = __nccwpck_require__(35053); + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + */ +function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } + + if (valueNode.kind === _kinds.Kind.VARIABLE) { + const variableName = valueNode.name.value; + + if (variables == null || variables[variableName] === undefined) { + // No valid return value. + return; + } + + const variableValue = variables[variableName]; + + if (variableValue === null && (0, _definition.isNonNullType)(type)) { + return; // Invalid: intentionally return no value. + } // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. + + return variableValue; + } + + if ((0, _definition.isNonNullType)(type)) { + if (valueNode.kind === _kinds.Kind.NULL) { + return; // Invalid: intentionally return no value. + } + + return valueFromAST(valueNode, type.ofType, variables); + } + + if (valueNode.kind === _kinds.Kind.NULL) { + // This is explicitly returning the value null. + return null; + } + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if (valueNode.kind === _kinds.Kind.LIST) { + const coercedValues = []; + + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if ((0, _definition.isNonNullType)(itemType)) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(null); + } else { + const itemValue = valueFromAST(itemNode, itemType, variables); + + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(itemValue); + } + } + + return coercedValues; + } + + const coercedValue = valueFromAST(valueNode, itemType, variables); + + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. + } + + return [coercedValue]; + } + + if ((0, _definition.isInputObjectType)(type)) { + if (valueNode.kind !== _kinds.Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + + const coercedObj = Object.create(null); + const fieldNodes = (0, _keyMap.keyMap)( + valueNode.fields, + (field) => field.name.value, + ); + + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes[field.name]; + + if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + return; // Invalid: intentionally return no value. + } + + continue; + } + + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedObj[field.name] = fieldValue; + } + + return coercedObj; + } + + if ((0, _definition.isLeafType)(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + + try { + result = type.parseLiteral(valueNode, variables); + } catch (_error) { + return; // Invalid: intentionally return no value. + } + + if (result === undefined) { + return; // Invalid: intentionally return no value. + } + + return result; + } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} // Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. + +function isMissingVariable(valueNode, variables) { + return ( + valueNode.kind === _kinds.Kind.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined) + ); +} + + +/***/ }), + +/***/ 64539: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.valueFromASTUntyped = valueFromASTUntyped; + +var _keyValMap = __nccwpck_require__(69662); + +var _kinds = __nccwpck_require__(19542); + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value + * will reflect the provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case _kinds.Kind.NULL: + return null; + + case _kinds.Kind.INT: + return parseInt(valueNode.value, 10); + + case _kinds.Kind.FLOAT: + return parseFloat(valueNode.value); + + case _kinds.Kind.STRING: + case _kinds.Kind.ENUM: + case _kinds.Kind.BOOLEAN: + return valueNode.value; + + case _kinds.Kind.LIST: + return valueNode.values.map((node) => + valueFromASTUntyped(node, variables), + ); + + case _kinds.Kind.OBJECT: + return (0, _keyValMap.keyValMap)( + valueNode.fields, + (field) => field.name.value, + (field) => valueFromASTUntyped(field.value, variables), + ); + + case _kinds.Kind.VARIABLE: + return variables === null || variables === void 0 + ? void 0 + : variables[valueNode.name.value]; + } +} + + +/***/ }), + +/***/ 26243: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ValidationContext = + exports.SDLValidationContext = + exports.ASTValidationContext = + void 0; + +var _kinds = __nccwpck_require__(19542); + +var _visitor = __nccwpck_require__(45946); + +var _TypeInfo = __nccwpck_require__(95756); + +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + + reportError(error) { + this._onError(error); + } + + getDocument() { + return this._ast; + } + + getFragment(name) { + let fragments; + + if (this._fragments) { + fragments = this._fragments; + } else { + fragments = Object.create(null); + + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } + + this._fragments = fragments; + } + + return fragments[name]; + } + + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); + + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; + + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) { + spreads.push(selection); + } else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } + + this._fragmentSpreads.set(node, spreads); + } + + return spreads; + } + + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); + + if (!fragments) { + fragments = []; + const collectedNames = Object.create(null); + const nodesToVisit = [operation.selectionSet]; + let node; + + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; + + if (collectedNames[fragName] !== true) { + collectedNames[fragName] = true; + const fragment = this.getFragment(fragName); + + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } + + this._recursivelyReferencedFragments.set(operation, fragments); + } + + return fragments; + } +} + +exports.ASTValidationContext = ASTValidationContext; + +class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; + } + + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } + + getSchema() { + return this._schema; + } +} + +exports.SDLValidationContext = SDLValidationContext; + +class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); + } + + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } + + getSchema() { + return this._schema; + } + + getVariableUsages(node) { + let usages = this._variableUsages.get(node); + + if (!usages) { + const newUsages = []; + const typeInfo = new _TypeInfo.TypeInfo(this._schema); + (0, _visitor.visit)( + node, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, { + VariableDefinition: () => false, + + Variable(variable) { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + defaultValue: typeInfo.getDefaultValue(), + }); + }, + }), + ); + usages = newUsages; + + this._variableUsages.set(node, usages); + } + + return usages; + } + + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); + + if (!usages) { + usages = this.getVariableUsages(operation); + + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } + + this._recursiveVariableUsages.set(operation, usages); + } + + return usages; + } + + getType() { + return this._typeInfo.getType(); + } + + getParentType() { + return this._typeInfo.getParentType(); + } + + getInputType() { + return this._typeInfo.getInputType(); + } + + getParentInputType() { + return this._typeInfo.getParentInputType(); + } + + getFieldDef() { + return this._typeInfo.getFieldDef(); + } + + getDirective() { + return this._typeInfo.getDirective(); + } + + getArgument() { + return this._typeInfo.getArgument(); + } + + getEnumValue() { + return this._typeInfo.getEnumValue(); + } +} + +exports.ValidationContext = ValidationContext; + + +/***/ }), + +/***/ 68660: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ + enumerable: true, + get: function () { + return _ExecutableDefinitionsRule.ExecutableDefinitionsRule; + }, +})); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", ({ + enumerable: true, + get: function () { + return _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule; + }, +})); +Object.defineProperty(exports, "KnownArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownArgumentNamesRule.KnownArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownDirectivesRule", ({ + enumerable: true, + get: function () { + return _KnownDirectivesRule.KnownDirectivesRule; + }, +})); +Object.defineProperty(exports, "KnownFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownFragmentNamesRule.KnownFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownTypeNamesRule", ({ + enumerable: true, + get: function () { + return _KnownTypeNamesRule.KnownTypeNamesRule; + }, +})); +Object.defineProperty(exports, "LoneAnonymousOperationRule", ({ + enumerable: true, + get: function () { + return _LoneAnonymousOperationRule.LoneAnonymousOperationRule; + }, +})); +Object.defineProperty(exports, "LoneSchemaDefinitionRule", ({ + enumerable: true, + get: function () { + return _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule; + }, +})); +Object.defineProperty(exports, "NoDeprecatedCustomRule", ({ + enumerable: true, + get: function () { + return _NoDeprecatedCustomRule.NoDeprecatedCustomRule; + }, +})); +Object.defineProperty(exports, "NoFragmentCyclesRule", ({ + enumerable: true, + get: function () { + return _NoFragmentCyclesRule.NoFragmentCyclesRule; + }, +})); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", ({ + enumerable: true, + get: function () { + return _NoSchemaIntrospectionCustomRule.NoSchemaIntrospectionCustomRule; + }, +})); +Object.defineProperty(exports, "NoUndefinedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUndefinedVariablesRule.NoUndefinedVariablesRule; + }, +})); +Object.defineProperty(exports, "NoUnusedFragmentsRule", ({ + enumerable: true, + get: function () { + return _NoUnusedFragmentsRule.NoUnusedFragmentsRule; + }, +})); +Object.defineProperty(exports, "NoUnusedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUnusedVariablesRule.NoUnusedVariablesRule; + }, +})); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", ({ + enumerable: true, + get: function () { + return _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule; + }, +})); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", ({ + enumerable: true, + get: function () { + return _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule; + }, +})); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", ({ + enumerable: true, + get: function () { + return _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule; + }, +})); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", ({ + enumerable: true, + get: function () { + return _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule; + }, +})); +Object.defineProperty(exports, "ScalarLeafsRule", ({ + enumerable: true, + get: function () { + return _ScalarLeafsRule.ScalarLeafsRule; + }, +})); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ + enumerable: true, + get: function () { + return _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentNamesRule.UniqueArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule; + }, +})); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFragmentNamesRule.UniqueFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationNamesRule.UniqueOperationNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationTypesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationTypesRule.UniqueOperationTypesRule; + }, +})); +Object.defineProperty(exports, "UniqueTypeNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueTypeNamesRule.UniqueTypeNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueVariableNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueVariableNamesRule.UniqueVariableNamesRule; + }, +})); +Object.defineProperty(exports, "ValidationContext", ({ + enumerable: true, + get: function () { + return _ValidationContext.ValidationContext; + }, +})); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "VariablesAreInputTypesRule", ({ + enumerable: true, + get: function () { + return _VariablesAreInputTypesRule.VariablesAreInputTypesRule; + }, +})); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", ({ + enumerable: true, + get: function () { + return _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule; + }, +})); +Object.defineProperty(exports, "specifiedRules", ({ + enumerable: true, + get: function () { + return _specifiedRules.specifiedRules; + }, +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.validate; + }, +})); + +var _validate = __nccwpck_require__(17329); + +var _ValidationContext = __nccwpck_require__(26243); + +var _specifiedRules = __nccwpck_require__(41014); + +var _ExecutableDefinitionsRule = __nccwpck_require__(68226); + +var _FieldsOnCorrectTypeRule = __nccwpck_require__(7665); + +var _FragmentsOnCompositeTypesRule = __nccwpck_require__(84245); + +var _KnownArgumentNamesRule = __nccwpck_require__(32454); + +var _KnownDirectivesRule = __nccwpck_require__(69207); + +var _KnownFragmentNamesRule = __nccwpck_require__(14838); + +var _KnownTypeNamesRule = __nccwpck_require__(83742); + +var _LoneAnonymousOperationRule = __nccwpck_require__(1624); + +var _NoFragmentCyclesRule = __nccwpck_require__(20514); + +var _NoUndefinedVariablesRule = __nccwpck_require__(28997); + +var _NoUnusedFragmentsRule = __nccwpck_require__(34627); + +var _NoUnusedVariablesRule = __nccwpck_require__(84580); + +var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(90629); + +var _PossibleFragmentSpreadsRule = __nccwpck_require__(73535); + +var _ProvidedRequiredArgumentsRule = __nccwpck_require__(94225); + +var _ScalarLeafsRule = __nccwpck_require__(99500); + +var _SingleFieldSubscriptionsRule = __nccwpck_require__(69843); + +var _UniqueArgumentNamesRule = __nccwpck_require__(6374); + +var _UniqueDirectivesPerLocationRule = __nccwpck_require__(74106); + +var _UniqueFragmentNamesRule = __nccwpck_require__(41); + +var _UniqueInputFieldNamesRule = __nccwpck_require__(12057); + +var _UniqueOperationNamesRule = __nccwpck_require__(32188); + +var _UniqueVariableNamesRule = __nccwpck_require__(1785); + +var _ValuesOfCorrectTypeRule = __nccwpck_require__(61399); + +var _VariablesAreInputTypesRule = __nccwpck_require__(53249); + +var _VariablesInAllowedPositionRule = __nccwpck_require__(19710); + +var _LoneSchemaDefinitionRule = __nccwpck_require__(87451); + +var _UniqueOperationTypesRule = __nccwpck_require__(52111); + +var _UniqueTypeNamesRule = __nccwpck_require__(77154); + +var _UniqueEnumValueNamesRule = __nccwpck_require__(28113); + +var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(44282); + +var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(26641); + +var _UniqueDirectiveNamesRule = __nccwpck_require__(23338); + +var _PossibleTypeExtensionsRule = __nccwpck_require__(58261); + +var _NoDeprecatedCustomRule = __nccwpck_require__(10088); + +var _NoSchemaIntrospectionCustomRule = __nccwpck_require__(77374); + + +/***/ }), + +/***/ 68226: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ExecutableDefinitionsRule = ExecutableDefinitionsRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _predicates = __nccwpck_require__(2493); + +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!(0, _predicates.isExecutableDefinitionNode)(definition)) { + const defName = + definition.kind === _kinds.Kind.SCHEMA_DEFINITION || + definition.kind === _kinds.Kind.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError( + new _GraphQLError.GraphQLError( + `The ${defName} definition is not executable.`, + { + nodes: definition, + }, + ), + ); + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 7665: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.FieldsOnCorrectTypeRule = FieldsOnCorrectTypeRule; + +var _didYouMean = __nccwpck_require__(94476); + +var _naturalCompare = __nccwpck_require__(29329); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); + + if (type) { + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; // First determine if there are any suggested types to condition on. + + let suggestion = (0, _didYouMean.didYouMean)( + 'to use an inline fragment on', + getSuggestedTypeNames(schema, type, fieldName), + ); // If there are no suggested types, then perhaps this was a typo? + + if (suggestion === '') { + suggestion = (0, _didYouMean.didYouMean)( + getSuggestedFieldNames(type, fieldName), + ); + } // Report an error, including helpful suggestions. + + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot query field "${fieldName}" on type "${type.name}".` + + suggestion, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} +/** + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. + */ + +function getSuggestedTypeNames(schema, type, fieldName) { + if (!(0, _definition.isAbstractType)(type)) { + // Must be an Object type, which does not have possible fields. + return []; + } + + const suggestedTypes = new Set(); + const usageCount = Object.create(null); + + for (const possibleType of schema.getPossibleTypes(type)) { + if (!possibleType.getFields()[fieldName]) { + continue; + } // This object type defines this field. + + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; + + for (const possibleInterface of possibleType.getInterfaces()) { + var _usageCount$possibleI; + + if (!possibleInterface.getFields()[fieldName]) { + continue; + } // This interface type defines this field. + + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + ((_usageCount$possibleI = usageCount[possibleInterface.name]) !== + null && _usageCount$possibleI !== void 0 + ? _usageCount$possibleI + : 0) + 1; + } + } + + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; + + if (usageCountDiff !== 0) { + return usageCountDiff; + } // Suggest super types first followed by subtypes + + if ( + (0, _definition.isInterfaceType)(typeA) && + schema.isSubType(typeA, typeB) + ) { + return -1; + } + + if ( + (0, _definition.isInterfaceType)(typeB) && + schema.isSubType(typeB, typeA) + ) { + return 1; + } + + return (0, _naturalCompare.naturalCompare)(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ + +function getSuggestedFieldNames(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + const possibleFieldNames = Object.keys(type.getFields()); + return (0, _suggestionList.suggestionList)(fieldName, possibleFieldNames); + } // Otherwise, must be a Union type, which does not define fields. + + return []; +} + + +/***/ }), + +/***/ 84245: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _typeFromAST = __nccwpck_require__(73461); + +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; + + if (typeCondition) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + typeCondition, + ); + + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment cannot condition on non composite type "${typeStr}".`, + { + nodes: typeCondition, + }, + ), + ); + } + } + }, + + FragmentDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.typeCondition, + ); + + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(node.typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, + { + nodes: node.typeCondition, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 32454: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule; +exports.KnownArgumentNamesRule = KnownArgumentNamesRule; + +var _didYouMean = __nccwpck_require__(94476); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _directives = __nccwpck_require__(34154); + +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), + + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); + + if (!argDef && fieldDef && parentType) { + const argName = argNode.name.value; + const knownArgsNames = fieldDef.args.map((arg) => arg.name); + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgsNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + }, + }; +} +/** + * @internal + */ + +function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + directiveArgs[directive.name] = directive.args.map((arg) => arg.name); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argsNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); + } + } + + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs[directiveName]; + + if (directiveNode.arguments && knownArgs) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + + if (!knownArgs.includes(argName)) { + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgs, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on directive "@${directiveName}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 69207: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownDirectivesRule = KnownDirectivesRule; + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _GraphQLError = __nccwpck_require__(66807); + +var _ast = __nccwpck_require__(20727); + +var _directiveLocation = __nccwpck_require__(6128); + +var _kinds = __nccwpck_require__(19542); + +var _directives = __nccwpck_require__(34154); + +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +function KnownDirectivesRule(context) { + const locationsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + locationsMap[directive.name] = directive.locations; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + locationsMap[def.name.value] = def.locations.map((name) => name.value); + } + } + + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap[name]; + + if (!locations) { + context.reportError( + new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, { + nodes: node, + }), + ); + return; + } + + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + + if (candidateLocation && !locations.includes(candidateLocation)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${name}" may not be used on ${candidateLocation}.`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors[ancestors.length - 1]; + 'kind' in appliedTo || (0, _invariant.invariant)(false); + + switch (appliedTo.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); + + case _kinds.Kind.FIELD: + return _directiveLocation.DirectiveLocation.FIELD; + + case _kinds.Kind.FRAGMENT_SPREAD: + return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD; + + case _kinds.Kind.INLINE_FRAGMENT: + return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT; + + case _kinds.Kind.FRAGMENT_DEFINITION: + return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION; + + case _kinds.Kind.VARIABLE_DEFINITION: + return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION; + + case _kinds.Kind.SCHEMA_DEFINITION: + case _kinds.Kind.SCHEMA_EXTENSION: + return _directiveLocation.DirectiveLocation.SCHEMA; + + case _kinds.Kind.SCALAR_TYPE_DEFINITION: + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.SCALAR; + + case _kinds.Kind.OBJECT_TYPE_DEFINITION: + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.OBJECT; + + case _kinds.Kind.FIELD_DEFINITION: + return _directiveLocation.DirectiveLocation.FIELD_DEFINITION; + + case _kinds.Kind.INTERFACE_TYPE_DEFINITION: + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INTERFACE; + + case _kinds.Kind.UNION_TYPE_DEFINITION: + case _kinds.Kind.UNION_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.UNION; + + case _kinds.Kind.ENUM_TYPE_DEFINITION: + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.ENUM; + + case _kinds.Kind.ENUM_VALUE_DEFINITION: + return _directiveLocation.DirectiveLocation.ENUM_VALUE; + + case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INPUT_OBJECT; + + case _kinds.Kind.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + 'kind' in parentNode || (0, _invariant.invariant)(false); + return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION + ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION + : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. + + /* c8 ignore next */ + + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(appliedTo.kind), + ); + } +} + +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case _ast.OperationTypeNode.QUERY: + return _directiveLocation.DirectiveLocation.QUERY; + + case _ast.OperationTypeNode.MUTATION: + return _directiveLocation.DirectiveLocation.MUTATION; + + case _ast.OperationTypeNode.SUBSCRIPTION: + return _directiveLocation.DirectiveLocation.SUBSCRIPTION; + } +} + + +/***/ }), + +/***/ 14838: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownFragmentNamesRule = KnownFragmentNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown fragment "${fragmentName}".`, + { + nodes: node.name, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 83742: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownTypeNamesRule = KnownTypeNamesRule; + +var _didYouMean = __nccwpck_require__(94476); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _predicates = __nccwpck_require__(2493); + +var _introspection = __nccwpck_require__(98029); + +var _scalars = __nccwpck_require__(14544); + +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +function KnownTypeNamesRule(context) { + const schema = context.getSchema(); + const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = true; + } + } + + const typeNames = [ + ...Object.keys(existingTypesMap), + ...Object.keys(definedTypes), + ]; + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + + if (!existingTypesMap[typeName] && !definedTypes[typeName]) { + var _ancestors$; + + const definitionNode = + (_ancestors$ = ancestors[2]) !== null && _ancestors$ !== void 0 + ? _ancestors$ + : parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + + if (isSDL && standardTypeNames.includes(typeName)) { + return; + } + + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + isSDL ? standardTypeNames.concat(typeNames) : typeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown type "${typeName}".` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +const standardTypeNames = [ + ..._scalars.specifiedScalarTypes, + ..._introspection.introspectionTypes, +].map((type) => type.name); + +function isSDLNode(value) { + return ( + 'kind' in value && + ((0, _predicates.isTypeSystemDefinitionNode)(value) || + (0, _predicates.isTypeSystemExtensionNode)(value)) + ); +} + + +/***/ }), + +/***/ 1624: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter( + (definition) => definition.kind === _kinds.Kind.OPERATION_DEFINITION, + ).length; + }, + + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + 'This anonymous operation must be the only defined operation.', + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 87451: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +function LoneSchemaDefinitionRule(context) { + var _ref, _ref2, _oldSchema$astNode; + + const oldSchema = context.getSchema(); + const alreadyDefined = + (_ref = + (_ref2 = + (_oldSchema$astNode = + oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.astNode) !== null && _oldSchema$astNode !== void 0 + ? _oldSchema$astNode + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getQueryType()) !== null && _ref2 !== void 0 + ? _ref2 + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getMutationType()) !== null && _ref !== void 0 + ? _ref + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Cannot define a new schema within a schema extension.', + { + nodes: node, + }, + ), + ); + return; + } + + if (schemaDefinitionsCount > 0) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Must provide only one schema definition.', + { + nodes: node, + }, + ), + ); + } + + ++schemaDefinitionsCount; + }, + }; +} + + +/***/ }), + +/***/ 20514: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoFragmentCyclesRule = NoFragmentCyclesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors + + const spreadPath = []; // Position in the spread path + + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(fragment) { + if (visitedFrags[fragment.name.value]) { + return; + } + + const fragmentName = fragment.name.value; + visitedFrags[fragmentName] = true; + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + + if (spreadNodes.length === 0) { + return; + } + + spreadPathIndexByName[fragmentName] = spreadPath.length; + + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); + + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); + + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), + { + nodes: cyclePath, + }, + ), + ); + } + + spreadPath.pop(); + } + + spreadPathIndexByName[fragmentName] = undefined; + } +} + + +/***/ }), + +/***/ 28997: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUndefinedVariablesRule = NoUndefinedVariablesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +function NoUndefinedVariablesRule(context) { + let variableNameDefined = Object.create(null); + return { + OperationDefinition: { + enter() { + variableNameDefined = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + const varName = node.name.value; + + if (variableNameDefined[varName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, + { + nodes: [node, operation], + }, + ), + ); + } + } + }, + }, + + VariableDefinition(node) { + variableNameDefined[node.variable.name.value] = true; + }, + }; +} + + +/***/ }), + +/***/ 34627: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +function NoUnusedFragmentsRule(context) { + const operationDefs = []; + const fragmentDefs = []; + return { + OperationDefinition(node) { + operationDefs.push(node); + return false; + }, + + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, + + Document: { + leave() { + const fragmentNameUsed = Object.create(null); + + for (const operation of operationDefs) { + for (const fragment of context.getRecursivelyReferencedFragments( + operation, + )) { + fragmentNameUsed[fragment.name.value] = true; + } + } + + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; + + if (fragmentNameUsed[fragName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${fragName}" is never used.`, + { + nodes: fragmentDef, + }, + ), + ); + } + } + }, + }, + }; +} + + +/***/ }), + +/***/ 84580: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUnusedVariablesRule = NoUnusedVariablesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +function NoUnusedVariablesRule(context) { + let variableDefs = []; + return { + OperationDefinition: { + enter() { + variableDefs = []; + }, + + leave(operation) { + const variableNameUsed = Object.create(null); + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + variableNameUsed[node.name.value] = true; + } + + for (const variableDef of variableDefs) { + const variableName = variableDef.variable.name.value; + + if (variableNameUsed[variableName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, + { + nodes: variableDef, + }, + ), + ); + } + } + }, + }, + + VariableDefinition(def) { + variableDefs.push(def); + }, + }; +} + + +/***/ }), + +/***/ 90629: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.OverlappingFieldsCanBeMergedRule = OverlappingFieldsCanBeMergedRule; + +var _inspect = __nccwpck_require__(17819); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _sortValueNode = __nccwpck_require__(21826); + +var _typeFromAST = __nccwpck_require__(73461); + +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map( + ([responseName, subReason]) => + `subfields "${responseName}" conflict because ` + + reasonMessage(subReason), + ) + .join(' and '); + } + + return reason; +} +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ + +function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when two fragments are compared "between" each other for + // conflicts. Two fragments may be compared many times, so memoizing this can + // dramatically improve the performance of this validator. + const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. + + const cachedFieldsAndFragmentNames = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + context.getParentType(), + selectionSet, + ); + + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); + context.reportError( + new _GraphQLError.GraphQLError( + `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, + { + nodes: fields1.concat(fields2), + }, + ), + ); + } + }, + }; +} + +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentType, + selectionSet, +) { + const conflicts = []; + const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, + ); // (A) Find find all conflicts "within" the fields of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. + + collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, + ); + + if (fragmentNames.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread fragment name found. + for (let i = 0; i < fragmentNames.length; i++) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fieldMap, + fragmentNames[i], + ); // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment names to every other + // item in that same list (except for itself). + + for (let j = i + 1; j < fragmentNames.length; j++) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fragmentNames[i], + fragmentNames[j], + ); + } + } + } + + return conflicts; +} // Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. + +function collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fragmentName, +) { + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + return; + } + + const [fieldMap2, referencedFragmentNames] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, + ); // Do not compare a fragment's fieldMap to itself. + + if (fieldMap === fieldMap2) { + return; + } // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fieldMap2, + ); // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. + + for (const referencedFragmentName of referencedFragmentNames) { + // Memoize so two fragments are not compared for conflicts more than once. + if ( + comparedFragmentPairs.has( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ) + ) { + continue; + } + + comparedFragmentPairs.add( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ); + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + referencedFragmentName, + ); + } +} // Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. + +function collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, +) { + // No need to compare a fragment to itself. + if (fragmentName1 === fragmentName2) { + return; + } // Memoize so two fragments are not compared for conflicts more than once. + + if ( + comparedFragmentPairs.has( + fragmentName1, + fragmentName2, + areMutuallyExclusive, + ) + ) { + return; + } + + comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentName1); + const fragment2 = context.getFragment(fragmentName2); + + if (!fragment1 || !fragment2) { + return; + } + + const [fieldMap1, referencedFragmentNames1] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment1, + ); + const [fieldMap2, referencedFragmentNames2] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment2, + ); // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. + + for (const referencedFragmentName2 of referencedFragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + referencedFragmentName2, + ); + } // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. + + for (const referencedFragmentName1 of referencedFragmentNames1) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + referencedFragmentName1, + fragmentName2, + ); + } +} // Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. + +function findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + parentType1, + selectionSet1, + parentType2, + selectionSet2, +) { + const conflicts = []; + const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType1, + selectionSet1, + ); + const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType2, + selectionSet2, + ); // (H) First, collect all conflicts between these two collections of field. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fragmentName2, + ); + } // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + + for (const fragmentName1 of fragmentNames1) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap2, + fragmentName1, + ); + } // (J) Also collect conflicts between any fragment names by the first and + // fragment names by the second. This compares each item in the first set of + // names to each item in the second set of names. + + for (const fragmentName1 of fragmentNames1) { + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, + ); + } + } + + return conflicts; +} // Collect all Conflicts "within" one collection of fields. + +function collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of Object.entries(fieldMap)) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, // within one collection is never mutually exclusive + responseName, + fields[i], + fields[j], + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. + +function collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + fieldMap1, + fieldMap2, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of Object.entries(fieldMap1)) { + const fields2 = fieldMap2[responseName]; + + if (fields2) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. + +function findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, +) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. + + const areMutuallyExclusive = + parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + (0, _definition.isObjectType)(parentType1) && + (0, _definition.isObjectType)(parentType2)); + + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; + + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } // Two field calls must have the same arguments. + + if (stringifyArguments(node1) !== stringifyArguments(node2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } // The return type for each field. + + const type1 = def1 === null || def1 === void 0 ? void 0 : def1.type; + const type2 = def2 === null || def2 === void 0 ? void 0 : def2.type; + + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${(0, _inspect.inspect)( + type1, + )}" and "${(0, _inspect.inspect)(type2)}"`, + ], + [node1], + [node2], + ]; + } // Collect and compare sub-fields. Use the same "visited fragment names" list + // for both collections so fields in a fragment reference are never + // compared to themselves. + + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + (0, _definition.getNamedType)(type1), + selectionSet1, + (0, _definition.getNamedType)(type2), + selectionSet2, + ); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} + +function stringifyArguments(fieldNode) { + var _fieldNode$arguments; + + // FIXME https://github.com/graphql/graphql-js/issues/2203 + const args = + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) !== null && + _fieldNode$arguments !== void 0 + ? _fieldNode$arguments + : []; + const inputObjectWithArgs = { + kind: _kinds.Kind.OBJECT, + fields: args.map((argNode) => ({ + kind: _kinds.Kind.OBJECT_FIELD, + name: argNode.name, + value: argNode.value, + })), + }; + return (0, _printer.print)( + (0, _sortValueNode.sortValueNode)(inputObjectWithArgs), + ); +} // Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. + +function doTypesConflict(type1, type2) { + if ((0, _definition.isListType)(type1)) { + return (0, _definition.isListType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0, _definition.isListType)(type2)) { + return true; + } + + if ((0, _definition.isNonNullType)(type1)) { + return (0, _definition.isNonNullType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0, _definition.isNonNullType)(type2)) { + return true; + } + + if ( + (0, _definition.isLeafType)(type1) || + (0, _definition.isLeafType)(type2) + ) { + return type1 !== type2; + } + + return false; +} // Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment names +// referenced via fragment spreads. + +function getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, +) { + const cached = cachedFieldsAndFragmentNames.get(selectionSet); + + if (cached) { + return cached; + } + + const nodeAndDefs = Object.create(null); + const fragmentNames = Object.create(null); + + _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, + ); + + const result = [nodeAndDefs, Object.keys(fragmentNames)]; + cachedFieldsAndFragmentNames.set(selectionSet, result); + return result; +} // Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment names referenced via fragment spreads. + +function getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, +) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); + + if (cached) { + return cached; + } + + const fragmentType = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + fragment.typeCondition, + ); + return getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragmentType, + fragment.selectionSet, + ); +} + +function _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _kinds.Kind.FIELD: { + const fieldName = selection.name.value; + let fieldDef; + + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + fieldDef = parentType.getFields()[fieldName]; + } + + const responseName = selection.alias + ? selection.alias.value + : fieldName; + + if (!nodeAndDefs[responseName]) { + nodeAndDefs[responseName] = []; + } + + nodeAndDefs[responseName].push([parentType, selection, fieldDef]); + break; + } + + case _kinds.Kind.FRAGMENT_SPREAD: + fragmentNames[selection.name.value] = true; + break; + + case _kinds.Kind.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) + : parentType; + + _collectFieldsAndFragmentNames( + context, + inlineFragmentType, + selection.selectionSet, + nodeAndDefs, + fragmentNames, + ); + + break; + } + } + } +} // Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. + +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; + } +} +/** + * A way to keep track of pairs of things when the ordering of the pair does not matter. + */ + +class PairSet { + constructor() { + this._data = new Map(); + } + + has(a, b, areMutuallyExclusive) { + var _this$_data$get; + + const [key1, key2] = a < b ? [a, b] : [b, a]; + const result = + (_this$_data$get = this._data.get(key1)) === null || + _this$_data$get === void 0 + ? void 0 + : _this$_data$get.get(key2); + + if (result === undefined) { + return false; + } // areMutuallyExclusive being false is a superset of being true, hence if + // we want to know if this PairSet "has" these two with no exclusivity, + // we have to ensure it was added as such. + + return areMutuallyExclusive ? true : areMutuallyExclusive === result; + } + + add(a, b, areMutuallyExclusive) { + const [key1, key2] = a < b ? [a, b] : [b, a]; + + const map = this._data.get(key1); + + if (map === undefined) { + this._data.set(key1, new Map([[key2, areMutuallyExclusive]])); + } else { + map.set(key2, areMutuallyExclusive); + } + } +} + + +/***/ }), + +/***/ 73535: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.PossibleFragmentSpreadsRule = PossibleFragmentSpreadsRule; + +var _inspect = __nccwpck_require__(17819); + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +var _typeComparators = __nccwpck_require__(60700); + +var _typeFromAST = __nccwpck_require__(73461); + +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +function PossibleFragmentSpreadsRule(context) { + return { + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); + + if ( + (0, _definition.isCompositeType)(fragType) && + (0, _definition.isCompositeType)(parentType) && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); + + if ( + fragType && + parentType && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getFragmentType(context, name) { + const frag = context.getFragment(name); + + if (frag) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + frag.typeCondition, + ); + + if ((0, _definition.isCompositeType)(type)) { + return type; + } + } +} + + +/***/ }), + +/***/ 58261: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.PossibleTypeExtensionsRule = PossibleTypeExtensionsRule; + +var _didYouMean = __nccwpck_require__(94476); + +var _inspect = __nccwpck_require__(17819); + +var _invariant = __nccwpck_require__(52810); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _predicates = __nccwpck_require__(2493); + +var _definition = __nccwpck_require__(49492); + +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = def; + } + } + + return { + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; + + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes[typeName]; + const existingType = + schema === null || schema === void 0 ? void 0 : schema.getType(typeName); + let expectedKind; + + if (defNode) { + expectedKind = defKindToExtKind[defNode.kind]; + } else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + + if (expectedKind) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot extend non-${kindStr} type "${typeName}".`, + { + nodes: defNode ? [defNode, node] : node, + }, + ), + ); + } + } else { + const allTypeNames = Object.keys({ + ...definedTypes, + ...(schema === null || schema === void 0 + ? void 0 + : schema.getTypeMap()), + }); + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + allTypeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot extend type "${typeName}" because it is not defined.` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node.name, + }, + ), + ); + } + } +} + +const defKindToExtKind = { + [_kinds.Kind.SCALAR_TYPE_DEFINITION]: _kinds.Kind.SCALAR_TYPE_EXTENSION, + [_kinds.Kind.OBJECT_TYPE_DEFINITION]: _kinds.Kind.OBJECT_TYPE_EXTENSION, + [_kinds.Kind.INTERFACE_TYPE_DEFINITION]: _kinds.Kind.INTERFACE_TYPE_EXTENSION, + [_kinds.Kind.UNION_TYPE_DEFINITION]: _kinds.Kind.UNION_TYPE_EXTENSION, + [_kinds.Kind.ENUM_TYPE_DEFINITION]: _kinds.Kind.ENUM_TYPE_EXTENSION, + [_kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION]: + _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION, +}; + +function typeToExtKind(type) { + if ((0, _definition.isScalarType)(type)) { + return _kinds.Kind.SCALAR_TYPE_EXTENSION; + } + + if ((0, _definition.isObjectType)(type)) { + return _kinds.Kind.OBJECT_TYPE_EXTENSION; + } + + if ((0, _definition.isInterfaceType)(type)) { + return _kinds.Kind.INTERFACE_TYPE_EXTENSION; + } + + if ((0, _definition.isUnionType)(type)) { + return _kinds.Kind.UNION_TYPE_EXTENSION; + } + + if ((0, _definition.isEnumType)(type)) { + return _kinds.Kind.ENUM_TYPE_EXTENSION; + } + + if ((0, _definition.isInputObjectType)(type)) { + return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} + +function extensionKindToTypeName(kind) { + switch (kind) { + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return 'scalar'; + + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return 'object'; + + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return 'interface'; + + case _kinds.Kind.UNION_TYPE_EXTENSION: + return 'union'; + + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return 'enum'; + + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered + + /* c8 ignore next */ + + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(kind), + ); + } +} + + +/***/ }), + +/***/ 94225: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ProvidedRequiredArgumentsOnDirectivesRule = + ProvidedRequiredArgumentsOnDirectivesRule; +exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; + +var _inspect = __nccwpck_require__(17819); + +var _keyMap = __nccwpck_require__(35053); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _directives = __nccwpck_require__(34154); + +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +function ProvidedRequiredArgumentsRule(context) { + return { + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + var _fieldNode$arguments; + + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + return false; + } + + const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) === null || + _fieldNode$arguments === void 0 + ? void 0 + : _fieldNode$arguments.map((arg) => arg.name.value), + ); + + for (const argDef of fieldDef.args) { + if ( + !providedArgs.has(argDef.name) && + (0, _definition.isRequiredArgument)(argDef) + ) { + const argTypeStr = (0, _inspect.inspect)(argDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, + { + nodes: fieldNode, + }, + ), + ); + } + } + }, + }, + }; +} +/** + * @internal + */ + +function ProvidedRequiredArgumentsOnDirectivesRule(context) { + var _schema$getDirectives; + + const requiredArgsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = + (_schema$getDirectives = + schema === null || schema === void 0 + ? void 0 + : schema.getDirectives()) !== null && _schema$getDirectives !== void 0 + ? _schema$getDirectives + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + requiredArgsMap[directive.name] = (0, _keyMap.keyMap)( + directive.args.filter(_definition.isRequiredArgument), + (arg) => arg.name, + ); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + requiredArgsMap[def.name.value] = (0, _keyMap.keyMap)( + argNodes.filter(isRequiredArgumentNode), + (arg) => arg.name.value, + ); + } + } + + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap[directiveName]; + + if (requiredArgs) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + + for (const [argName, argDef] of Object.entries(requiredArgs)) { + if (!argNodeMap.has(argName)) { + const argType = (0, _definition.isType)(argDef.type) + ? (0, _inspect.inspect)(argDef.type) + : (0, _printer.print)(argDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, + { + nodes: directiveNode, + }, + ), + ); + } + } + } + }, + }, + }; +} + +function isRequiredArgumentNode(arg) { + return ( + arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null + ); +} + + +/***/ }), + +/***/ 99500: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ScalarLeafsRule = ScalarLeafsRule; + +var _inspect = __nccwpck_require__(17819); + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +function ScalarLeafsRule(context) { + return { + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; + + if (type) { + if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, + { + nodes: selectionSet, + }, + ), + ); + } + } else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 69843: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _collectFields = __nccwpck_require__(54808); + +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +function SingleFieldSubscriptionsRule(context) { + return { + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); + + for (const definition of document.definitions) { + if (definition.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = definition; + } + } + + const fields = (0, _collectFields.collectFields)( + schema, + fragments, + variableValues, + subscriptionType, + node.selectionSet, + ); + + if (fields.size > 1) { + const fieldSelectionLists = [...fields.values()]; + const extraFieldSelectionLists = fieldSelectionLists.slice(1); + const extraFieldSelections = extraFieldSelectionLists.flat(); + context.reportError( + new _GraphQLError.GraphQLError( + operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', + { + nodes: extraFieldSelections, + }, + ), + ); + } + + for (const fieldNodes of fields.values()) { + const field = fieldNodes[0]; + const fieldName = field.name.value; + + if (fieldName.startsWith('__')) { + context.reportError( + new _GraphQLError.GraphQLError( + operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', + { + nodes: fieldNodes, + }, + ), + ); + } + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 26641: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule; + +var _groupBy = __nccwpck_require__(33278); + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +function UniqueArgumentDefinitionNamesRule(context) { + return { + DirectiveDefinition(directiveNode) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, + + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; + + function checkArgUniquenessPerField(typeNode) { + var _typeNode$fields; + + const typeName = typeNode.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_typeNode$fields = typeNode.fields) !== null && + _typeNode$fields !== void 0 + ? _typeNode$fields + : []; + + for (const fieldDef of fieldNodes) { + var _fieldDef$arguments; + + const fieldName = fieldDef.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_fieldDef$arguments = fieldDef.arguments) !== null && + _fieldDef$arguments !== void 0 + ? _fieldDef$arguments + : []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); + } + + return false; + } + + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `Argument "${parentName}(${argName}:)" can only be defined once.`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + + return false; + } +} + + +/***/ }), + +/***/ 6374: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule; + +var _groupBy = __nccwpck_require__(33278); + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + + function checkArgUniqueness(parentNode) { + var _parentNode$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_parentNode$arguments = parentNode.arguments) !== null && + _parentNode$arguments !== void 0 + ? _parentNode$arguments + : []; + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one argument named "${argName}".`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + } +} + + +/***/ }), + +/***/ 23338: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = Object.create(null); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + + if ( + schema !== null && + schema !== void 0 && + schema.getDirective(directiveName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownDirectiveNames[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one directive named "@${directiveName}".`, + { + nodes: [knownDirectiveNames[directiveName], node.name], + }, + ), + ); + } else { + knownDirectiveNames[directiveName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 74106: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _predicates = __nccwpck_require__(2493); + +var _directives = __nccwpck_require__(34154); + +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap[def.name.value] = !def.repeatable; + } + } + + const schemaDirectives = Object.create(null); + const typeDirectivesMap = Object.create(null); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } + + let seenDirectives; + + if ( + node.kind === _kinds.Kind.SCHEMA_DEFINITION || + node.kind === _kinds.Kind.SCHEMA_EXTENSION + ) { + seenDirectives = schemaDirectives; + } else if ( + (0, _predicates.isTypeDefinitionNode)(node) || + (0, _predicates.isTypeExtensionNode)(node) + ) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap[typeName]; + + if (seenDirectives === undefined) { + typeDirectivesMap[typeName] = seenDirectives = Object.create(null); + } + } else { + seenDirectives = Object.create(null); + } + + for (const directive of node.directives) { + const directiveName = directive.name.value; + + if (uniqueDirectiveMap[directiveName]) { + if (seenDirectives[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `The directive "@${directiveName}" can only be used once at this location.`, + { + nodes: [seenDirectives[directiveName], directive], + }, + ), + ); + } else { + seenDirectives[directiveName] = directive; + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 28113: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = Object.create(null); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; + + function checkValueUniqueness(node) { + var _node$values; + + const typeName = node.name.value; + + if (!knownValueNames[typeName]) { + knownValueNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const valueNodes = + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + const valueNames = knownValueNames[typeName]; + + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; + + if ( + (0, _definition.isEnumType)(existingType) && + existingType.getValue(valueName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: valueDef.name, + }, + ), + ); + } else if (valueNames[valueName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" can only be defined once.`, + { + nodes: [valueNames[valueName], valueDef.name], + }, + ), + ); + } else { + valueNames[valueName] = valueDef.name; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 44282: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = Object.create(null); + return { + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; + + function checkFieldUniqueness(node) { + var _node$fields; + + const typeName = node.name.value; + + if (!knownFieldNames[typeName]) { + knownFieldNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + const fieldNames = knownFieldNames[typeName]; + + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + + if (hasField(existingTypeMap[typeName], fieldName)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: fieldDef.name, + }, + ), + ); + } else if (fieldNames[fieldName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${typeName}.${fieldName}" can only be defined once.`, + { + nodes: [fieldNames[fieldName], fieldDef.name], + }, + ), + ); + } else { + fieldNames[fieldName] = fieldDef.name; + } + } + + return false; + } +} + +function hasField(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) || + (0, _definition.isInputObjectType)(type) + ) { + return type.getFields()[fieldName] != null; + } + + return false; +} + + +/***/ }), + +/***/ 41: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueFragmentNamesRule = UniqueFragmentNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +function UniqueFragmentNamesRule(context) { + const knownFragmentNames = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + const fragmentName = node.name.value; + + if (knownFragmentNames[fragmentName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one fragment named "${fragmentName}".`, + { + nodes: [knownFragmentNames[fragmentName], node.name], + }, + ), + ); + } else { + knownFragmentNames[fragmentName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 12057: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule; + +var _invariant = __nccwpck_require__(52810); + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = Object.create(null); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = Object.create(null); + }, + + leave() { + const prevKnownNames = knownNameStack.pop(); + prevKnownNames || (0, _invariant.invariant)(false); + knownNames = prevKnownNames; + }, + }, + + ObjectField(node) { + const fieldName = node.name.value; + + if (knownNames[fieldName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one input field named "${fieldName}".`, + { + nodes: [knownNames[fieldName], node.name], + }, + ), + ); + } else { + knownNames[fieldName] = node.name; + } + }, + }; +} + + +/***/ }), + +/***/ 32188: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueOperationNamesRule = UniqueOperationNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +function UniqueOperationNamesRule(context) { + const knownOperationNames = Object.create(null); + return { + OperationDefinition(node) { + const operationName = node.name; + + if (operationName) { + if (knownOperationNames[operationName.value]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one operation named "${operationName.value}".`, + { + nodes: [ + knownOperationNames[operationName.value], + operationName, + ], + }, + ), + ); + } else { + knownOperationNames[operationName.value] = operationName; + } + } + + return false; + }, + + FragmentDefinition: () => false, + }; +} + + +/***/ }), + +/***/ 52111: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueOperationTypesRule = UniqueOperationTypesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = Object.create(null); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; + + function checkOperationTypes(node) { + var _node$operationTypes; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const operationTypesNodes = + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes[operation]; + + if (existingOperationTypes[operation]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type for ${operation} already defined in the schema. It cannot be redefined.`, + { + nodes: operationType, + }, + ), + ); + } else if (alreadyDefinedOperationType) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one ${operation} type in schema.`, + { + nodes: [alreadyDefinedOperationType, operationType], + }, + ), + ); + } else { + definedOperationTypes[operation] = operationType; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 77154: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueTypeNamesRule = UniqueTypeNamesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +function UniqueTypeNamesRule(context) { + const knownTypeNames = Object.create(null); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, + }; + + function checkTypeName(node) { + const typeName = node.name.value; + + if (schema !== null && schema !== void 0 && schema.getType(typeName)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownTypeNames[typeName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one type named "${typeName}".`, + { + nodes: [knownTypeNames[typeName], node.name], + }, + ), + ); + } else { + knownTypeNames[typeName] = node.name; + } + + return false; + } +} + + +/***/ }), + +/***/ 1785: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueVariableNamesRule = UniqueVariableNamesRule; + +var _groupBy = __nccwpck_require__(33278); + +var _GraphQLError = __nccwpck_require__(66807); + +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +function UniqueVariableNamesRule(context) { + return { + OperationDefinition(operationNode) { + var _operationNode$variab; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const variableDefinitions = + (_operationNode$variab = operationNode.variableDefinitions) !== null && + _operationNode$variab !== void 0 + ? _operationNode$variab + : []; + const seenVariableDefinitions = (0, _groupBy.groupBy)( + variableDefinitions, + (node) => node.variable.name.value, + ); + + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one variable named "$${variableName}".`, + { + nodes: variableNodes.map((node) => node.variable.name), + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 61399: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; + +var _didYouMean = __nccwpck_require__(94476); + +var _inspect = __nccwpck_require__(17819); + +var _keyMap = __nccwpck_require__(35053); + +var _suggestionList = __nccwpck_require__(48992); + +var _GraphQLError = __nccwpck_require__(66807); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +function ValuesOfCorrectTypeRule(context) { + return { + ListValue(node) { + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + const type = (0, _definition.getNullableType)( + context.getParentInputType(), + ); + + if (!(0, _definition.isListType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } + }, + + ObjectValue(node) { + const type = (0, _definition.getNamedType)(context.getInputType()); + + if (!(0, _definition.isInputObjectType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } // Ensure every required field exists. + + const fieldNodeMap = (0, _keyMap.keyMap)( + node.fields, + (field) => field.name.value, + ); + + for (const fieldDef of Object.values(type.getFields())) { + const fieldNode = fieldNodeMap[fieldDef.name]; + + if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) { + const typeStr = (0, _inspect.inspect)(fieldDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const parentType = (0, _definition.getNamedType)( + context.getParentInputType(), + ); + const fieldType = context.getInputType(); + + if (!fieldType && (0, _definition.isInputObjectType)(parentType)) { + const suggestions = (0, _suggestionList.suggestionList)( + node.name.value, + Object.keys(parentType.getFields()), + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${node.name.value}" is not defined by type "${parentType.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: node, + }, + ), + ); + } + }, + + NullValue(node) { + const type = context.getInputType(); + + if ((0, _definition.isNonNullType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${(0, _inspect.inspect)( + type, + )}", found ${(0, _printer.print)(node)}.`, + { + nodes: node, + }, + ), + ); + } + }, + + EnumValue: (node) => isValidValueNode(context, node), + IntValue: (node) => isValidValueNode(context, node), + FloatValue: (node) => isValidValueNode(context, node), + StringValue: (node) => isValidValueNode(context, node), + BooleanValue: (node) => isValidValueNode(context, node), + }; +} +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ + +function isValidValueNode(context, node) { + // Report any error at the full type expected by the location. + const locationType = context.getInputType(); + + if (!locationType) { + return; + } + + const type = (0, _definition.getNamedType)(locationType); + + if (!(0, _definition.isLeafType)(type)) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + return; + } // Scalars and Enums determine if a literal value is valid via parseLiteral(), + // which may throw or return an invalid value to indicate failure. + + try { + const parseResult = type.parseLiteral( + node, + undefined, + /* variables */ + ); + + if (parseResult === undefined) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + } + } catch (error) { + const typeStr = (0, _inspect.inspect)(locationType); + + if (error instanceof _GraphQLError.GraphQLError) { + context.reportError(error); + } else { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}; ` + error.message, + { + nodes: node, + originalError: error, + }, + ), + ); + } + } +} + + +/***/ }), + +/***/ 53249: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _printer = __nccwpck_require__(3099); + +var _definition = __nccwpck_require__(49492); + +var _typeFromAST = __nccwpck_require__(73461); + +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +function VariablesAreInputTypesRule(context) { + return { + VariableDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.type, + ); + + if (type !== undefined && !(0, _definition.isInputType)(type)) { + const variableName = node.variable.name.value; + const typeName = (0, _printer.print)(node.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${variableName}" cannot be non-input type "${typeName}".`, + { + nodes: node.type, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 19710: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; + +var _inspect = __nccwpck_require__(17819); + +var _GraphQLError = __nccwpck_require__(66807); + +var _kinds = __nccwpck_require__(19542); + +var _definition = __nccwpck_require__(49492); + +var _typeComparators = __nccwpck_require__(60700); + +var _typeFromAST = __nccwpck_require__(73461); + +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +function VariablesInAllowedPositionRule(context) { + let varDefMap = Object.create(null); + return { + OperationDefinition: { + enter() { + varDefMap = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node, type, defaultValue } of usages) { + const varName = node.name.value; + const varDef = varDefMap[varName]; + + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type); + + if ( + varType && + !allowedVariableUsage( + schema, + varType, + varDef.defaultValue, + type, + defaultValue, + ) + ) { + const varTypeStr = (0, _inspect.inspect)(varType); + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, + { + nodes: [varDef, node], + }, + ), + ); + } + } + } + }, + }, + + VariableDefinition(node) { + varDefMap[node.variable.name.value] = node; + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * which includes considering if default values exist for either the variable + * or the location at which it is located. + */ + +function allowedVariableUsage( + schema, + varType, + varDefaultValue, + locationType, + locationDefaultValue, +) { + if ( + (0, _definition.isNonNullType)(locationType) && + !(0, _definition.isNonNullType)(varType) + ) { + const hasNonNullVariableDefaultValue = + varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; + + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; + } + + const nullableLocationType = locationType.ofType; + return (0, _typeComparators.isTypeSubTypeOf)( + schema, + varType, + nullableLocationType, + ); + } + + return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType); +} + + +/***/ }), + +/***/ 10088: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule; + +var _invariant = __nccwpck_require__(52810); + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +function NoDeprecatedCustomRule(context) { + return { + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = + fieldDef === null || fieldDef === void 0 + ? void 0 + : fieldDef.deprecationReason; + + if (fieldDef && deprecationReason != null) { + const parentType = context.getParentType(); + parentType != null || (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = + argDef === null || argDef === void 0 + ? void 0 + : argDef.deprecationReason; + + if (argDef && deprecationReason != null) { + const directiveDef = context.getDirective(); + + if (directiveDef != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } else { + const parentType = context.getParentType(); + const fieldDef = context.getFieldDef(); + (parentType != null && fieldDef != null) || + (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const inputObjectDef = (0, _definition.getNamedType)( + context.getParentInputType(), + ); + + if ((0, _definition.isInputObjectType)(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = + inputFieldDef === null || inputFieldDef === void 0 + ? void 0 + : inputFieldDef.deprecationReason; + + if (deprecationReason != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = + enumValueDef === null || enumValueDef === void 0 + ? void 0 + : enumValueDef.deprecationReason; + + if (enumValueDef && deprecationReason != null) { + const enumTypeDef = (0, _definition.getNamedType)( + context.getInputType(), + ); + enumTypeDef != null || (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 77374: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule; + +var _GraphQLError = __nccwpck_require__(66807); + +var _definition = __nccwpck_require__(49492); + +var _introspection = __nccwpck_require__(98029); + +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +function NoSchemaIntrospectionCustomRule(context) { + return { + Field(node) { + const type = (0, _definition.getNamedType)(context.getType()); + + if (type && (0, _introspection.isIntrospectionType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 41014: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.specifiedSDLRules = exports.specifiedRules = void 0; + +var _ExecutableDefinitionsRule = __nccwpck_require__(68226); + +var _FieldsOnCorrectTypeRule = __nccwpck_require__(7665); + +var _FragmentsOnCompositeTypesRule = __nccwpck_require__(84245); + +var _KnownArgumentNamesRule = __nccwpck_require__(32454); + +var _KnownDirectivesRule = __nccwpck_require__(69207); + +var _KnownFragmentNamesRule = __nccwpck_require__(14838); + +var _KnownTypeNamesRule = __nccwpck_require__(83742); + +var _LoneAnonymousOperationRule = __nccwpck_require__(1624); + +var _LoneSchemaDefinitionRule = __nccwpck_require__(87451); + +var _NoFragmentCyclesRule = __nccwpck_require__(20514); + +var _NoUndefinedVariablesRule = __nccwpck_require__(28997); + +var _NoUnusedFragmentsRule = __nccwpck_require__(34627); + +var _NoUnusedVariablesRule = __nccwpck_require__(84580); + +var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(90629); + +var _PossibleFragmentSpreadsRule = __nccwpck_require__(73535); + +var _PossibleTypeExtensionsRule = __nccwpck_require__(58261); + +var _ProvidedRequiredArgumentsRule = __nccwpck_require__(94225); + +var _ScalarLeafsRule = __nccwpck_require__(99500); + +var _SingleFieldSubscriptionsRule = __nccwpck_require__(69843); + +var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(26641); + +var _UniqueArgumentNamesRule = __nccwpck_require__(6374); + +var _UniqueDirectiveNamesRule = __nccwpck_require__(23338); + +var _UniqueDirectivesPerLocationRule = __nccwpck_require__(74106); + +var _UniqueEnumValueNamesRule = __nccwpck_require__(28113); + +var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(44282); + +var _UniqueFragmentNamesRule = __nccwpck_require__(41); + +var _UniqueInputFieldNamesRule = __nccwpck_require__(12057); + +var _UniqueOperationNamesRule = __nccwpck_require__(32188); + +var _UniqueOperationTypesRule = __nccwpck_require__(52111); + +var _UniqueTypeNamesRule = __nccwpck_require__(77154); + +var _UniqueVariableNamesRule = __nccwpck_require__(1785); + +var _ValuesOfCorrectTypeRule = __nccwpck_require__(61399); + +var _VariablesAreInputTypesRule = __nccwpck_require__(53249); + +var _VariablesInAllowedPositionRule = __nccwpck_require__(19710); + +// Spec Section: "Executable Definitions" +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +// Spec Section: "Fragments on Composite Types" +// Spec Section: "Argument Names" +// Spec Section: "Directives Are Defined" +// Spec Section: "Fragment spread target defined" +// Spec Section: "Fragment Spread Type Existence" +// Spec Section: "Lone Anonymous Operation" +// SDL-specific validation rules +// Spec Section: "Fragments must not form cycles" +// Spec Section: "All Variable Used Defined" +// Spec Section: "Fragments must be used" +// Spec Section: "All Variables Used" +// Spec Section: "Field Selection Merging" +// Spec Section: "Fragment spread is possible" +// Spec Section: "Argument Optionality" +// Spec Section: "Leaf Field Selections" +// Spec Section: "Subscriptions with Single Root Field" +// Spec Section: "Argument Uniqueness" +// Spec Section: "Directives Are Unique Per Location" +// Spec Section: "Fragment Name Uniqueness" +// Spec Section: "Input Object Field Uniqueness" +// Spec Section: "Operation Name Uniqueness" +// Spec Section: "Variable Uniqueness" +// Spec Section: "Value Type Correctness" +// Spec Section: "Variables are Input Types" +// Spec Section: "All Variable Usages Are Allowed" + +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +const specifiedRules = Object.freeze([ + _ExecutableDefinitionsRule.ExecutableDefinitionsRule, + _UniqueOperationNamesRule.UniqueOperationNamesRule, + _LoneAnonymousOperationRule.LoneAnonymousOperationRule, + _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule, + _VariablesAreInputTypesRule.VariablesAreInputTypesRule, + _ScalarLeafsRule.ScalarLeafsRule, + _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule, + _UniqueFragmentNamesRule.UniqueFragmentNamesRule, + _KnownFragmentNamesRule.KnownFragmentNamesRule, + _NoUnusedFragmentsRule.NoUnusedFragmentsRule, + _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule, + _NoFragmentCyclesRule.NoFragmentCyclesRule, + _UniqueVariableNamesRule.UniqueVariableNamesRule, + _NoUndefinedVariablesRule.NoUndefinedVariablesRule, + _NoUnusedVariablesRule.NoUnusedVariablesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _KnownArgumentNamesRule.KnownArgumentNamesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule, + _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule, + _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, +]); +/** + * @internal + */ + +exports.specifiedRules = specifiedRules; +const specifiedSDLRules = Object.freeze([ + _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule, + _UniqueOperationTypesRule.UniqueOperationTypesRule, + _UniqueTypeNamesRule.UniqueTypeNamesRule, + _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule, + _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule, + _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule, + _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule, + _KnownArgumentNamesRule.KnownArgumentNamesOnDirectivesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsOnDirectivesRule, +]); +exports.specifiedSDLRules = specifiedSDLRules; + + +/***/ }), + +/***/ 17329: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidSDL = assertValidSDL; +exports.assertValidSDLExtension = assertValidSDLExtension; +exports.validate = validate; +exports.validateSDL = validateSDL; + +var _devAssert = __nccwpck_require__(60645); + +var _GraphQLError = __nccwpck_require__(66807); + +var _visitor = __nccwpck_require__(45946); + +var _validate = __nccwpck_require__(95929); + +var _TypeInfo = __nccwpck_require__(95756); + +var _specifiedRules = __nccwpck_require__(41014); + +var _ValidationContext = __nccwpck_require__(26243); + +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ +function validate( + schema, + documentAST, + rules = _specifiedRules.specifiedRules, + options, + /** @deprecated will be removed in 17.0.0 */ + typeInfo = new _TypeInfo.TypeInfo(schema), +) { + var _options$maxErrors; + + const maxErrors = + (_options$maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors) !== + null && _options$maxErrors !== void 0 + ? _options$maxErrors + : 100; + documentAST || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. + + (0, _validate.assertValidSchema)(schema); + const abortObj = Object.freeze({}); + const errors = []; + const context = new _ValidationContext.ValidationContext( + schema, + documentAST, + typeInfo, + (error) => { + if (errors.length >= maxErrors) { + errors.push( + new _GraphQLError.GraphQLError( + 'Too many validation errors, error limit reached. Validation aborted.', + ), + ); // eslint-disable-next-line @typescript-eslint/no-throw-literal + + throw abortObj; + } + + errors.push(error); + }, + ); // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. + + const visitor = (0, _visitor.visitInParallel)( + rules.map((rule) => rule(context)), + ); // Visit the whole document with each instance of all provided rules. + + try { + (0, _visitor.visit)( + documentAST, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor), + ); + } catch (e) { + if (e !== abortObj) { + throw e; + } + } + + return errors; +} +/** + * @internal + */ + +function validateSDL( + documentAST, + schemaToExtend, + rules = _specifiedRules.specifiedSDLRules, +) { + const errors = []; + const context = new _ValidationContext.SDLValidationContext( + documentAST, + schemaToExtend, + (error) => { + errors.push(error); + }, + ); + const visitors = rules.map((rule) => rule(context)); + (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + + +/***/ }), + +/***/ 61121: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.versionInfo = exports.version = void 0; +// Note: This file is autogenerated using "resources/gen-version.js" script and +// automatically updated by "npm version" command. + +/** + * A string containing the version of the GraphQL.js library + */ +const version = '16.6.0'; +/** + * An object containing the components of the GraphQL.js version string + */ + +exports.version = version; +const versionInfo = Object.freeze({ + major: 16, + minor: 6, + patch: 0, + preReleaseTag: null, +}); +exports.versionInfo = versionInfo; + + /***/ }), /***/ 72435: @@ -16676,7 +40048,7 @@ for (const a in aliases) { // eslint-disable-line guard-for-in /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { (function (global, factory) { - true ? factory(exports, __nccwpck_require__(32132), __nccwpck_require__(49009)) : + true ? factory(exports, __nccwpck_require__(32132), __nccwpck_require__(65361)) : 0; }(this, (function (exports, tslib, graphql) { 'use strict'; @@ -16824,7 +40196,7 @@ module.exports = __nccwpck_require__(8597).gql; /***/ }), -/***/ 442: +/***/ 93192: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -16837,11 +40209,11 @@ exports.GraphQLError = void 0; exports.formatError = formatError; exports.printError = printError; -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _location = __nccwpck_require__(75450); +var _location = __nccwpck_require__(13857); -var _printLocation = __nccwpck_require__(16845); +var _printLocation = __nccwpck_require__(40676); function toNormalizedOptions(args) { const firstArg = args[0]; @@ -17099,7 +40471,7 @@ function formatError(error) { /***/ }), -/***/ 56815: +/***/ 37549: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -17139,16 +40511,16 @@ Object.defineProperty(exports, "syntaxError", ({ }, })); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _syntaxError = __nccwpck_require__(87910); +var _syntaxError = __nccwpck_require__(53354); -var _locatedError = __nccwpck_require__(73285); +var _locatedError = __nccwpck_require__(49943); /***/ }), -/***/ 73285: +/***/ 49943: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -17159,9 +40531,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.locatedError = locatedError; -var _toError = __nccwpck_require__(3524); +var _toError = __nccwpck_require__(15989); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); /** * Given an arbitrary value, presumably thrown while attempting to execute a @@ -17196,7 +40568,7 @@ function isLocatedGraphQLError(error) { /***/ }), -/***/ 87910: +/***/ 53354: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -17207,7 +40579,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.syntaxError = syntaxError; -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); /** * Produces a GraphQLError representing a syntax error, containing useful @@ -17223,7 +40595,7 @@ function syntaxError(source, position, description) { /***/ }), -/***/ 28951: +/***/ 3027: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -17235,15 +40607,15 @@ Object.defineProperty(exports, "__esModule", ({ exports.collectFields = collectFields; exports.collectSubfields = collectSubfields; -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _directives = __nccwpck_require__(27602); +var _directives = __nccwpck_require__(50828); -var _typeFromAST = __nccwpck_require__(32901); +var _typeFromAST = __nccwpck_require__(20207); -var _values = __nccwpck_require__(32502); +var _values = __nccwpck_require__(49106); /** * Given a selectionSet, collects all of the fields and returns them. @@ -17460,7 +40832,7 @@ function getFieldEntryKey(node) { /***/ }), -/***/ 60201: +/***/ 75510: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -17477,43 +40849,43 @@ exports.execute = execute; exports.executeSync = executeSync; exports.getFieldDef = getFieldDef; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _invariant = __nccwpck_require__(28864); +var _invariant = __nccwpck_require__(31338); -var _isIterableObject = __nccwpck_require__(77306); +var _isIterableObject = __nccwpck_require__(63522); -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _isPromise = __nccwpck_require__(85413); +var _isPromise = __nccwpck_require__(5926); -var _memoize = __nccwpck_require__(60555); +var _memoize = __nccwpck_require__(19264); -var _Path = __nccwpck_require__(23798); +var _Path = __nccwpck_require__(3585); -var _promiseForObject = __nccwpck_require__(25677); +var _promiseForObject = __nccwpck_require__(76762); -var _promiseReduce = __nccwpck_require__(32215); +var _promiseReduce = __nccwpck_require__(74614); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _locatedError = __nccwpck_require__(73285); +var _locatedError = __nccwpck_require__(49943); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _introspection = __nccwpck_require__(95678); +var _introspection = __nccwpck_require__(8077); -var _validate = __nccwpck_require__(21299); +var _validate = __nccwpck_require__(51662); -var _collectFields = __nccwpck_require__(28951); +var _collectFields = __nccwpck_require__(3027); -var _values = __nccwpck_require__(32502); +var _values = __nccwpck_require__(49106); /** * A memoized collection of relevant subfields with regard to the return @@ -17874,23 +41246,34 @@ function executeFields(exeContext, parentType, sourceValue, path, fields) { const results = Object.create(null); let containsPromise = false; - for (const [responseName, fieldNodes] of fields.entries()) { - const fieldPath = (0, _Path.addPath)(path, responseName, parentType.name); - const result = executeField( - exeContext, - parentType, - sourceValue, - fieldNodes, - fieldPath, - ); + try { + for (const [responseName, fieldNodes] of fields.entries()) { + const fieldPath = (0, _Path.addPath)(path, responseName, parentType.name); + const result = executeField( + exeContext, + parentType, + sourceValue, + fieldNodes, + fieldPath, + ); - if (result !== undefined) { - results[responseName] = result; + if (result !== undefined) { + results[responseName] = result; - if ((0, _isPromise.isPromise)(result)) { - containsPromise = true; + if ((0, _isPromise.isPromise)(result)) { + containsPromise = true; + } } } + } catch (error) { + if (containsPromise) { + // Ensure that any promises returned by other fields are handled, as they may also reject. + return (0, _promiseForObject.promiseForObject)(results).finally(() => { + throw error; + }); + } + + throw error; } // If there are no promises, we can just return the object if (!containsPromise) { @@ -18494,7 +41877,7 @@ function getFieldDef(schema, parentType, fieldNode) { /***/ }), -/***/ 15701: +/***/ 86506: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -18564,18 +41947,18 @@ Object.defineProperty(exports, "subscribe", ({ }, })); -var _Path = __nccwpck_require__(23798); +var _Path = __nccwpck_require__(3585); -var _execute = __nccwpck_require__(60201); +var _execute = __nccwpck_require__(75510); -var _subscribe = __nccwpck_require__(31009); +var _subscribe = __nccwpck_require__(1404); -var _values = __nccwpck_require__(32502); +var _values = __nccwpck_require__(49106); /***/ }), -/***/ 15685: +/***/ 6491: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -18651,7 +42034,7 @@ function mapAsyncIterator(iterable, callback) { /***/ }), -/***/ 31009: +/***/ 1404: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -18663,25 +42046,25 @@ Object.defineProperty(exports, "__esModule", ({ exports.createSourceEventStream = createSourceEventStream; exports.subscribe = subscribe; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _isAsyncIterable = __nccwpck_require__(44503); +var _isAsyncIterable = __nccwpck_require__(27159); -var _Path = __nccwpck_require__(23798); +var _Path = __nccwpck_require__(3585); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _locatedError = __nccwpck_require__(73285); +var _locatedError = __nccwpck_require__(49943); -var _collectFields = __nccwpck_require__(28951); +var _collectFields = __nccwpck_require__(3027); -var _execute = __nccwpck_require__(60201); +var _execute = __nccwpck_require__(75510); -var _mapAsyncIterator = __nccwpck_require__(15685); +var _mapAsyncIterator = __nccwpck_require__(6491); -var _values = __nccwpck_require__(32502); +var _values = __nccwpck_require__(49106); /** * Implements the "Subscribe" algorithm described in the GraphQL specification. @@ -18903,7 +42286,7 @@ async function executeSubscription(exeContext) { /***/ }), -/***/ 32502: +/***/ 49106: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -18916,25 +42299,25 @@ exports.getArgumentValues = getArgumentValues; exports.getDirectiveValues = getDirectiveValues; exports.getVariableValues = getVariableValues; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _keyMap = __nccwpck_require__(65169); +var _keyMap = __nccwpck_require__(22660); -var _printPathArray = __nccwpck_require__(17069); +var _printPathArray = __nccwpck_require__(36956); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _printer = __nccwpck_require__(46157); +var _printer = __nccwpck_require__(54697); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _coerceInputValue = __nccwpck_require__(56977); +var _coerceInputValue = __nccwpck_require__(47416); -var _typeFromAST = __nccwpck_require__(32901); +var _typeFromAST = __nccwpck_require__(20207); -var _valueFromAST = __nccwpck_require__(60962); +var _valueFromAST = __nccwpck_require__(71964); /** * Prepares an object map of variableValues of the correct type based on the @@ -19055,7 +42438,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) { onError( new _GraphQLError.GraphQLError(prefix + '; ' + error.message, { nodes: varDefNode, - originalError: error.originalError, + originalError: error, }), ); }, @@ -19211,7 +42594,7 @@ function hasOwnProperty(obj, prop) { /***/ }), -/***/ 733: +/***/ 21522: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -19223,17 +42606,17 @@ Object.defineProperty(exports, "__esModule", ({ exports.graphql = graphql; exports.graphqlSync = graphqlSync; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _isPromise = __nccwpck_require__(85413); +var _isPromise = __nccwpck_require__(5926); -var _parser = __nccwpck_require__(89937); +var _parser = __nccwpck_require__(8515); -var _validate = __nccwpck_require__(21299); +var _validate = __nccwpck_require__(51662); -var _validate2 = __nccwpck_require__(1581); +var _validate2 = __nccwpck_require__(16405); -var _execute = __nccwpck_require__(60201); +var _execute = __nccwpck_require__(75510); function graphql(args) { // Always return a Promise for a consistent API. @@ -19315,7 +42698,7 @@ function graphqlImpl(args) { /***/ }), -/***/ 49009: +/***/ 65361: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -20573,26 +43956,26 @@ Object.defineProperty(exports, "visitWithTypeInfo", ({ }, })); -var _version = __nccwpck_require__(63732); +var _version = __nccwpck_require__(48267); -var _graphql = __nccwpck_require__(733); +var _graphql = __nccwpck_require__(21522); -var _index = __nccwpck_require__(40776); +var _index = __nccwpck_require__(42983); -var _index2 = __nccwpck_require__(62153); +var _index2 = __nccwpck_require__(96428); -var _index3 = __nccwpck_require__(15701); +var _index3 = __nccwpck_require__(86506); -var _index4 = __nccwpck_require__(87682); +var _index4 = __nccwpck_require__(99241); -var _index5 = __nccwpck_require__(56815); +var _index5 = __nccwpck_require__(37549); -var _index6 = __nccwpck_require__(97206); +var _index6 = __nccwpck_require__(80669); /***/ }), -/***/ 23798: +/***/ 3585: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20633,7 +44016,7 @@ function pathToArray(path) { /***/ }), -/***/ 6205: +/***/ 88054: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20655,7 +44038,7 @@ function devAssert(condition, message) { /***/ }), -/***/ 28052: +/***/ 4475: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20701,7 +44084,7 @@ function didYouMean(firstArg, secondArg) { /***/ }), -/***/ 12597: +/***/ 7890: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20735,7 +44118,7 @@ function groupBy(list, keyFn) { /***/ }), -/***/ 20220: +/***/ 76649: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20756,7 +44139,7 @@ function identityFunc(x) { /***/ }), -/***/ 70715: +/***/ 85856: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20885,7 +44268,7 @@ function getObjectTag(object) { /***/ }), -/***/ 47599: +/***/ 12358: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -20896,7 +44279,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.instanceOf = void 0; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); /** * A replacement for instanceof which includes an error warning when multi-realm @@ -20907,8 +44290,7 @@ var _inspect = __nccwpck_require__(70715); const instanceOf = /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 - // eslint-disable-next-line no-undef - process.env.NODE_ENV === 'production' + globalThis.process && globalThis.process.env.NODE_ENV === 'production' ? function instanceOf(value, constructor) { return value instanceof constructor; } @@ -20954,7 +44336,7 @@ exports.instanceOf = instanceOf; /***/ }), -/***/ 28864: +/***/ 31338: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -20978,7 +44360,7 @@ function invariant(condition, message) { /***/ }), -/***/ 44503: +/***/ 27159: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21004,7 +44386,7 @@ function isAsyncIterable(maybeAsyncIterable) { /***/ }), -/***/ 77306: +/***/ 63522: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21044,7 +44426,7 @@ function isIterableObject(maybeIterable) { /***/ }), -/***/ 46541: +/***/ 39453: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21066,7 +44448,7 @@ function isObjectLike(value) { /***/ }), -/***/ 85413: +/***/ 5926: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21091,7 +44473,7 @@ function isPromise(value) { /***/ }), -/***/ 65169: +/***/ 22660: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21142,7 +44524,7 @@ function keyMap(list, keyFn) { /***/ }), -/***/ 98673: +/***/ 63345: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21183,7 +44565,7 @@ function keyValMap(list, keyFn, valFn) { /***/ }), -/***/ 40176: +/***/ 83611: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21211,7 +44593,7 @@ function mapValue(map, fn) { /***/ }), -/***/ 60555: +/***/ 19264: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21260,7 +44642,7 @@ function memoize3(fn) { /***/ }), -/***/ 48917: +/***/ 72220: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21337,7 +44719,7 @@ function isDigit(code) { /***/ }), -/***/ 17069: +/***/ 36956: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21362,7 +44744,7 @@ function printPathArray(path) { /***/ }), -/***/ 25677: +/***/ 76762: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21395,7 +44777,7 @@ function promiseForObject(object) { /***/ }), -/***/ 32215: +/***/ 74614: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -21406,7 +44788,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.promiseReduce = promiseReduce; -var _isPromise = __nccwpck_require__(85413); +var _isPromise = __nccwpck_require__(5926); /** * Similar to Array.prototype.reduce(), however the reducing callback may return @@ -21430,7 +44812,7 @@ function promiseReduce(values, callbackFn, initialValue) { /***/ }), -/***/ 69977: +/***/ 11642: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -21441,7 +44823,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.suggestionList = suggestionList; -var _naturalCompare = __nccwpck_require__(48917); +var _naturalCompare = __nccwpck_require__(72220); /** * Given an invalid input string and a list of valid options, returns a filtered @@ -21577,7 +44959,7 @@ function stringToArray(str) { /***/ }), -/***/ 3524: +/***/ 15989: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -21588,7 +44970,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.toError = toError; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); /** * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. @@ -21610,7 +44992,7 @@ class NonErrorThrown extends Error { /***/ }), -/***/ 25964: +/***/ 91250: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21642,7 +45024,7 @@ function toObjMap(obj) { /***/ }), -/***/ 22744: +/***/ 90733: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -21874,7 +45256,7 @@ exports.OperationTypeNode = OperationTypeNode; /***/ }), -/***/ 25466: +/***/ 49074: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -21887,7 +45269,7 @@ exports.dedentBlockStringLines = dedentBlockStringLines; exports.isPrintableAsBlockString = isPrintableAsBlockString; exports.printBlockString = printBlockString; -var _characterClasses = __nccwpck_require__(28170); +var _characterClasses = __nccwpck_require__(10849); /** * Produces the value of a block string from its parsed raw value, similar to @@ -22077,7 +45459,7 @@ function printBlockString(value, options) { /***/ }), -/***/ 28170: +/***/ 10849: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -22160,7 +45542,7 @@ function isNameContinue(code) { /***/ }), -/***/ 95311: +/***/ 53012: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -22207,7 +45589,7 @@ exports.DirectiveLocation = DirectiveLocation; /***/ }), -/***/ 62153: +/***/ 96428: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -22403,34 +45785,34 @@ Object.defineProperty(exports, "visitInParallel", ({ }, })); -var _source = __nccwpck_require__(51561); +var _source = __nccwpck_require__(43985); -var _location = __nccwpck_require__(75450); +var _location = __nccwpck_require__(13857); -var _printLocation = __nccwpck_require__(16845); +var _printLocation = __nccwpck_require__(40676); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _tokenKind = __nccwpck_require__(9520); +var _tokenKind = __nccwpck_require__(11142); -var _lexer = __nccwpck_require__(6529); +var _lexer = __nccwpck_require__(11548); -var _parser = __nccwpck_require__(89937); +var _parser = __nccwpck_require__(8515); -var _printer = __nccwpck_require__(46157); +var _printer = __nccwpck_require__(54697); -var _visitor = __nccwpck_require__(78625); +var _visitor = __nccwpck_require__(69826); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _predicates = __nccwpck_require__(24854); +var _predicates = __nccwpck_require__(19007); -var _directiveLocation = __nccwpck_require__(95311); +var _directiveLocation = __nccwpck_require__(53012); /***/ }), -/***/ 36578: +/***/ 36096: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -22501,7 +45883,7 @@ exports.Kind = Kind; /***/ }), -/***/ 6529: +/***/ 11548: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -22513,15 +45895,15 @@ Object.defineProperty(exports, "__esModule", ({ exports.Lexer = void 0; exports.isPunctuatorTokenKind = isPunctuatorTokenKind; -var _syntaxError = __nccwpck_require__(87910); +var _syntaxError = __nccwpck_require__(53354); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _blockString = __nccwpck_require__(25466); +var _blockString = __nccwpck_require__(49074); -var _characterClasses = __nccwpck_require__(28170); +var _characterClasses = __nccwpck_require__(10849); -var _tokenKind = __nccwpck_require__(9520); +var _tokenKind = __nccwpck_require__(11142); /** * Given a Source object, creates a Lexer for that source. @@ -23515,7 +46897,7 @@ function readName(lexer, start) { /***/ }), -/***/ 75450: +/***/ 13857: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -23526,7 +46908,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.getLocation = getLocation; -var _invariant = __nccwpck_require__(28864); +var _invariant = __nccwpck_require__(31338); const LineRegExp = /\r\n|[\n\r]/g; /** @@ -23561,7 +46943,7 @@ function getLocation(source, position) { /***/ }), -/***/ 89937: +/***/ 8515: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -23576,19 +46958,19 @@ exports.parseConstValue = parseConstValue; exports.parseType = parseType; exports.parseValue = parseValue; -var _syntaxError = __nccwpck_require__(87910); +var _syntaxError = __nccwpck_require__(53354); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _directiveLocation = __nccwpck_require__(95311); +var _directiveLocation = __nccwpck_require__(53012); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _lexer = __nccwpck_require__(6529); +var _lexer = __nccwpck_require__(11548); -var _source = __nccwpck_require__(51561); +var _source = __nccwpck_require__(43985); -var _tokenKind = __nccwpck_require__(9520); +var _tokenKind = __nccwpck_require__(11142); /** * Given a GraphQL source, parses it into a Document. @@ -25136,7 +48518,7 @@ function getTokenKindDesc(kind) { /***/ }), -/***/ 24854: +/***/ 19007: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -25156,7 +48538,7 @@ exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode; exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode; exports.isValueNode = isValueNode; -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); function isDefinitionNode(node) { return ( @@ -25253,7 +48635,7 @@ function isTypeExtensionNode(node) { /***/ }), -/***/ 16845: +/***/ 40676: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -25265,7 +48647,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.printLocation = printLocation; exports.printSourceLocation = printSourceLocation; -var _location = __nccwpck_require__(75450); +var _location = __nccwpck_require__(13857); /** * Render a helpful description of the location in the GraphQL Source document. @@ -25335,7 +48717,7 @@ function printPrefixedLines(lines) { /***/ }), -/***/ 45422: +/***/ 90517: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -25526,7 +48908,7 @@ const escapeSequences = [ /***/ }), -/***/ 46157: +/***/ 54697: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -25537,11 +48919,11 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.print = print; -var _blockString = __nccwpck_require__(25466); +var _blockString = __nccwpck_require__(49074); -var _printString = __nccwpck_require__(45422); +var _printString = __nccwpck_require__(90517); -var _visitor = __nccwpck_require__(78625); +var _visitor = __nccwpck_require__(69826); /** * Converts an AST into a string, using one set of reasonable @@ -25885,7 +49267,7 @@ function hasMultilineItems(maybeArray) { /***/ }), -/***/ 51561: +/***/ 43985: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -25897,11 +49279,11 @@ Object.defineProperty(exports, "__esModule", ({ exports.Source = void 0; exports.isSource = isSource; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _instanceOf = __nccwpck_require__(47599); +var _instanceOf = __nccwpck_require__(12358); /** * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are @@ -25958,7 +49340,7 @@ function isSource(source) { /***/ }), -/***/ 9520: +/***/ 11142: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -26009,7 +49391,7 @@ exports.TokenKind = TokenKind; /***/ }), -/***/ 78625: +/***/ 69826: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -26024,13 +49406,13 @@ exports.getVisitFn = getVisitFn; exports.visit = visit; exports.visitInParallel = visitInParallel; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); const BREAK = Object.freeze({}); /** @@ -26394,7 +49776,7 @@ function getVisitFn(visitor, kind, isLeaving) { /***/ }), -/***/ 19322: +/***/ 31752: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -26406,11 +49788,11 @@ Object.defineProperty(exports, "__esModule", ({ exports.assertEnumValueName = assertEnumValueName; exports.assertName = assertName; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _characterClasses = __nccwpck_require__(28170); +var _characterClasses = __nccwpck_require__(10849); /** * Upholds the spec rules about naming. @@ -26461,7 +49843,7 @@ function assertEnumValueName(name) { /***/ }), -/***/ 82341: +/***/ 57741: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -26522,37 +49904,37 @@ exports.isWrappingType = isWrappingType; exports.resolveObjMapThunk = resolveObjMapThunk; exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _didYouMean = __nccwpck_require__(28052); +var _didYouMean = __nccwpck_require__(4475); -var _identityFunc = __nccwpck_require__(20220); +var _identityFunc = __nccwpck_require__(76649); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _instanceOf = __nccwpck_require__(47599); +var _instanceOf = __nccwpck_require__(12358); -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _keyMap = __nccwpck_require__(65169); +var _keyMap = __nccwpck_require__(22660); -var _keyValMap = __nccwpck_require__(98673); +var _keyValMap = __nccwpck_require__(63345); -var _mapValue = __nccwpck_require__(40176); +var _mapValue = __nccwpck_require__(83611); -var _suggestionList = __nccwpck_require__(69977); +var _suggestionList = __nccwpck_require__(11642); -var _toObjMap = __nccwpck_require__(25964); +var _toObjMap = __nccwpck_require__(91250); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _printer = __nccwpck_require__(46157); +var _printer = __nccwpck_require__(54697); -var _valueFromASTUntyped = __nccwpck_require__(44051); +var _valueFromASTUntyped = __nccwpck_require__(97416); -var _assertName = __nccwpck_require__(19322); +var _assertName = __nccwpck_require__(31752); function isType(type) { return ( @@ -27808,7 +51190,7 @@ function isRequiredInputField(field) { /***/ }), -/***/ 27602: +/***/ 50828: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -27829,23 +51211,23 @@ exports.isDirective = isDirective; exports.isSpecifiedDirective = isSpecifiedDirective; exports.specifiedDirectives = void 0; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _instanceOf = __nccwpck_require__(47599); +var _instanceOf = __nccwpck_require__(12358); -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _toObjMap = __nccwpck_require__(25964); +var _toObjMap = __nccwpck_require__(91250); -var _directiveLocation = __nccwpck_require__(95311); +var _directiveLocation = __nccwpck_require__(53012); -var _assertName = __nccwpck_require__(19322); +var _assertName = __nccwpck_require__(31752); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _scalars = __nccwpck_require__(41963); +var _scalars = __nccwpck_require__(94420); /** * Test if the given value is a GraphQL directive. @@ -28040,7 +51422,7 @@ function isSpecifiedDirective(directive) { /***/ }), -/***/ 40776: +/***/ 42983: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -28578,24 +51960,24 @@ Object.defineProperty(exports, "validateSchema", ({ }, })); -var _schema = __nccwpck_require__(17287); +var _schema = __nccwpck_require__(354); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _directives = __nccwpck_require__(27602); +var _directives = __nccwpck_require__(50828); -var _scalars = __nccwpck_require__(41963); +var _scalars = __nccwpck_require__(94420); -var _introspection = __nccwpck_require__(95678); +var _introspection = __nccwpck_require__(8077); -var _validate = __nccwpck_require__(21299); +var _validate = __nccwpck_require__(51662); -var _assertName = __nccwpck_require__(19322); +var _assertName = __nccwpck_require__(31752); /***/ }), -/***/ 95678: +/***/ 8077: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -28620,19 +52002,19 @@ exports.introspectionTypes = void 0; exports.isIntrospectionType = isIntrospectionType; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _invariant = __nccwpck_require__(28864); +var _invariant = __nccwpck_require__(31338); -var _directiveLocation = __nccwpck_require__(95311); +var _directiveLocation = __nccwpck_require__(53012); -var _printer = __nccwpck_require__(46157); +var _printer = __nccwpck_require__(54697); -var _astFromValue = __nccwpck_require__(14268); +var _astFromValue = __nccwpck_require__(61402); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _scalars = __nccwpck_require__(41963); +var _scalars = __nccwpck_require__(94420); const __Schema = new _definition.GraphQLObjectType({ name: '__Schema', @@ -29220,7 +52602,7 @@ function isIntrospectionType(type) { /***/ }), -/***/ 41963: +/***/ 94420: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -29240,17 +52622,17 @@ exports.GraphQLString = exports.isSpecifiedScalarType = isSpecifiedScalarType; exports.specifiedScalarTypes = void 0; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _kinds = __nccwpck_require__(36578); +var _kinds = __nccwpck_require__(36096); -var _printer = __nccwpck_require__(46157); +var _printer = __nccwpck_require__(54697); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); /** * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). @@ -29597,7 +52979,7 @@ function serializeObject(outputValue) { /***/ }), -/***/ 17287: +/***/ 354: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -29610,23 +52992,23 @@ exports.GraphQLSchema = void 0; exports.assertSchema = assertSchema; exports.isSchema = isSchema; -var _devAssert = __nccwpck_require__(6205); +var _devAssert = __nccwpck_require__(88054); -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _instanceOf = __nccwpck_require__(47599); +var _instanceOf = __nccwpck_require__(12358); -var _isObjectLike = __nccwpck_require__(46541); +var _isObjectLike = __nccwpck_require__(39453); -var _toObjMap = __nccwpck_require__(25964); +var _toObjMap = __nccwpck_require__(91250); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _directives = __nccwpck_require__(27602); +var _directives = __nccwpck_require__(50828); -var _introspection = __nccwpck_require__(95678); +var _introspection = __nccwpck_require__(8077); /** * Test if the given value is a GraphQL schema. @@ -30007,7 +53389,7 @@ function collectReferencedTypes(type, typeSet) { /***/ }), -/***/ 21299: +/***/ 51662: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -30019,21 +53401,21 @@ Object.defineProperty(exports, "__esModule", ({ exports.assertValidSchema = assertValidSchema; exports.validateSchema = validateSchema; -var _inspect = __nccwpck_require__(70715); +var _inspect = __nccwpck_require__(85856); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _ast = __nccwpck_require__(22744); +var _ast = __nccwpck_require__(90733); -var _typeComparators = __nccwpck_require__(72159); +var _typeComparators = __nccwpck_require__(33981); -var _definition = __nccwpck_require__(82341); +var _definition = __nccwpck_require__(57741); -var _directives = __nccwpck_require__(27602); +var _directives = __nccwpck_require__(50828); -var _introspection = __nccwpck_require__(95678); +var _introspection = __nccwpck_require__(8077); -var _schema = __nccwpck_require__(17287); +var _schema = __nccwpck_require__(354); /** * Implements the "Type Validation" sub-sections of the specification's @@ -30454,244 +53836,729 @@ function validateTypeImplementsInterface(context, type, iface) { : _typeArg$astNode.type, ], ); - } // TODO: validate default values? - } // Assert additional arguments must not be required. + } // TODO: validate default values? + } // Assert additional arguments must not be required. + + for (const typeArg of typeField.args) { + const argName = typeArg.name; + const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); + + if (!ifaceArg && (0, _definition.isRequiredArgument)(typeArg)) { + context.reportError( + `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, + [typeArg.astNode, ifaceField.astNode], + ); + } + } + } +} + +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError( + transitive === type + ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` + : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, + [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ], + ); + } + } +} + +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + + if (memberTypes.length === 0) { + context.reportError( + `Union type ${union.name} must define one or more member types.`, + [union.astNode, ...union.extensionASTNodes], + ); + } + + const includedTypeNames = Object.create(null); + + for (const memberType of memberTypes) { + if (includedTypeNames[memberType.name]) { + context.reportError( + `Union type ${union.name} can only include type ${memberType.name} once.`, + getUnionMemberTypeNodes(union, memberType.name), + ); + continue; + } + + includedTypeNames[memberType.name] = true; + + if (!(0, _definition.isObjectType)(memberType)) { + context.reportError( + `Union type ${union.name} can only include Object types, ` + + `it cannot include ${(0, _inspect.inspect)(memberType)}.`, + getUnionMemberTypeNodes(union, String(memberType)), + ); + } + } +} + +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + + if (enumValues.length === 0) { + context.reportError( + `Enum type ${enumType.name} must define one or more values.`, + [enumType.astNode, ...enumType.extensionASTNodes], + ); + } + + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} + +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + + if (fields.length === 0) { + context.reportError( + `Input Object type ${inputObj.name} must define one or more fields.`, + [inputObj.astNode, ...inputObj.extensionASTNodes], + ); + } // Ensure the arguments are valid + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an input type + + if (!(0, _definition.isInputType)(field.type)) { + var _field$astNode2; + + context.reportError( + `The type of ${inputObj.name}.${field.name} must be Input Type ` + + `but got: ${(0, _inspect.inspect)(field.type)}.`, + (_field$astNode2 = field.astNode) === null || _field$astNode2 === void 0 + ? void 0 + : _field$astNode2.type, + ); + } + + if ( + (0, _definition.isRequiredInputField)(field) && + field.deprecationReason != null + ) { + var _field$astNode3; + + context.reportError( + `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(field.astNode), + (_field$astNode3 = field.astNode) === null || + _field$astNode3 === void 0 + ? void 0 + : _field$astNode3.type, + ], + ); + } + } +} + +function createInputObjectCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors + + const fieldPath = []; // Position in the type path + + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(inputObj) { + if (visitedTypes[inputObj.name]) { + return; + } + + visitedTypes[inputObj.name] = true; + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + + for (const field of fields) { + if ( + (0, _definition.isNonNullType)(field.type) && + (0, _definition.isInputObjectType)(field.type.ofType) + ) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push(field); + + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); + context.reportError( + `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, + cyclePath.map((fieldObj) => fieldObj.astNode), + ); + } + + fieldPath.pop(); + } + } + + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} + +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((typeNode) => { + var _typeNode$interfaces; + + return ( + /* c8 ignore next */ + (_typeNode$interfaces = typeNode.interfaces) !== null && + _typeNode$interfaces !== void 0 + ? _typeNode$interfaces + : [] + ); + }) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} + +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((unionNode) => { + var _unionNode$types; + + return ( + /* c8 ignore next */ + (_unionNode$types = unionNode.types) !== null && + _unionNode$types !== void 0 + ? _unionNode$types + : [] + ); + }) + .filter((typeNode) => typeNode.name.value === typeName); +} + +function getDeprecatedDirectiveNode(definitionNode) { + var _definitionNode$direc; + + return definitionNode === null || definitionNode === void 0 + ? void 0 + : (_definitionNode$direc = definitionNode.directives) === null || + _definitionNode$direc === void 0 + ? void 0 + : _definitionNode$direc.find( + (node) => + node.name.value === _directives.GraphQLDeprecatedDirective.name, + ); +} + + +/***/ }), + +/***/ 63981: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.TypeInfo = void 0; +exports.visitWithTypeInfo = visitWithTypeInfo; + +var _ast = __nccwpck_require__(90733); + +var _kinds = __nccwpck_require__(36096); + +var _visitor = __nccwpck_require__(69826); + +var _definition = __nccwpck_require__(57741); + +var _introspection = __nccwpck_require__(8077); + +var _typeFromAST = __nccwpck_require__(20207); + +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +class TypeInfo { + constructor( + schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, + /** @deprecated will be removed in 17.0.0 */ + getFieldDefFn, + ) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._getFieldDef = + getFieldDefFn !== null && getFieldDefFn !== void 0 + ? getFieldDefFn + : getFieldDef; + + if (initialType) { + if ((0, _definition.isInputType)(initialType)) { + this._inputTypeStack.push(initialType); + } + + if ((0, _definition.isCompositeType)(initialType)) { + this._parentTypeStack.push(initialType); + } + + if ((0, _definition.isOutputType)(initialType)) { + this._typeStack.push(initialType); + } + } + } + + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + + getType() { + if (this._typeStack.length > 0) { + return this._typeStack[this._typeStack.length - 1]; + } + } + + getParentType() { + if (this._parentTypeStack.length > 0) { + return this._parentTypeStack[this._parentTypeStack.length - 1]; + } + } + + getInputType() { + if (this._inputTypeStack.length > 0) { + return this._inputTypeStack[this._inputTypeStack.length - 1]; + } + } + + getParentInputType() { + if (this._inputTypeStack.length > 1) { + return this._inputTypeStack[this._inputTypeStack.length - 2]; + } + } + + getFieldDef() { + if (this._fieldDefStack.length > 0) { + return this._fieldDefStack[this._fieldDefStack.length - 1]; + } + } + + getDefaultValue() { + if (this._defaultValueStack.length > 0) { + return this._defaultValueStack[this._defaultValueStack.length - 1]; + } + } + + getDirective() { + return this._directive; + } + + getArgument() { + return this._argument; + } + + getEnumValue() { + return this._enumValue; + } + + enter(node) { + const schema = this._schema; // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: { + const namedType = (0, _definition.getNamedType)(this.getType()); + + this._parentTypeStack.push( + (0, _definition.isCompositeType)(namedType) ? namedType : undefined, + ); + + break; + } + + case _kinds.Kind.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + + if (parentType) { + fieldDef = this._getFieldDef(schema, parentType, node); + + if (fieldDef) { + fieldType = fieldDef.type; + } + } + + this._fieldDefStack.push(fieldDef); + + this._typeStack.push( + (0, _definition.isOutputType)(fieldType) ? fieldType : undefined, + ); + + break; + } + + case _kinds.Kind.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + + case _kinds.Kind.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + + this._typeStack.push( + (0, _definition.isObjectType)(rootType) ? rootType : undefined, + ); + + break; + } + + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) + : (0, _definition.getNamedType)(this.getType()); + + this._typeStack.push( + (0, _definition.isOutputType)(outputType) ? outputType : undefined, + ); + + break; + } + + case _kinds.Kind.VARIABLE_DEFINITION: { + const inputType = (0, _typeFromAST.typeFromAST)(schema, node.type); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputType) ? inputType : undefined, + ); + + break; + } + + case _kinds.Kind.ARGUMENT: { + var _this$getDirective; + + let argDef; + let argType; + const fieldOrDirective = + (_this$getDirective = this.getDirective()) !== null && + _this$getDirective !== void 0 + ? _this$getDirective + : this.getFieldDef(); + + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find( + (arg) => arg.name === node.name.value, + ); + + if (argDef) { + argType = argDef.type; + } + } + + this._argument = argDef; + + this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(argType) ? argType : undefined, + ); + + break; + } + + case _kinds.Kind.LIST: { + const listType = (0, _definition.getNullableType)(this.getInputType()); + const itemType = (0, _definition.isListType)(listType) + ? listType.ofType + : listType; // List positions never have a default value. + + this._defaultValueStack.push(undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(itemType) ? itemType : undefined, + ); + + break; + } + + case _kinds.Kind.OBJECT_FIELD: { + const objectType = (0, _definition.getNamedType)(this.getInputType()); + let inputFieldType; + let inputField; + + if ((0, _definition.isInputObjectType)(objectType)) { + inputField = objectType.getFields()[node.name.value]; + + if (inputField) { + inputFieldType = inputField.type; + } + } + + this._defaultValueStack.push( + inputField ? inputField.defaultValue : undefined, + ); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputFieldType) + ? inputFieldType + : undefined, + ); - for (const typeArg of typeField.args) { - const argName = typeArg.name; - const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); + break; + } - if (!ifaceArg && (0, _definition.isRequiredArgument)(typeArg)) { - context.reportError( - `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, - [typeArg.astNode, ifaceField.astNode], - ); + case _kinds.Kind.ENUM: { + const enumType = (0, _definition.getNamedType)(this.getInputType()); + let enumValue; + + if ((0, _definition.isEnumType)(enumType)) { + enumValue = enumType.getValue(node.value); + } + + this._enumValue = enumValue; + break; } + + default: // Ignore other nodes } } -} -function validateTypeImplementsAncestors(context, type, iface) { - const ifaceInterfaces = type.getInterfaces(); + leave(node) { + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: + this._parentTypeStack.pop(); - for (const transitive of iface.getInterfaces()) { - if (!ifaceInterfaces.includes(transitive)) { - context.reportError( - transitive === type - ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` - : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, - [ - ...getAllImplementsInterfaceNodes(iface, transitive), - ...getAllImplementsInterfaceNodes(type, iface), - ], - ); - } - } -} + break; -function validateUnionMembers(context, union) { - const memberTypes = union.getTypes(); + case _kinds.Kind.FIELD: + this._fieldDefStack.pop(); - if (memberTypes.length === 0) { - context.reportError( - `Union type ${union.name} must define one or more member types.`, - [union.astNode, ...union.extensionASTNodes], - ); - } + this._typeStack.pop(); - const includedTypeNames = Object.create(null); + break; - for (const memberType of memberTypes) { - if (includedTypeNames[memberType.name]) { - context.reportError( - `Union type ${union.name} can only include type ${memberType.name} once.`, - getUnionMemberTypeNodes(union, memberType.name), - ); - continue; - } + case _kinds.Kind.DIRECTIVE: + this._directive = null; + break; - includedTypeNames[memberType.name] = true; + case _kinds.Kind.OPERATION_DEFINITION: + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: + this._typeStack.pop(); - if (!(0, _definition.isObjectType)(memberType)) { - context.reportError( - `Union type ${union.name} can only include Object types, ` + - `it cannot include ${(0, _inspect.inspect)(memberType)}.`, - getUnionMemberTypeNodes(union, String(memberType)), - ); - } - } -} + break; -function validateEnumValues(context, enumType) { - const enumValues = enumType.getValues(); + case _kinds.Kind.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); - if (enumValues.length === 0) { - context.reportError( - `Enum type ${enumType.name} must define one or more values.`, - [enumType.astNode, ...enumType.extensionASTNodes], - ); - } + break; - for (const enumValue of enumValues) { - // Ensure valid name. - validateName(context, enumValue); - } -} + case _kinds.Kind.ARGUMENT: + this._argument = null; -function validateInputFields(context, inputObj) { - const fields = Object.values(inputObj.getFields()); + this._defaultValueStack.pop(); - if (fields.length === 0) { - context.reportError( - `Input Object type ${inputObj.name} must define one or more fields.`, - [inputObj.astNode, ...inputObj.extensionASTNodes], - ); - } // Ensure the arguments are valid + this._inputTypeStack.pop(); - for (const field of fields) { - // Ensure they are named correctly. - validateName(context, field); // Ensure the type is an input type + break; - if (!(0, _definition.isInputType)(field.type)) { - var _field$astNode2; + case _kinds.Kind.LIST: + case _kinds.Kind.OBJECT_FIELD: + this._defaultValueStack.pop(); - context.reportError( - `The type of ${inputObj.name}.${field.name} must be Input Type ` + - `but got: ${(0, _inspect.inspect)(field.type)}.`, - (_field$astNode2 = field.astNode) === null || _field$astNode2 === void 0 - ? void 0 - : _field$astNode2.type, - ); - } + this._inputTypeStack.pop(); - if ( - (0, _definition.isRequiredInputField)(field) && - field.deprecationReason != null - ) { - var _field$astNode3; + break; - context.reportError( - `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, - [ - getDeprecatedDirectiveNode(field.astNode), - (_field$astNode3 = field.astNode) === null || - _field$astNode3 === void 0 - ? void 0 - : _field$astNode3.type, - ], - ); + case _kinds.Kind.ENUM: + this._enumValue = null; + break; + + default: // Ignore other nodes } } } -function createInputObjectCircularRefsValidator(context) { - // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. - // Tracks already visited types to maintain O(N) and to ensure that cycles - // are not redundantly reported. - const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors +exports.TypeInfo = TypeInfo; - const fieldPath = []; // Position in the type path +/** + * Not exactly the same as the executor's definition of getFieldDef, in this + * statically evaluated environment we do not always have an Object type, + * and need to handle Interface and Union types. + */ +function getFieldDef(schema, parentType, fieldNode) { + const name = fieldNode.name.value; - const fieldPathIndexByTypeName = Object.create(null); - return detectCycleRecursive; // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle was found but continues to explore - // the graph to find all possible cycles. + if ( + name === _introspection.SchemaMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.SchemaMetaFieldDef; + } - function detectCycleRecursive(inputObj) { - if (visitedTypes[inputObj.name]) { - return; - } + if ( + name === _introspection.TypeMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.TypeMetaFieldDef; + } - visitedTypes[inputObj.name] = true; - fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; - const fields = Object.values(inputObj.getFields()); + if ( + name === _introspection.TypeNameMetaFieldDef.name && + (0, _definition.isCompositeType)(parentType) + ) { + return _introspection.TypeNameMetaFieldDef; + } - for (const field of fields) { - if ( - (0, _definition.isNonNullType)(field.type) && - (0, _definition.isInputObjectType)(field.type.ofType) - ) { - const fieldType = field.type.ofType; - const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; - fieldPath.push(field); + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + return parentType.getFields()[name]; + } +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ - if (cycleIndex === undefined) { - detectCycleRecursive(fieldType); - } else { - const cyclePath = fieldPath.slice(cycleIndex); - const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); - context.reportError( - `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, - cyclePath.map((fieldObj) => fieldObj.astNode), - ); +function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).enter; + + if (fn) { + const result = fn.apply(visitor, args); + + if (result !== undefined) { + typeInfo.leave(node); + + if ((0, _ast.isNode)(result)) { + typeInfo.enter(result); + } } - fieldPath.pop(); + return result; } - } + }, - fieldPathIndexByTypeName[inputObj.name] = undefined; - } + leave(...args) { + const node = args[0]; + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).leave; + let result; + + if (fn) { + result = fn.apply(visitor, args); + } + + typeInfo.leave(node); + return result; + }, + }; } -function getAllImplementsInterfaceNodes(type, iface) { - const { astNode, extensionASTNodes } = type; - const nodes = - astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 - return nodes - .flatMap((typeNode) => { - var _typeNode$interfaces; +/***/ }), - return ( - /* c8 ignore next */ - (_typeNode$interfaces = typeNode.interfaces) !== null && - _typeNode$interfaces !== void 0 - ? _typeNode$interfaces - : [] - ); - }) - .filter((ifaceNode) => ifaceNode.name.value === iface.name); -} +/***/ 63786: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -function getUnionMemberTypeNodes(union, typeName) { - const { astNode, extensionASTNodes } = union; - const nodes = - astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 +"use strict"; - return nodes - .flatMap((unionNode) => { - var _unionNode$types; - return ( - /* c8 ignore next */ - (_unionNode$types = unionNode.types) !== null && - _unionNode$types !== void 0 - ? _unionNode$types - : [] - ); - }) - .filter((typeNode) => typeNode.name.value === typeName); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidName = assertValidName; +exports.isValidNameError = isValidNameError; + +var _devAssert = __nccwpck_require__(88054); + +var _GraphQLError = __nccwpck_require__(93192); + +var _assertName = __nccwpck_require__(31752); + +/* c8 ignore start */ + +/** + * Upholds the spec rules about naming. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ +function assertValidName(name) { + const error = isValidNameError(name); + + if (error) { + throw error; + } + + return name; } +/** + * Returns an Error if a name is invalid. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ -function getDeprecatedDirectiveNode(definitionNode) { - var _definitionNode$direc; +function isValidNameError(name) { + typeof name === 'string' || + (0, _devAssert.devAssert)(false, 'Expected name to be a string.'); - return definitionNode === null || definitionNode === void 0 - ? void 0 - : (_definitionNode$direc = definitionNode.directives) === null || - _definitionNode$direc === void 0 - ? void 0 - : _definitionNode$direc.find( - (node) => - node.name.value === _directives.GraphQLDeprecatedDirective.name, - ); + if (name.startsWith('__')) { + return new _GraphQLError.GraphQLError( + `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, + ); + } + + try { + (0, _assertName.assertName)(name); + } catch (error) { + return error; + } } +/* c8 ignore stop */ /***/ }), -/***/ 86215: +/***/ 61402: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -30700,483 +54567,713 @@ function getDeprecatedDirectiveNode(definitionNode) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.TypeInfo = void 0; -exports.visitWithTypeInfo = visitWithTypeInfo; +exports.astFromValue = astFromValue; -var _ast = __nccwpck_require__(22744); +var _inspect = __nccwpck_require__(85856); -var _kinds = __nccwpck_require__(36578); +var _invariant = __nccwpck_require__(31338); -var _visitor = __nccwpck_require__(78625); +var _isIterableObject = __nccwpck_require__(63522); -var _definition = __nccwpck_require__(82341); +var _isObjectLike = __nccwpck_require__(39453); -var _introspection = __nccwpck_require__(95678); +var _kinds = __nccwpck_require__(36096); -var _typeFromAST = __nccwpck_require__(32901); +var _definition = __nccwpck_require__(57741); + +var _scalars = __nccwpck_require__(94420); /** - * TypeInfo is a utility class which, given a GraphQL schema, can keep track - * of the current field and type definitions at any point in a GraphQL document - * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * */ -class TypeInfo { - constructor( - schema, - /** - * Initial type may be provided in rare cases to facilitate traversals - * beginning somewhere other than documents. - */ - initialType, - /** @deprecated will be removed in 17.0.0 */ - getFieldDefFn, - ) { - this._schema = schema; - this._typeStack = []; - this._parentTypeStack = []; - this._inputTypeStack = []; - this._fieldDefStack = []; - this._defaultValueStack = []; - this._directive = null; - this._argument = null; - this._enumValue = null; - this._getFieldDef = - getFieldDefFn !== null && getFieldDefFn !== void 0 - ? getFieldDefFn - : getFieldDef; +function astFromValue(value, type) { + if ((0, _definition.isNonNullType)(type)) { + const astValue = astFromValue(value, type.ofType); - if (initialType) { - if ((0, _definition.isInputType)(initialType)) { - this._inputTypeStack.push(initialType); - } + if ( + (astValue === null || astValue === void 0 ? void 0 : astValue.kind) === + _kinds.Kind.NULL + ) { + return null; + } - if ((0, _definition.isCompositeType)(initialType)) { - this._parentTypeStack.push(initialType); + return astValue; + } // only explicit null, not undefined, NaN + + if (value === null) { + return { + kind: _kinds.Kind.NULL, + }; + } // undefined + + if (value === undefined) { + return null; + } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if ((0, _isIterableObject.isIterableObject)(value)) { + const valuesNodes = []; + + for (const item of value) { + const itemNode = astFromValue(item, itemType); + + if (itemNode != null) { + valuesNodes.push(itemNode); + } } - if ((0, _definition.isOutputType)(initialType)) { - this._typeStack.push(initialType); + return { + kind: _kinds.Kind.LIST, + values: valuesNodes, + }; + } + + return astFromValue(value, itemType); + } // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(value)) { + return null; + } + + const fieldNodes = []; + + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + + if (fieldValue) { + fieldNodes.push({ + kind: _kinds.Kind.OBJECT_FIELD, + name: { + kind: _kinds.Kind.NAME, + value: field.name, + }, + value: fieldValue, + }); } } - } - get [Symbol.toStringTag]() { - return 'TypeInfo'; + return { + kind: _kinds.Kind.OBJECT, + fields: fieldNodes, + }; } - getType() { - if (this._typeStack.length > 0) { - return this._typeStack[this._typeStack.length - 1]; + if ((0, _definition.isLeafType)(type)) { + // Since value is an internally represented value, it must be serialized + // to an externally represented value before converting into an AST. + const serialized = type.serialize(value); + + if (serialized == null) { + return null; + } // Others serialize based on their corresponding JavaScript scalar types. + + if (typeof serialized === 'boolean') { + return { + kind: _kinds.Kind.BOOLEAN, + value: serialized, + }; + } // JavaScript numbers can be Int or Float values. + + if (typeof serialized === 'number' && Number.isFinite(serialized)) { + const stringNum = String(serialized); + return integerStringRegExp.test(stringNum) + ? { + kind: _kinds.Kind.INT, + value: stringNum, + } + : { + kind: _kinds.Kind.FLOAT, + value: stringNum, + }; } - } - getParentType() { - if (this._parentTypeStack.length > 0) { - return this._parentTypeStack[this._parentTypeStack.length - 1]; - } - } + if (typeof serialized === 'string') { + // Enum types use Enum literals. + if ((0, _definition.isEnumType)(type)) { + return { + kind: _kinds.Kind.ENUM, + value: serialized, + }; + } // ID types can use Int literals. - getInputType() { - if (this._inputTypeStack.length > 0) { - return this._inputTypeStack[this._inputTypeStack.length - 1]; - } - } + if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) { + return { + kind: _kinds.Kind.INT, + value: serialized, + }; + } - getParentInputType() { - if (this._inputTypeStack.length > 1) { - return this._inputTypeStack[this._inputTypeStack.length - 2]; + return { + kind: _kinds.Kind.STRING, + value: serialized, + }; } - } - getFieldDef() { - if (this._fieldDefStack.length > 0) { - return this._fieldDefStack[this._fieldDefStack.length - 1]; - } + throw new TypeError( + `Cannot convert value to AST: ${(0, _inspect.inspect)(serialized)}.`, + ); } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. - getDefaultValue() { - if (this._defaultValueStack.length > 0) { - return this._defaultValueStack[this._defaultValueStack.length - 1]; - } - } + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ - getDirective() { - return this._directive; - } +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; - getArgument() { - return this._argument; - } - getEnumValue() { - return this._enumValue; - } +/***/ }), - enter(node) { - const schema = this._schema; // Note: many of the types below are explicitly typed as "unknown" to drop - // any assumptions of a valid schema to ensure runtime types are properly - // checked before continuing since TypeInfo is used as part of validation - // which occurs before guarantees of schema and document validity. +/***/ 22079: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - switch (node.kind) { - case _kinds.Kind.SELECTION_SET: { - const namedType = (0, _definition.getNamedType)(this.getType()); +"use strict"; - this._parentTypeStack.push( - (0, _definition.isCompositeType)(namedType) ? namedType : undefined, - ); - break; - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.buildASTSchema = buildASTSchema; +exports.buildSchema = buildSchema; - case _kinds.Kind.FIELD: { - const parentType = this.getParentType(); - let fieldDef; - let fieldType; +var _devAssert = __nccwpck_require__(88054); - if (parentType) { - fieldDef = this._getFieldDef(schema, parentType, node); +var _kinds = __nccwpck_require__(36096); - if (fieldDef) { - fieldType = fieldDef.type; - } - } +var _parser = __nccwpck_require__(8515); - this._fieldDefStack.push(fieldDef); +var _directives = __nccwpck_require__(50828); - this._typeStack.push( - (0, _definition.isOutputType)(fieldType) ? fieldType : undefined, - ); +var _schema = __nccwpck_require__(354); - break; - } +var _validate = __nccwpck_require__(16405); - case _kinds.Kind.DIRECTIVE: - this._directive = schema.getDirective(node.name.value); - break; +var _extendSchema = __nccwpck_require__(28218); - case _kinds.Kind.OPERATION_DEFINITION: { - const rootType = schema.getRootType(node.operation); +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +function buildASTSchema(documentAST, options) { + (documentAST != null && documentAST.kind === _kinds.Kind.DOCUMENT) || + (0, _devAssert.devAssert)(false, 'Must provide valid Document AST.'); - this._typeStack.push( - (0, _definition.isObjectType)(rootType) ? rootType : undefined, - ); + if ( + (options === null || options === void 0 ? void 0 : options.assumeValid) !== + true && + (options === null || options === void 0 + ? void 0 + : options.assumeValidSDL) !== true + ) { + (0, _validate.assertValidSDL)(documentAST); + } - break; - } + const emptySchemaConfig = { + description: undefined, + types: [], + directives: [], + extensions: Object.create(null), + extensionASTNodes: [], + assumeValid: false, + }; + const config = (0, _extendSchema.extendSchemaImpl)( + emptySchemaConfig, + documentAST, + options, + ); - case _kinds.Kind.INLINE_FRAGMENT: - case _kinds.Kind.FRAGMENT_DEFINITION: { - const typeConditionAST = node.typeCondition; - const outputType = typeConditionAST - ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) - : (0, _definition.getNamedType)(this.getType()); + if (config.astNode == null) { + for (const type of config.types) { + switch (type.name) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + case 'Query': + // @ts-expect-error validated in `validateSchema` + config.query = type; + break; - this._typeStack.push( - (0, _definition.isOutputType)(outputType) ? outputType : undefined, - ); + case 'Mutation': + // @ts-expect-error validated in `validateSchema` + config.mutation = type; + break; - break; + case 'Subscription': + // @ts-expect-error validated in `validateSchema` + config.subscription = type; + break; } + } + } - case _kinds.Kind.VARIABLE_DEFINITION: { - const inputType = (0, _typeFromAST.typeFromAST)(schema, node.type); - - this._inputTypeStack.push( - (0, _definition.isInputType)(inputType) ? inputType : undefined, - ); - - break; - } + const directives = [ + ...config.directives, // If specified directives were not explicitly declared, add them. + ..._directives.specifiedDirectives.filter((stdDirective) => + config.directives.every( + (directive) => directive.name !== stdDirective.name, + ), + ), + ]; + return new _schema.GraphQLSchema({ ...config, directives }); +} +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ - case _kinds.Kind.ARGUMENT: { - var _this$getDirective; +function buildSchema(source, options) { + const document = (0, _parser.parse)(source, { + noLocation: + options === null || options === void 0 ? void 0 : options.noLocation, + allowLegacyFragmentVariables: + options === null || options === void 0 + ? void 0 + : options.allowLegacyFragmentVariables, + }); + return buildASTSchema(document, { + assumeValidSDL: + options === null || options === void 0 ? void 0 : options.assumeValidSDL, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); +} - let argDef; - let argType; - const fieldOrDirective = - (_this$getDirective = this.getDirective()) !== null && - _this$getDirective !== void 0 - ? _this$getDirective - : this.getFieldDef(); - if (fieldOrDirective) { - argDef = fieldOrDirective.args.find( - (arg) => arg.name === node.name.value, - ); +/***/ }), - if (argDef) { - argType = argDef.type; - } - } +/***/ 27828: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - this._argument = argDef; +"use strict"; - this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); - this._inputTypeStack.push( - (0, _definition.isInputType)(argType) ? argType : undefined, - ); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.buildClientSchema = buildClientSchema; - break; - } +var _devAssert = __nccwpck_require__(88054); - case _kinds.Kind.LIST: { - const listType = (0, _definition.getNullableType)(this.getInputType()); - const itemType = (0, _definition.isListType)(listType) - ? listType.ofType - : listType; // List positions never have a default value. +var _inspect = __nccwpck_require__(85856); - this._defaultValueStack.push(undefined); +var _isObjectLike = __nccwpck_require__(39453); - this._inputTypeStack.push( - (0, _definition.isInputType)(itemType) ? itemType : undefined, - ); +var _keyValMap = __nccwpck_require__(63345); - break; - } +var _parser = __nccwpck_require__(8515); - case _kinds.Kind.OBJECT_FIELD: { - const objectType = (0, _definition.getNamedType)(this.getInputType()); - let inputFieldType; - let inputField; +var _definition = __nccwpck_require__(57741); - if ((0, _definition.isInputObjectType)(objectType)) { - inputField = objectType.getFields()[node.name.value]; +var _directives = __nccwpck_require__(50828); - if (inputField) { - inputFieldType = inputField.type; - } - } +var _introspection = __nccwpck_require__(8077); - this._defaultValueStack.push( - inputField ? inputField.defaultValue : undefined, - ); +var _scalars = __nccwpck_require__(94420); - this._inputTypeStack.push( - (0, _definition.isInputType)(inputFieldType) - ? inputFieldType - : undefined, - ); +var _schema = __nccwpck_require__(354); - break; - } +var _valueFromAST = __nccwpck_require__(71964); - case _kinds.Kind.ENUM: { - const enumType = (0, _definition.getNamedType)(this.getInputType()); - let enumValue; +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "parse" or "serialize" functions or any other + * server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ +function buildClientSchema(introspection, options) { + ((0, _isObjectLike.isObjectLike)(introspection) && + (0, _isObjectLike.isObjectLike)(introspection.__schema)) || + (0, _devAssert.devAssert)( + false, + `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${(0, + _inspect.inspect)(introspection)}.`, + ); // Get the schema from the introspection result. - if ((0, _definition.isEnumType)(enumType)) { - enumValue = enumType.getValue(node.value); - } + const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each. - this._enumValue = enumValue; - break; - } + const typeMap = (0, _keyValMap.keyValMap)( + schemaIntrospection.types, + (typeIntrospection) => typeIntrospection.name, + (typeIntrospection) => buildType(typeIntrospection), + ); // Include standard types only if they are used. - default: // Ignore other nodes + for (const stdType of [ + ..._scalars.specifiedScalarTypes, + ..._introspection.introspectionTypes, + ]) { + if (typeMap[stdType.name]) { + typeMap[stdType.name] = stdType; } - } + } // Get the root Query, Mutation, and Subscription types. - leave(node) { - switch (node.kind) { - case _kinds.Kind.SELECTION_SET: - this._parentTypeStack.pop(); + const queryType = schemaIntrospection.queryType + ? getObjectType(schemaIntrospection.queryType) + : null; + const mutationType = schemaIntrospection.mutationType + ? getObjectType(schemaIntrospection.mutationType) + : null; + const subscriptionType = schemaIntrospection.subscriptionType + ? getObjectType(schemaIntrospection.subscriptionType) + : null; // Get the directives supported by Introspection, assuming empty-set if + // directives were not queried for. - break; + const directives = schemaIntrospection.directives + ? schemaIntrospection.directives.map(buildDirective) + : []; // Then produce and return a Schema with these types. - case _kinds.Kind.FIELD: - this._fieldDefStack.pop(); + return new _schema.GraphQLSchema({ + description: schemaIntrospection.description, + query: queryType, + mutation: mutationType, + subscription: subscriptionType, + types: Object.values(typeMap), + directives, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); // Given a type reference in introspection, return the GraphQLType instance. + // preferring cached instances before building new instances. - this._typeStack.pop(); + function getType(typeRef) { + if (typeRef.kind === _introspection.TypeKind.LIST) { + const itemRef = typeRef.ofType; - break; + if (!itemRef) { + throw new Error('Decorated type deeper than introspection query.'); + } - case _kinds.Kind.DIRECTIVE: - this._directive = null; - break; + return new _definition.GraphQLList(getType(itemRef)); + } - case _kinds.Kind.OPERATION_DEFINITION: - case _kinds.Kind.INLINE_FRAGMENT: - case _kinds.Kind.FRAGMENT_DEFINITION: - this._typeStack.pop(); + if (typeRef.kind === _introspection.TypeKind.NON_NULL) { + const nullableRef = typeRef.ofType; - break; + if (!nullableRef) { + throw new Error('Decorated type deeper than introspection query.'); + } - case _kinds.Kind.VARIABLE_DEFINITION: - this._inputTypeStack.pop(); + const nullableType = getType(nullableRef); + return new _definition.GraphQLNonNull( + (0, _definition.assertNullableType)(nullableType), + ); + } - break; + return getNamedType(typeRef); + } - case _kinds.Kind.ARGUMENT: - this._argument = null; + function getNamedType(typeRef) { + const typeName = typeRef.name; - this._defaultValueStack.pop(); + if (!typeName) { + throw new Error( + `Unknown type reference: ${(0, _inspect.inspect)(typeRef)}.`, + ); + } - this._inputTypeStack.pop(); + const type = typeMap[typeName]; - break; + if (!type) { + throw new Error( + `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`, + ); + } - case _kinds.Kind.LIST: - case _kinds.Kind.OBJECT_FIELD: - this._defaultValueStack.pop(); + return type; + } - this._inputTypeStack.pop(); + function getObjectType(typeRef) { + return (0, _definition.assertObjectType)(getNamedType(typeRef)); + } - break; + function getInterfaceType(typeRef) { + return (0, _definition.assertInterfaceType)(getNamedType(typeRef)); + } // Given a type's introspection result, construct the correct + // GraphQLType instance. - case _kinds.Kind.ENUM: - this._enumValue = null; - break; + function buildType(type) { + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain + if (type != null && type.name != null && type.kind != null) { + // FIXME: Properly type IntrospectionType, it's a breaking change so fix in v17 + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check + switch (type.kind) { + case _introspection.TypeKind.SCALAR: + return buildScalarDef(type); - default: // Ignore other nodes - } - } -} + case _introspection.TypeKind.OBJECT: + return buildObjectDef(type); -exports.TypeInfo = TypeInfo; + case _introspection.TypeKind.INTERFACE: + return buildInterfaceDef(type); -/** - * Not exactly the same as the executor's definition of getFieldDef, in this - * statically evaluated environment we do not always have an Object type, - * and need to handle Interface and Union types. - */ -function getFieldDef(schema, parentType, fieldNode) { - const name = fieldNode.name.value; + case _introspection.TypeKind.UNION: + return buildUnionDef(type); - if ( - name === _introspection.SchemaMetaFieldDef.name && - schema.getQueryType() === parentType - ) { - return _introspection.SchemaMetaFieldDef; - } + case _introspection.TypeKind.ENUM: + return buildEnumDef(type); - if ( - name === _introspection.TypeMetaFieldDef.name && - schema.getQueryType() === parentType - ) { - return _introspection.TypeMetaFieldDef; - } + case _introspection.TypeKind.INPUT_OBJECT: + return buildInputObjectDef(type); + } + } - if ( - name === _introspection.TypeNameMetaFieldDef.name && - (0, _definition.isCompositeType)(parentType) - ) { - return _introspection.TypeNameMetaFieldDef; + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`, + ); } - if ( - (0, _definition.isObjectType)(parentType) || - (0, _definition.isInterfaceType)(parentType) - ) { - return parentType.getFields()[name]; + function buildScalarDef(scalarIntrospection) { + return new _definition.GraphQLScalarType({ + name: scalarIntrospection.name, + description: scalarIntrospection.description, + specifiedByURL: scalarIntrospection.specifiedByURL, + }); } -} -/** - * Creates a new visitor instance which maintains a provided TypeInfo instance - * along with visiting visitor. - */ - -function visitWithTypeInfo(typeInfo, visitor) { - return { - enter(...args) { - const node = args[0]; - typeInfo.enter(node); - const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).enter; - if (fn) { - const result = fn.apply(visitor, args); - - if (result !== undefined) { - typeInfo.leave(node); + function buildImplementationsList(implementingIntrospection) { + // TODO: Temporary workaround until GraphQL ecosystem will fully support + // 'interfaces' on interface types. + if ( + implementingIntrospection.interfaces === null && + implementingIntrospection.kind === _introspection.TypeKind.INTERFACE + ) { + return []; + } - if ((0, _ast.isNode)(result)) { - typeInfo.enter(result); - } - } + if (!implementingIntrospection.interfaces) { + const implementingIntrospectionStr = (0, _inspect.inspect)( + implementingIntrospection, + ); + throw new Error( + `Introspection result missing interfaces: ${implementingIntrospectionStr}.`, + ); + } - return result; - } - }, + return implementingIntrospection.interfaces.map(getInterfaceType); + } - leave(...args) { - const node = args[0]; - const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).leave; - let result; + function buildObjectDef(objectIntrospection) { + return new _definition.GraphQLObjectType({ + name: objectIntrospection.name, + description: objectIntrospection.description, + interfaces: () => buildImplementationsList(objectIntrospection), + fields: () => buildFieldDefMap(objectIntrospection), + }); + } - if (fn) { - result = fn.apply(visitor, args); - } + function buildInterfaceDef(interfaceIntrospection) { + return new _definition.GraphQLInterfaceType({ + name: interfaceIntrospection.name, + description: interfaceIntrospection.description, + interfaces: () => buildImplementationsList(interfaceIntrospection), + fields: () => buildFieldDefMap(interfaceIntrospection), + }); + } - typeInfo.leave(node); - return result; - }, - }; -} + function buildUnionDef(unionIntrospection) { + if (!unionIntrospection.possibleTypes) { + const unionIntrospectionStr = (0, _inspect.inspect)(unionIntrospection); + throw new Error( + `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`, + ); + } + return new _definition.GraphQLUnionType({ + name: unionIntrospection.name, + description: unionIntrospection.description, + types: () => unionIntrospection.possibleTypes.map(getObjectType), + }); + } -/***/ }), + function buildEnumDef(enumIntrospection) { + if (!enumIntrospection.enumValues) { + const enumIntrospectionStr = (0, _inspect.inspect)(enumIntrospection); + throw new Error( + `Introspection result missing enumValues: ${enumIntrospectionStr}.`, + ); + } -/***/ 21570: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return new _definition.GraphQLEnumType({ + name: enumIntrospection.name, + description: enumIntrospection.description, + values: (0, _keyValMap.keyValMap)( + enumIntrospection.enumValues, + (valueIntrospection) => valueIntrospection.name, + (valueIntrospection) => ({ + description: valueIntrospection.description, + deprecationReason: valueIntrospection.deprecationReason, + }), + ), + }); + } -"use strict"; + function buildInputObjectDef(inputObjectIntrospection) { + if (!inputObjectIntrospection.inputFields) { + const inputObjectIntrospectionStr = (0, _inspect.inspect)( + inputObjectIntrospection, + ); + throw new Error( + `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`, + ); + } + return new _definition.GraphQLInputObjectType({ + name: inputObjectIntrospection.name, + description: inputObjectIntrospection.description, + fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), + }); + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.assertValidName = assertValidName; -exports.isValidNameError = isValidNameError; + function buildFieldDefMap(typeIntrospection) { + if (!typeIntrospection.fields) { + throw new Error( + `Introspection result missing fields: ${(0, _inspect.inspect)( + typeIntrospection, + )}.`, + ); + } -var _devAssert = __nccwpck_require__(6205); + return (0, _keyValMap.keyValMap)( + typeIntrospection.fields, + (fieldIntrospection) => fieldIntrospection.name, + buildField, + ); + } -var _GraphQLError = __nccwpck_require__(442); + function buildField(fieldIntrospection) { + const type = getType(fieldIntrospection.type); -var _assertName = __nccwpck_require__(19322); + if (!(0, _definition.isOutputType)(type)) { + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Introspection must provide output type for fields, but received: ${typeStr}.`, + ); + } -/* c8 ignore start */ + if (!fieldIntrospection.args) { + const fieldIntrospectionStr = (0, _inspect.inspect)(fieldIntrospection); + throw new Error( + `Introspection result missing field args: ${fieldIntrospectionStr}.`, + ); + } -/** - * Upholds the spec rules about naming. - * @deprecated Please use `assertName` instead. Will be removed in v17 - */ -function assertValidName(name) { - const error = isValidNameError(name); + return { + description: fieldIntrospection.description, + deprecationReason: fieldIntrospection.deprecationReason, + type, + args: buildInputValueDefMap(fieldIntrospection.args), + }; + } - if (error) { - throw error; + function buildInputValueDefMap(inputValueIntrospections) { + return (0, _keyValMap.keyValMap)( + inputValueIntrospections, + (inputValue) => inputValue.name, + buildInputValue, + ); } - return name; -} -/** - * Returns an Error if a name is invalid. - * @deprecated Please use `assertName` instead. Will be removed in v17 - */ + function buildInputValue(inputValueIntrospection) { + const type = getType(inputValueIntrospection.type); -function isValidNameError(name) { - typeof name === 'string' || - (0, _devAssert.devAssert)(false, 'Expected name to be a string.'); + if (!(0, _definition.isInputType)(type)) { + const typeStr = (0, _inspect.inspect)(type); + throw new Error( + `Introspection must provide input type for arguments, but received: ${typeStr}.`, + ); + } - if (name.startsWith('__')) { - return new _GraphQLError.GraphQLError( - `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, - ); + const defaultValue = + inputValueIntrospection.defaultValue != null + ? (0, _valueFromAST.valueFromAST)( + (0, _parser.parseValue)(inputValueIntrospection.defaultValue), + type, + ) + : undefined; + return { + description: inputValueIntrospection.description, + type, + defaultValue, + deprecationReason: inputValueIntrospection.deprecationReason, + }; } - try { - (0, _assertName.assertName)(name); - } catch (error) { - return error; + function buildDirective(directiveIntrospection) { + if (!directiveIntrospection.args) { + const directiveIntrospectionStr = (0, _inspect.inspect)( + directiveIntrospection, + ); + throw new Error( + `Introspection result missing directive args: ${directiveIntrospectionStr}.`, + ); + } + + if (!directiveIntrospection.locations) { + const directiveIntrospectionStr = (0, _inspect.inspect)( + directiveIntrospection, + ); + throw new Error( + `Introspection result missing directive locations: ${directiveIntrospectionStr}.`, + ); + } + + return new _directives.GraphQLDirective({ + name: directiveIntrospection.name, + description: directiveIntrospection.description, + isRepeatable: directiveIntrospection.isRepeatable, + locations: directiveIntrospection.locations.slice(), + args: buildInputValueDefMap(directiveIntrospection.args), + }); } } -/* c8 ignore stop */ /***/ }), -/***/ 14268: +/***/ 47416: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -31185,174 +55282,180 @@ function isValidNameError(name) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.astFromValue = astFromValue; +exports.coerceInputValue = coerceInputValue; -var _inspect = __nccwpck_require__(70715); +var _didYouMean = __nccwpck_require__(4475); -var _invariant = __nccwpck_require__(28864); +var _inspect = __nccwpck_require__(85856); -var _isIterableObject = __nccwpck_require__(77306); +var _invariant = __nccwpck_require__(31338); -var _isObjectLike = __nccwpck_require__(46541); +var _isIterableObject = __nccwpck_require__(63522); -var _kinds = __nccwpck_require__(36578); +var _isObjectLike = __nccwpck_require__(39453); -var _definition = __nccwpck_require__(82341); +var _Path = __nccwpck_require__(3585); -var _scalars = __nccwpck_require__(41963); +var _printPathArray = __nccwpck_require__(36956); + +var _suggestionList = __nccwpck_require__(11642); + +var _GraphQLError = __nccwpck_require__(93192); + +var _definition = __nccwpck_require__(57741); /** - * Produces a GraphQL Value AST given a JavaScript object. - * Function will match JavaScript/JSON values to GraphQL AST schema format - * by using suggested GraphQLInputType. For example: - * - * astFromValue("value", GraphQLString) - * - * A GraphQL type must be provided, which will be used to interpret different - * JavaScript values. - * - * | JSON Value | GraphQL Value | - * | ------------- | -------------------- | - * | Object | Input Object | - * | Array | List | - * | Boolean | Boolean | - * | String | String / Enum Value | - * | Number | Int / Float | - * | Unknown | Enum Value | - * | null | NullValue | - * + * Coerces a JavaScript value given a GraphQL Input Type. */ -function astFromValue(value, type) { - if ((0, _definition.isNonNullType)(type)) { - const astValue = astFromValue(value, type.ofType); +function coerceInputValue(inputValue, type, onError = defaultOnError) { + return coerceInputValueImpl(inputValue, type, onError, undefined); +} - if ( - (astValue === null || astValue === void 0 ? void 0 : astValue.kind) === - _kinds.Kind.NULL - ) { - return null; - } +function defaultOnError(path, invalidValue, error) { + let errorPrefix = 'Invalid value ' + (0, _inspect.inspect)(invalidValue); - return astValue; - } // only explicit null, not undefined, NaN + if (path.length > 0) { + errorPrefix += ` at "value${(0, _printPathArray.printPathArray)(path)}"`; + } - if (value === null) { - return { - kind: _kinds.Kind.NULL, - }; - } // undefined + error.message = errorPrefix + ': ' + error.message; + throw error; +} - if (value === undefined) { +function coerceInputValueImpl(inputValue, type, onError, path) { + if ((0, _definition.isNonNullType)(type)) { + if (inputValue != null) { + return coerceInputValueImpl(inputValue, type.ofType, onError, path); + } + + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected non-nullable type "${(0, _inspect.inspect)( + type, + )}" not to be null.`, + ), + ); + return; + } + + if (inputValue == null) { + // Explicitly return the value null. return null; - } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but - // the value is not an array, convert the value using the list's item type. + } if ((0, _definition.isListType)(type)) { const itemType = type.ofType; - if ((0, _isIterableObject.isIterableObject)(value)) { - const valuesNodes = []; - - for (const item of value) { - const itemNode = astFromValue(item, itemType); + if ((0, _isIterableObject.isIterableObject)(inputValue)) { + return Array.from(inputValue, (itemValue, index) => { + const itemPath = (0, _Path.addPath)(path, index, undefined); + return coerceInputValueImpl(itemValue, itemType, onError, itemPath); + }); + } // Lists accept a non-list value as a list of one. - if (itemNode != null) { - valuesNodes.push(itemNode); - } - } + return [coerceInputValueImpl(inputValue, itemType, onError, path)]; + } - return { - kind: _kinds.Kind.LIST, - values: valuesNodes, - }; + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(inputValue)) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}" to be an object.`, + ), + ); + return; } - return astFromValue(value, itemType); - } // Populate the fields of the input object by creating ASTs from each value - // in the JavaScript object according to the fields in the input type. + const coercedValue = {}; + const fieldDefs = type.getFields(); - if ((0, _definition.isInputObjectType)(type)) { - if (!(0, _isObjectLike.isObjectLike)(value)) { - return null; - } + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; - const fieldNodes = []; + if (fieldValue === undefined) { + if (field.defaultValue !== undefined) { + coercedValue[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + const typeStr = (0, _inspect.inspect)(field.type); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${field.name}" of required type "${typeStr}" was not provided.`, + ), + ); + } - for (const field of Object.values(type.getFields())) { - const fieldValue = astFromValue(value[field.name], field.type); + continue; + } - if (fieldValue) { - fieldNodes.push({ - kind: _kinds.Kind.OBJECT_FIELD, - name: { - kind: _kinds.Kind.NAME, - value: field.name, - }, - value: fieldValue, - }); + coercedValue[field.name] = coerceInputValueImpl( + fieldValue, + field.type, + onError, + (0, _Path.addPath)(path, field.name, type.name), + ); + } // Ensure every provided field is defined. + + for (const fieldName of Object.keys(inputValue)) { + if (!fieldDefs[fieldName]) { + const suggestions = (0, _suggestionList.suggestionList)( + fieldName, + Object.keys(type.getFields()), + ); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${fieldName}" is not defined by type "${type.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + ), + ); } } - return { - kind: _kinds.Kind.OBJECT, - fields: fieldNodes, - }; + return coercedValue; } if ((0, _definition.isLeafType)(type)) { - // Since value is an internally represented value, it must be serialized - // to an externally represented value before converting into an AST. - const serialized = type.serialize(value); - - if (serialized == null) { - return null; - } // Others serialize based on their corresponding JavaScript scalar types. + let parseResult; // Scalars and Enums determine if a input value is valid via parseValue(), + // which can throw to indicate failure. If it throws, maintain a reference + // to the original error. - if (typeof serialized === 'boolean') { - return { - kind: _kinds.Kind.BOOLEAN, - value: serialized, - }; - } // JavaScript numbers can be Int or Float values. + try { + parseResult = type.parseValue(inputValue); + } catch (error) { + if (error instanceof _GraphQLError.GraphQLError) { + onError((0, _Path.pathToArray)(path), inputValue, error); + } else { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}". ` + error.message, + { + originalError: error, + }, + ), + ); + } - if (typeof serialized === 'number' && Number.isFinite(serialized)) { - const stringNum = String(serialized); - return integerStringRegExp.test(stringNum) - ? { - kind: _kinds.Kind.INT, - value: stringNum, - } - : { - kind: _kinds.Kind.FLOAT, - value: stringNum, - }; + return; } - if (typeof serialized === 'string') { - // Enum types use Enum literals. - if ((0, _definition.isEnumType)(type)) { - return { - kind: _kinds.Kind.ENUM, - value: serialized, - }; - } // ID types can use Int literals. - - if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) { - return { - kind: _kinds.Kind.INT, - value: serialized, - }; - } - - return { - kind: _kinds.Kind.STRING, - value: serialized, - }; + if (parseResult === undefined) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError(`Expected type "${type.name}".`), + ); } - throw new TypeError( - `Cannot convert value to AST: ${(0, _inspect.inspect)(serialized)}.`, - ); + return parseResult; } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. @@ -31363,54 +55466,100 @@ function astFromValue(value, type) { 'Unexpected input type: ' + (0, _inspect.inspect)(type), ); } + + +/***/ }), + +/***/ 53841: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.concatAST = concatAST; + +var _kinds = __nccwpck_require__(36096); + /** - * IntValue: - * - NegativeSign? 0 - * - NegativeSign? NonZeroDigit ( Digit+ )? + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. */ +function concatAST(documents) { + const definitions = []; -const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; + for (const doc of documents) { + definitions.push(...doc.definitions); + } + + return { + kind: _kinds.Kind.DOCUMENT, + definitions, + }; +} /***/ }), -/***/ 81503: +/***/ 28218: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -"use strict"; +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.extendSchema = extendSchema; +exports.extendSchemaImpl = extendSchemaImpl; + +var _devAssert = __nccwpck_require__(88054); + +var _inspect = __nccwpck_require__(85856); + +var _invariant = __nccwpck_require__(31338); + +var _keyMap = __nccwpck_require__(22660); + +var _mapValue = __nccwpck_require__(83611); + +var _kinds = __nccwpck_require__(36096); +var _predicates = __nccwpck_require__(19007); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.buildASTSchema = buildASTSchema; -exports.buildSchema = buildSchema; +var _definition = __nccwpck_require__(57741); -var _devAssert = __nccwpck_require__(6205); +var _directives = __nccwpck_require__(50828); -var _kinds = __nccwpck_require__(36578); +var _introspection = __nccwpck_require__(8077); -var _parser = __nccwpck_require__(89937); +var _scalars = __nccwpck_require__(94420); -var _directives = __nccwpck_require__(27602); +var _schema = __nccwpck_require__(354); -var _schema = __nccwpck_require__(17287); +var _validate = __nccwpck_require__(16405); -var _validate = __nccwpck_require__(1581); +var _values = __nccwpck_require__(49106); -var _extendSchema = __nccwpck_require__(14691); +var _valueFromAST = __nccwpck_require__(71964); /** - * This takes the ast of a schema document produced by the parse function in - * src/language/parser.js. + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. * - * If no schema definition is provided, then it will look for types named Query, - * Mutation and Subscription. + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. * - * Given that AST it constructs a GraphQLSchema. The resulting schema - * has no resolve methods, so execution will use default resolvers. + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. */ -function buildASTSchema(documentAST, options) { +function extendSchema(schema, documentAST, options) { + (0, _schema.assertSchema)(schema); (documentAST != null && documentAST.kind === _kinds.Kind.DOCUMENT) || (0, _devAssert.devAssert)(false, 'Must provide valid Document AST.'); @@ -31421,477 +55570,747 @@ function buildASTSchema(documentAST, options) { ? void 0 : options.assumeValidSDL) !== true ) { - (0, _validate.assertValidSDL)(documentAST); + (0, _validate.assertValidSDLExtension)(documentAST, schema); } - const emptySchemaConfig = { - description: undefined, - types: [], - directives: [], - extensions: Object.create(null), - extensionASTNodes: [], - assumeValid: false, - }; - const config = (0, _extendSchema.extendSchemaImpl)( - emptySchemaConfig, - documentAST, - options, - ); + const schemaConfig = schema.toConfig(); + const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); + return schemaConfig === extendedConfig + ? schema + : new _schema.GraphQLSchema(extendedConfig); +} +/** + * @internal + */ - if (config.astNode == null) { - for (const type of config.types) { - switch (type.name) { - // Note: While this could make early assertions to get the correctly - // typed values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - case 'Query': - // @ts-expect-error validated in `validateSchema` - config.query = type; - break; +function extendSchemaImpl(schemaConfig, documentAST, options) { + var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid; - case 'Mutation': - // @ts-expect-error validated in `validateSchema` - config.mutation = type; - break; + // Collect the type definitions and extensions found in the document. + const typeDefs = []; + const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can + // have the same name. For example, a type named "skip". - case 'Subscription': - // @ts-expect-error validated in `validateSchema` - config.subscription = type; - break; - } + const directiveDefs = []; + let schemaDef; // Schema extensions are collected which may add additional operation types. + + const schemaExtensions = []; + + for (const def of documentAST.definitions) { + if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) { + schemaDef = def; + } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) { + schemaExtensions.push(def); + } else if ((0, _predicates.isTypeDefinitionNode)(def)) { + typeDefs.push(def); + } else if ((0, _predicates.isTypeExtensionNode)(def)) { + const extendedTypeName = def.name.value; + const existingTypeExtensions = typeExtensionsMap[extendedTypeName]; + typeExtensionsMap[extendedTypeName] = existingTypeExtensions + ? existingTypeExtensions.concat([def]) + : [def]; + } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + directiveDefs.push(def); } + } // If this document contains no new types, extensions, or directives then + // return the same unmodified GraphQLSchema instance. + + if ( + Object.keys(typeExtensionsMap).length === 0 && + typeDefs.length === 0 && + directiveDefs.length === 0 && + schemaExtensions.length === 0 && + schemaDef == null + ) { + return schemaConfig; } - const directives = [ - ...config.directives, // If specified directives were not explicitly declared, add them. - ..._directives.specifiedDirectives.filter((stdDirective) => - config.directives.every( - (directive) => directive.name !== stdDirective.name, - ), - ), - ]; - return new _schema.GraphQLSchema({ ...config, directives }); -} -/** - * A helper function to build a GraphQLSchema directly from a source - * document. - */ + const typeMap = Object.create(null); -function buildSchema(source, options) { - const document = (0, _parser.parse)(source, { - noLocation: - options === null || options === void 0 ? void 0 : options.noLocation, - allowLegacyFragmentVariables: - options === null || options === void 0 + for (const existingType of schemaConfig.types) { + typeMap[existingType.name] = extendNamedType(existingType); + } + + for (const typeNode of typeDefs) { + var _stdTypeMap$name; + + const name = typeNode.name.value; + typeMap[name] = + (_stdTypeMap$name = stdTypeMap[name]) !== null && + _stdTypeMap$name !== void 0 + ? _stdTypeMap$name + : buildType(typeNode); + } + + const operationTypes = { + // Get the extended root operation types. + query: schemaConfig.query && replaceNamedType(schemaConfig.query), + mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation), + subscription: + schemaConfig.subscription && replaceNamedType(schemaConfig.subscription), + // Then, incorporate schema definition and all schema extensions. + ...(schemaDef && getOperationTypes([schemaDef])), + ...getOperationTypes(schemaExtensions), + }; // Then produce and return a Schema config with these types. + + return { + description: + (_schemaDef = schemaDef) === null || _schemaDef === void 0 ? void 0 - : options.allowLegacyFragmentVariables, - }); - return buildASTSchema(document, { - assumeValidSDL: - options === null || options === void 0 ? void 0 : options.assumeValidSDL, + : (_schemaDef$descriptio = _schemaDef.description) === null || + _schemaDef$descriptio === void 0 + ? void 0 + : _schemaDef$descriptio.value, + ...operationTypes, + types: Object.values(typeMap), + directives: [ + ...schemaConfig.directives.map(replaceDirective), + ...directiveDefs.map(buildDirective), + ], + extensions: Object.create(null), + astNode: + (_schemaDef2 = schemaDef) !== null && _schemaDef2 !== void 0 + ? _schemaDef2 + : schemaConfig.astNode, + extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), assumeValid: - options === null || options === void 0 ? void 0 : options.assumeValid, - }); -} + (_options$assumeValid = + options === null || options === void 0 + ? void 0 + : options.assumeValid) !== null && _options$assumeValid !== void 0 + ? _options$assumeValid + : false, + }; // Below are functions used for producing this schema that have closed over + // this scope and have access to the schema, cache, and newly defined types. + function replaceType(type) { + if ((0, _definition.isListType)(type)) { + // @ts-expect-error + return new _definition.GraphQLList(replaceType(type.ofType)); + } -/***/ }), + if ((0, _definition.isNonNullType)(type)) { + // @ts-expect-error + return new _definition.GraphQLNonNull(replaceType(type.ofType)); + } // @ts-expect-error FIXME -/***/ 89653: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + return replaceNamedType(type); + } -"use strict"; + function replaceNamedType(type) { + // Note: While this could make early assertions to get the correctly + // typed values, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + return typeMap[type.name]; + } + function replaceDirective(directive) { + const config = directive.toConfig(); + return new _directives.GraphQLDirective({ + ...config, + args: (0, _mapValue.mapValue)(config.args, extendArg), + }); + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.buildClientSchema = buildClientSchema; + function extendNamedType(type) { + if ( + (0, _introspection.isIntrospectionType)(type) || + (0, _scalars.isSpecifiedScalarType)(type) + ) { + // Builtin types are not extended. + return type; + } + + if ((0, _definition.isScalarType)(type)) { + return extendScalarType(type); + } + + if ((0, _definition.isObjectType)(type)) { + return extendObjectType(type); + } + + if ((0, _definition.isInterfaceType)(type)) { + return extendInterfaceType(type); + } + + if ((0, _definition.isUnionType)(type)) { + return extendUnionType(type); + } + + if ((0, _definition.isEnumType)(type)) { + return extendEnumType(type); + } + + if ((0, _definition.isInputObjectType)(type)) { + return extendInputObjectType(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible type definition nodes have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); + } -var _devAssert = __nccwpck_require__(6205); + function extendInputObjectType(type) { + var _typeExtensionsMap$co; -var _inspect = __nccwpck_require__(70715); + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co !== void 0 + ? _typeExtensionsMap$co + : []; + return new _definition.GraphQLInputObjectType({ + ...config, + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, (field) => ({ + ...field, + type: replaceType(field.type), + })), + ...buildInputFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } -var _isObjectLike = __nccwpck_require__(46541); + function extendEnumType(type) { + var _typeExtensionsMap$ty; -var _keyValMap = __nccwpck_require__(98673); + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && + _typeExtensionsMap$ty !== void 0 + ? _typeExtensionsMap$ty + : []; + return new _definition.GraphQLEnumType({ + ...config, + values: { ...config.values, ...buildEnumValueMap(extensions) }, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } -var _parser = __nccwpck_require__(89937); + function extendScalarType(type) { + var _typeExtensionsMap$co2; -var _definition = __nccwpck_require__(82341); + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co2 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co2 !== void 0 + ? _typeExtensionsMap$co2 + : []; + let specifiedByURL = config.specifiedByURL; -var _directives = __nccwpck_require__(27602); + for (const extensionNode of extensions) { + var _getSpecifiedByURL; -var _introspection = __nccwpck_require__(95678); + specifiedByURL = + (_getSpecifiedByURL = getSpecifiedByURL(extensionNode)) !== null && + _getSpecifiedByURL !== void 0 + ? _getSpecifiedByURL + : specifiedByURL; + } -var _scalars = __nccwpck_require__(41963); + return new _definition.GraphQLScalarType({ + ...config, + specifiedByURL, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } -var _schema = __nccwpck_require__(17287); + function extendObjectType(type) { + var _typeExtensionsMap$co3; -var _valueFromAST = __nccwpck_require__(60962); + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co3 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co3 !== void 0 + ? _typeExtensionsMap$co3 + : []; + return new _definition.GraphQLObjectType({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } -/** - * Build a GraphQLSchema for use by client tools. - * - * Given the result of a client running the introspection query, creates and - * returns a GraphQLSchema instance which can be then used with all graphql-js - * tools, but cannot be used to execute a query, as introspection does not - * represent the "resolver", "parse" or "serialize" functions or any other - * server-internal mechanisms. - * - * This function expects a complete introspection result. Don't forget to check - * the "errors" field of a server response before calling this function. - */ -function buildClientSchema(introspection, options) { - ((0, _isObjectLike.isObjectLike)(introspection) && - (0, _isObjectLike.isObjectLike)(introspection.__schema)) || - (0, _devAssert.devAssert)( - false, - `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${(0, - _inspect.inspect)(introspection)}.`, - ); // Get the schema from the introspection result. + function extendInterfaceType(type) { + var _typeExtensionsMap$co4; - const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each. + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co4 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co4 !== void 0 + ? _typeExtensionsMap$co4 + : []; + return new _definition.GraphQLInterfaceType({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0, _mapValue.mapValue)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } - const typeMap = (0, _keyValMap.keyValMap)( - schemaIntrospection.types, - (typeIntrospection) => typeIntrospection.name, - (typeIntrospection) => buildType(typeIntrospection), - ); // Include standard types only if they are used. + function extendUnionType(type) { + var _typeExtensionsMap$co5; - for (const stdType of [ - ..._scalars.specifiedScalarTypes, - ..._introspection.introspectionTypes, - ]) { - if (typeMap[stdType.name]) { - typeMap[stdType.name] = stdType; + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co5 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co5 !== void 0 + ? _typeExtensionsMap$co5 + : []; + return new _definition.GraphQLUnionType({ + ...config, + types: () => [ + ...type.getTypes().map(replaceNamedType), + ...buildUnionTypes(extensions), + ], + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendField(field) { + return { + ...field, + type: replaceType(field.type), + args: field.args && (0, _mapValue.mapValue)(field.args, extendArg), + }; + } + + function extendArg(arg) { + return { ...arg, type: replaceType(arg.type) }; + } + + function getOperationTypes(nodes) { + const opTypes = {}; + + for (const node of nodes) { + var _node$operationTypes; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const operationTypesNodes = + /* c8 ignore next */ + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + opTypes[operationType.operation] = getNamedType(operationType.type); + } } - } // Get the root Query, Mutation, and Subscription types. - const queryType = schemaIntrospection.queryType - ? getObjectType(schemaIntrospection.queryType) - : null; - const mutationType = schemaIntrospection.mutationType - ? getObjectType(schemaIntrospection.mutationType) - : null; - const subscriptionType = schemaIntrospection.subscriptionType - ? getObjectType(schemaIntrospection.subscriptionType) - : null; // Get the directives supported by Introspection, assuming empty-set if - // directives were not queried for. + return opTypes; + } - const directives = schemaIntrospection.directives - ? schemaIntrospection.directives.map(buildDirective) - : []; // Then produce and return a Schema with these types. + function getNamedType(node) { + var _stdTypeMap$name2; - return new _schema.GraphQLSchema({ - description: schemaIntrospection.description, - query: queryType, - mutation: mutationType, - subscription: subscriptionType, - types: Object.values(typeMap), - directives, - assumeValid: - options === null || options === void 0 ? void 0 : options.assumeValid, - }); // Given a type reference in introspection, return the GraphQLType instance. - // preferring cached instances before building new instances. + const name = node.name.value; + const type = + (_stdTypeMap$name2 = stdTypeMap[name]) !== null && + _stdTypeMap$name2 !== void 0 + ? _stdTypeMap$name2 + : typeMap[name]; - function getType(typeRef) { - if (typeRef.kind === _introspection.TypeKind.LIST) { - const itemRef = typeRef.ofType; + if (type === undefined) { + throw new Error(`Unknown type: "${name}".`); + } + + return type; + } + + function getWrappedType(node) { + if (node.kind === _kinds.Kind.LIST_TYPE) { + return new _definition.GraphQLList(getWrappedType(node.type)); + } + + if (node.kind === _kinds.Kind.NON_NULL_TYPE) { + return new _definition.GraphQLNonNull(getWrappedType(node.type)); + } + + return getNamedType(node); + } + + function buildDirective(node) { + var _node$description; + + return new _directives.GraphQLDirective({ + name: node.name.value, + description: + (_node$description = node.description) === null || + _node$description === void 0 + ? void 0 + : _node$description.value, + // @ts-expect-error + locations: node.locations.map(({ value }) => value), + isRepeatable: node.repeatable, + args: buildArgumentMap(node.arguments), + astNode: node, + }); + } - if (!itemRef) { - throw new Error('Decorated type deeper than introspection query.'); - } + function buildFieldMap(nodes) { + const fieldConfigMap = Object.create(null); - return new _definition.GraphQLList(getType(itemRef)); - } + for (const node of nodes) { + var _node$fields; - if (typeRef.kind === _introspection.TypeKind.NON_NULL) { - const nullableRef = typeRef.ofType; + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const nodeFields = + /* c8 ignore next */ + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; - if (!nullableRef) { - throw new Error('Decorated type deeper than introspection query.'); - } + for (const field of nodeFields) { + var _field$description; - const nullableType = getType(nullableRef); - return new _definition.GraphQLNonNull( - (0, _definition.assertNullableType)(nullableType), - ); + fieldConfigMap[field.name.value] = { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + type: getWrappedType(field.type), + description: + (_field$description = field.description) === null || + _field$description === void 0 + ? void 0 + : _field$description.value, + args: buildArgumentMap(field.arguments), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } } - return getNamedType(typeRef); + return fieldConfigMap; } - function getNamedType(typeRef) { - const typeName = typeRef.name; - - if (!typeName) { - throw new Error( - `Unknown type reference: ${(0, _inspect.inspect)(typeRef)}.`, - ); - } + function buildArgumentMap(args) { + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const argsNodes = + /* c8 ignore next */ + args !== null && args !== void 0 ? args : []; + const argConfigMap = Object.create(null); - const type = typeMap[typeName]; + for (const arg of argsNodes) { + var _arg$description; - if (!type) { - throw new Error( - `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`, - ); + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(arg.type); + argConfigMap[arg.name.value] = { + type, + description: + (_arg$description = arg.description) === null || + _arg$description === void 0 + ? void 0 + : _arg$description.value, + defaultValue: (0, _valueFromAST.valueFromAST)(arg.defaultValue, type), + deprecationReason: getDeprecationReason(arg), + astNode: arg, + }; } - return type; - } - - function getObjectType(typeRef) { - return (0, _definition.assertObjectType)(getNamedType(typeRef)); + return argConfigMap; } - function getInterfaceType(typeRef) { - return (0, _definition.assertInterfaceType)(getNamedType(typeRef)); - } // Given a type's introspection result, construct the correct - // GraphQLType instance. - - function buildType(type) { - // eslint-disable-next-line @typescript-eslint/prefer-optional-chain - if (type != null && type.name != null && type.kind != null) { - // FIXME: Properly type IntrospectionType, it's a breaking change so fix in v17 - // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check - switch (type.kind) { - case _introspection.TypeKind.SCALAR: - return buildScalarDef(type); - - case _introspection.TypeKind.OBJECT: - return buildObjectDef(type); + function buildInputFieldMap(nodes) { + const inputFieldMap = Object.create(null); - case _introspection.TypeKind.INTERFACE: - return buildInterfaceDef(type); + for (const node of nodes) { + var _node$fields2; - case _introspection.TypeKind.UNION: - return buildUnionDef(type); + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const fieldsNodes = + /* c8 ignore next */ + (_node$fields2 = node.fields) !== null && _node$fields2 !== void 0 + ? _node$fields2 + : []; - case _introspection.TypeKind.ENUM: - return buildEnumDef(type); + for (const field of fieldsNodes) { + var _field$description2; - case _introspection.TypeKind.INPUT_OBJECT: - return buildInputObjectDef(type); + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(field.type); + inputFieldMap[field.name.value] = { + type, + description: + (_field$description2 = field.description) === null || + _field$description2 === void 0 + ? void 0 + : _field$description2.value, + defaultValue: (0, _valueFromAST.valueFromAST)( + field.defaultValue, + type, + ), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; } } - const typeStr = (0, _inspect.inspect)(type); - throw new Error( - `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`, - ); + return inputFieldMap; } - function buildScalarDef(scalarIntrospection) { - return new _definition.GraphQLScalarType({ - name: scalarIntrospection.name, - description: scalarIntrospection.description, - specifiedByURL: scalarIntrospection.specifiedByURL, - }); - } + function buildEnumValueMap(nodes) { + const enumValueMap = Object.create(null); - function buildImplementationsList(implementingIntrospection) { - // TODO: Temporary workaround until GraphQL ecosystem will fully support - // 'interfaces' on interface types. - if ( - implementingIntrospection.interfaces === null && - implementingIntrospection.kind === _introspection.TypeKind.INTERFACE - ) { - return []; - } + for (const node of nodes) { + var _node$values; - if (!implementingIntrospection.interfaces) { - const implementingIntrospectionStr = (0, _inspect.inspect)( - implementingIntrospection, - ); - throw new Error( - `Introspection result missing interfaces: ${implementingIntrospectionStr}.`, - ); + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const valuesNodes = + /* c8 ignore next */ + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + + for (const value of valuesNodes) { + var _value$description; + + enumValueMap[value.name.value] = { + description: + (_value$description = value.description) === null || + _value$description === void 0 + ? void 0 + : _value$description.value, + deprecationReason: getDeprecationReason(value), + astNode: value, + }; + } } - return implementingIntrospection.interfaces.map(getInterfaceType); + return enumValueMap; } - function buildObjectDef(objectIntrospection) { - return new _definition.GraphQLObjectType({ - name: objectIntrospection.name, - description: objectIntrospection.description, - interfaces: () => buildImplementationsList(objectIntrospection), - fields: () => buildFieldDefMap(objectIntrospection), - }); - } + function buildInterfaces(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$interfaces$map, _node$interfaces; - function buildInterfaceDef(interfaceIntrospection) { - return new _definition.GraphQLInterfaceType({ - name: interfaceIntrospection.name, - description: interfaceIntrospection.description, - interfaces: () => buildImplementationsList(interfaceIntrospection), - fields: () => buildFieldDefMap(interfaceIntrospection), - }); + return ( + /* c8 ignore next */ + (_node$interfaces$map = + (_node$interfaces = node.interfaces) === null || + _node$interfaces === void 0 + ? void 0 + : _node$interfaces.map(getNamedType)) !== null && + _node$interfaces$map !== void 0 + ? _node$interfaces$map + : [] + ); + }, + ); } - function buildUnionDef(unionIntrospection) { - if (!unionIntrospection.possibleTypes) { - const unionIntrospectionStr = (0, _inspect.inspect)(unionIntrospection); - throw new Error( - `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`, - ); - } + function buildUnionTypes(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$types$map, _node$types; - return new _definition.GraphQLUnionType({ - name: unionIntrospection.name, - description: unionIntrospection.description, - types: () => unionIntrospection.possibleTypes.map(getObjectType), - }); + return ( + /* c8 ignore next */ + (_node$types$map = + (_node$types = node.types) === null || _node$types === void 0 + ? void 0 + : _node$types.map(getNamedType)) !== null && + _node$types$map !== void 0 + ? _node$types$map + : [] + ); + }, + ); } - function buildEnumDef(enumIntrospection) { - if (!enumIntrospection.enumValues) { - const enumIntrospectionStr = (0, _inspect.inspect)(enumIntrospection); - throw new Error( - `Introspection result missing enumValues: ${enumIntrospectionStr}.`, - ); - } + function buildType(astNode) { + var _typeExtensionsMap$na; - return new _definition.GraphQLEnumType({ - name: enumIntrospection.name, - description: enumIntrospection.description, - values: (0, _keyValMap.keyValMap)( - enumIntrospection.enumValues, - (valueIntrospection) => valueIntrospection.name, - (valueIntrospection) => ({ - description: valueIntrospection.description, - deprecationReason: valueIntrospection.deprecationReason, - }), - ), - }); - } + const name = astNode.name.value; + const extensionASTNodes = + (_typeExtensionsMap$na = typeExtensionsMap[name]) !== null && + _typeExtensionsMap$na !== void 0 + ? _typeExtensionsMap$na + : []; - function buildInputObjectDef(inputObjectIntrospection) { - if (!inputObjectIntrospection.inputFields) { - const inputObjectIntrospectionStr = (0, _inspect.inspect)( - inputObjectIntrospection, - ); - throw new Error( - `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`, - ); - } + switch (astNode.kind) { + case _kinds.Kind.OBJECT_TYPE_DEFINITION: { + var _astNode$description; - return new _definition.GraphQLInputObjectType({ - name: inputObjectIntrospection.name, - description: inputObjectIntrospection.description, - fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), - }); - } + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLObjectType({ + name, + description: + (_astNode$description = astNode.description) === null || + _astNode$description === void 0 + ? void 0 + : _astNode$description.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } - function buildFieldDefMap(typeIntrospection) { - if (!typeIntrospection.fields) { - throw new Error( - `Introspection result missing fields: ${(0, _inspect.inspect)( - typeIntrospection, - )}.`, - ); - } + case _kinds.Kind.INTERFACE_TYPE_DEFINITION: { + var _astNode$description2; - return (0, _keyValMap.keyValMap)( - typeIntrospection.fields, - (fieldIntrospection) => fieldIntrospection.name, - buildField, - ); - } + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLInterfaceType({ + name, + description: + (_astNode$description2 = astNode.description) === null || + _astNode$description2 === void 0 + ? void 0 + : _astNode$description2.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } - function buildField(fieldIntrospection) { - const type = getType(fieldIntrospection.type); + case _kinds.Kind.ENUM_TYPE_DEFINITION: { + var _astNode$description3; - if (!(0, _definition.isOutputType)(type)) { - const typeStr = (0, _inspect.inspect)(type); - throw new Error( - `Introspection must provide output type for fields, but received: ${typeStr}.`, - ); - } + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLEnumType({ + name, + description: + (_astNode$description3 = astNode.description) === null || + _astNode$description3 === void 0 + ? void 0 + : _astNode$description3.value, + values: buildEnumValueMap(allNodes), + astNode, + extensionASTNodes, + }); + } - if (!fieldIntrospection.args) { - const fieldIntrospectionStr = (0, _inspect.inspect)(fieldIntrospection); - throw new Error( - `Introspection result missing field args: ${fieldIntrospectionStr}.`, - ); - } + case _kinds.Kind.UNION_TYPE_DEFINITION: { + var _astNode$description4; - return { - description: fieldIntrospection.description, - deprecationReason: fieldIntrospection.deprecationReason, - type, - args: buildInputValueDefMap(fieldIntrospection.args), - }; - } + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLUnionType({ + name, + description: + (_astNode$description4 = astNode.description) === null || + _astNode$description4 === void 0 + ? void 0 + : _astNode$description4.value, + types: () => buildUnionTypes(allNodes), + astNode, + extensionASTNodes, + }); + } - function buildInputValueDefMap(inputValueIntrospections) { - return (0, _keyValMap.keyValMap)( - inputValueIntrospections, - (inputValue) => inputValue.name, - buildInputValue, - ); - } + case _kinds.Kind.SCALAR_TYPE_DEFINITION: { + var _astNode$description5; - function buildInputValue(inputValueIntrospection) { - const type = getType(inputValueIntrospection.type); + return new _definition.GraphQLScalarType({ + name, + description: + (_astNode$description5 = astNode.description) === null || + _astNode$description5 === void 0 + ? void 0 + : _astNode$description5.value, + specifiedByURL: getSpecifiedByURL(astNode), + astNode, + extensionASTNodes, + }); + } - if (!(0, _definition.isInputType)(type)) { - const typeStr = (0, _inspect.inspect)(type); - throw new Error( - `Introspection must provide input type for arguments, but received: ${typeStr}.`, - ); - } + case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: { + var _astNode$description6; - const defaultValue = - inputValueIntrospection.defaultValue != null - ? (0, _valueFromAST.valueFromAST)( - (0, _parser.parseValue)(inputValueIntrospection.defaultValue), - type, - ) - : undefined; - return { - description: inputValueIntrospection.description, - type, - defaultValue, - deprecationReason: inputValueIntrospection.deprecationReason, - }; + const allNodes = [astNode, ...extensionASTNodes]; + return new _definition.GraphQLInputObjectType({ + name, + description: + (_astNode$description6 = astNode.description) === null || + _astNode$description6 === void 0 + ? void 0 + : _astNode$description6.value, + fields: () => buildInputFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + } } +} - function buildDirective(directiveIntrospection) { - if (!directiveIntrospection.args) { - const directiveIntrospectionStr = (0, _inspect.inspect)( - directiveIntrospection, - ); - throw new Error( - `Introspection result missing directive args: ${directiveIntrospectionStr}.`, - ); - } +const stdTypeMap = (0, _keyMap.keyMap)( + [..._scalars.specifiedScalarTypes, ..._introspection.introspectionTypes], + (type) => type.name, +); +/** + * Given a field or enum value node, returns the string value for the + * deprecation reason. + */ - if (!directiveIntrospection.locations) { - const directiveIntrospectionStr = (0, _inspect.inspect)( - directiveIntrospection, - ); - throw new Error( - `Introspection result missing directive locations: ${directiveIntrospectionStr}.`, - ); - } +function getDeprecationReason(node) { + const deprecated = (0, _values.getDirectiveValues)( + _directives.GraphQLDeprecatedDirective, + node, + ); // @ts-expect-error validated by `getDirectiveValues` - return new _directives.GraphQLDirective({ - name: directiveIntrospection.name, - description: directiveIntrospection.description, - isRepeatable: directiveIntrospection.isRepeatable, - locations: directiveIntrospection.locations.slice(), - args: buildInputValueDefMap(directiveIntrospection.args), - }); - } + return deprecated === null || deprecated === void 0 + ? void 0 + : deprecated.reason; +} +/** + * Given a scalar node, returns the string value for the specifiedByURL. + */ + +function getSpecifiedByURL(node) { + const specifiedBy = (0, _values.getDirectiveValues)( + _directives.GraphQLSpecifiedByDirective, + node, + ); // @ts-expect-error validated by `getDirectiveValues` + + return specifiedBy === null || specifiedBy === void 0 + ? void 0 + : specifiedBy.url; } /***/ }), -/***/ 56977: +/***/ 1791: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -31900,1035 +56319,1070 @@ function buildClientSchema(introspection, options) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.coerceInputValue = coerceInputValue; +exports.DangerousChangeType = exports.BreakingChangeType = void 0; +exports.findBreakingChanges = findBreakingChanges; +exports.findDangerousChanges = findDangerousChanges; + +var _inspect = __nccwpck_require__(85856); -var _didYouMean = __nccwpck_require__(28052); +var _invariant = __nccwpck_require__(31338); -var _inspect = __nccwpck_require__(70715); +var _keyMap = __nccwpck_require__(22660); -var _invariant = __nccwpck_require__(28864); +var _printer = __nccwpck_require__(54697); -var _isIterableObject = __nccwpck_require__(77306); +var _definition = __nccwpck_require__(57741); -var _isObjectLike = __nccwpck_require__(46541); +var _scalars = __nccwpck_require__(94420); -var _Path = __nccwpck_require__(23798); +var _astFromValue = __nccwpck_require__(61402); -var _printPathArray = __nccwpck_require__(17069); +var _sortValueNode = __nccwpck_require__(6177); -var _suggestionList = __nccwpck_require__(69977); +var BreakingChangeType; +exports.BreakingChangeType = BreakingChangeType; + +(function (BreakingChangeType) { + BreakingChangeType['TYPE_REMOVED'] = 'TYPE_REMOVED'; + BreakingChangeType['TYPE_CHANGED_KIND'] = 'TYPE_CHANGED_KIND'; + BreakingChangeType['TYPE_REMOVED_FROM_UNION'] = 'TYPE_REMOVED_FROM_UNION'; + BreakingChangeType['VALUE_REMOVED_FROM_ENUM'] = 'VALUE_REMOVED_FROM_ENUM'; + BreakingChangeType['REQUIRED_INPUT_FIELD_ADDED'] = + 'REQUIRED_INPUT_FIELD_ADDED'; + BreakingChangeType['IMPLEMENTED_INTERFACE_REMOVED'] = + 'IMPLEMENTED_INTERFACE_REMOVED'; + BreakingChangeType['FIELD_REMOVED'] = 'FIELD_REMOVED'; + BreakingChangeType['FIELD_CHANGED_KIND'] = 'FIELD_CHANGED_KIND'; + BreakingChangeType['REQUIRED_ARG_ADDED'] = 'REQUIRED_ARG_ADDED'; + BreakingChangeType['ARG_REMOVED'] = 'ARG_REMOVED'; + BreakingChangeType['ARG_CHANGED_KIND'] = 'ARG_CHANGED_KIND'; + BreakingChangeType['DIRECTIVE_REMOVED'] = 'DIRECTIVE_REMOVED'; + BreakingChangeType['DIRECTIVE_ARG_REMOVED'] = 'DIRECTIVE_ARG_REMOVED'; + BreakingChangeType['REQUIRED_DIRECTIVE_ARG_ADDED'] = + 'REQUIRED_DIRECTIVE_ARG_ADDED'; + BreakingChangeType['DIRECTIVE_REPEATABLE_REMOVED'] = + 'DIRECTIVE_REPEATABLE_REMOVED'; + BreakingChangeType['DIRECTIVE_LOCATION_REMOVED'] = + 'DIRECTIVE_LOCATION_REMOVED'; +})( + BreakingChangeType || (exports.BreakingChangeType = BreakingChangeType = {}), +); -var _GraphQLError = __nccwpck_require__(442); +var DangerousChangeType; +exports.DangerousChangeType = DangerousChangeType; -var _definition = __nccwpck_require__(82341); +(function (DangerousChangeType) { + DangerousChangeType['VALUE_ADDED_TO_ENUM'] = 'VALUE_ADDED_TO_ENUM'; + DangerousChangeType['TYPE_ADDED_TO_UNION'] = 'TYPE_ADDED_TO_UNION'; + DangerousChangeType['OPTIONAL_INPUT_FIELD_ADDED'] = + 'OPTIONAL_INPUT_FIELD_ADDED'; + DangerousChangeType['OPTIONAL_ARG_ADDED'] = 'OPTIONAL_ARG_ADDED'; + DangerousChangeType['IMPLEMENTED_INTERFACE_ADDED'] = + 'IMPLEMENTED_INTERFACE_ADDED'; + DangerousChangeType['ARG_DEFAULT_VALUE_CHANGE'] = 'ARG_DEFAULT_VALUE_CHANGE'; +})( + DangerousChangeType || + (exports.DangerousChangeType = DangerousChangeType = {}), +); /** - * Coerces a JavaScript value given a GraphQL Input Type. + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. */ -function coerceInputValue(inputValue, type, onError = defaultOnError) { - return coerceInputValueImpl(inputValue, type, onError, undefined); +function findBreakingChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in BreakingChangeType, + ); } +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + */ -function defaultOnError(path, invalidValue, error) { - let errorPrefix = 'Invalid value ' + (0, _inspect.inspect)(invalidValue); - - if (path.length > 0) { - errorPrefix += ` at "value${(0, _printPathArray.printPathArray)(path)}"`; - } +function findDangerousChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in DangerousChangeType, + ); +} - error.message = errorPrefix + ': ' + error.message; - throw error; +function findSchemaChanges(oldSchema, newSchema) { + return [ + ...findTypeChanges(oldSchema, newSchema), + ...findDirectiveChanges(oldSchema, newSchema), + ]; } -function coerceInputValueImpl(inputValue, type, onError, path) { - if ((0, _definition.isNonNullType)(type)) { - if (inputValue != null) { - return coerceInputValueImpl(inputValue, type.ofType, onError, path); - } +function findDirectiveChanges(oldSchema, newSchema) { + const schemaChanges = []; + const directivesDiff = diff( + oldSchema.getDirectives(), + newSchema.getDirectives(), + ); - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError( - `Expected non-nullable type "${(0, _inspect.inspect)( - type, - )}" not to be null.`, - ), - ); - return; + for (const oldDirective of directivesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REMOVED, + description: `${oldDirective.name} was removed.`, + }); } - if (inputValue == null) { - // Explicitly return the value null. - return null; - } + for (const [oldDirective, newDirective] of directivesDiff.persisted) { + const argsDiff = diff(oldDirective.args, newDirective.args); - if ((0, _definition.isListType)(type)) { - const itemType = type.ofType; + for (const newArg of argsDiff.added) { + if ((0, _definition.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, + description: `A required arg ${newArg.name} on directive ${oldDirective.name} was added.`, + }); + } + } - if ((0, _isIterableObject.isIterableObject)(inputValue)) { - return Array.from(inputValue, (itemValue, index) => { - const itemPath = (0, _Path.addPath)(path, index, undefined); - return coerceInputValueImpl(itemValue, itemType, onError, itemPath); + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, + description: `${oldArg.name} was removed from ${oldDirective.name}.`, }); - } // Lists accept a non-list value as a list of one. - - return [coerceInputValueImpl(inputValue, itemType, onError, path)]; - } - - if ((0, _definition.isInputObjectType)(type)) { - if (!(0, _isObjectLike.isObjectLike)(inputValue)) { - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError( - `Expected type "${type.name}" to be an object.`, - ), - ); - return; } - const coercedValue = {}; - const fieldDefs = type.getFields(); - - for (const field of Object.values(fieldDefs)) { - const fieldValue = inputValue[field.name]; - - if (fieldValue === undefined) { - if (field.defaultValue !== undefined) { - coercedValue[field.name] = field.defaultValue; - } else if ((0, _definition.isNonNullType)(field.type)) { - const typeStr = (0, _inspect.inspect)(field.type); - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError( - `Field "${field.name}" of required type "${typeStr}" was not provided.`, - ), - ); - } - - continue; - } - - coercedValue[field.name] = coerceInputValueImpl( - fieldValue, - field.type, - onError, - (0, _Path.addPath)(path, field.name, type.name), - ); - } // Ensure every provided field is defined. + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, + description: `Repeatable flag was removed from ${oldDirective.name}.`, + }); + } - for (const fieldName of Object.keys(inputValue)) { - if (!fieldDefs[fieldName]) { - const suggestions = (0, _suggestionList.suggestionList)( - fieldName, - Object.keys(type.getFields()), - ); - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError( - `Field "${fieldName}" is not defined by type "${type.name}".` + - (0, _didYouMean.didYouMean)(suggestions), - ), - ); + for (const location of oldDirective.locations) { + if (!newDirective.locations.includes(location)) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, + description: `${location} was removed from ${oldDirective.name}.`, + }); } } - - return coercedValue; } - if ((0, _definition.isLeafType)(type)) { - let parseResult; // Scalars and Enums determine if a input value is valid via parseValue(), - // which can throw to indicate failure. If it throws, maintain a reference - // to the original error. + return schemaChanges; +} - try { - parseResult = type.parseValue(inputValue); - } catch (error) { - if (error instanceof _GraphQLError.GraphQLError) { - onError((0, _Path.pathToArray)(path), inputValue, error); - } else { - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError( - `Expected type "${type.name}". ` + error.message, - { - originalError: error, - }, - ), - ); - } +function findTypeChanges(oldSchema, newSchema) { + const schemaChanges = []; + const typesDiff = diff( + Object.values(oldSchema.getTypeMap()), + Object.values(newSchema.getTypeMap()), + ); - return; - } + for (const oldType of typesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED, + description: (0, _scalars.isSpecifiedScalarType)(oldType) + ? `Standard scalar ${oldType.name} was removed because it is not referenced anymore.` + : `${oldType.name} was removed.`, + }); + } - if (parseResult === undefined) { - onError( - (0, _Path.pathToArray)(path), - inputValue, - new _GraphQLError.GraphQLError(`Expected type "${type.name}".`), + for (const [oldType, newType] of typesDiff.persisted) { + if ( + (0, _definition.isEnumType)(oldType) && + (0, _definition.isEnumType)(newType) + ) { + schemaChanges.push(...findEnumTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isUnionType)(oldType) && + (0, _definition.isUnionType)(newType) + ) { + schemaChanges.push(...findUnionTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isInputObjectType)(oldType) && + (0, _definition.isInputObjectType)(newType) + ) { + schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); + } else if ( + (0, _definition.isObjectType)(oldType) && + (0, _definition.isObjectType)(newType) + ) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), + ); + } else if ( + (0, _definition.isInterfaceType)(oldType) && + (0, _definition.isInterfaceType)(newType) + ) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), ); + } else if (oldType.constructor !== newType.constructor) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_CHANGED_KIND, + description: + `${oldType.name} changed from ` + + `${typeKindName(oldType)} to ${typeKindName(newType)}.`, + }); } - - return parseResult; } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - false || - (0, _invariant.invariant)( - false, - 'Unexpected input type: ' + (0, _inspect.inspect)(type), - ); + return schemaChanges; } +function findInputObjectTypeChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); -/***/ }), - -/***/ 17329: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.concatAST = concatAST; + for (const newField of fieldsDiff.added) { + if ((0, _definition.isRequiredInputField)(newField)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, + description: `A required field ${newField.name} on input type ${oldType.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, + description: `An optional field ${newField.name} on input type ${oldType.name} was added.`, + }); + } + } -var _kinds = __nccwpck_require__(36578); + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } -/** - * Provided a collection of ASTs, presumably each from different files, - * concatenate the ASTs together into batched AST, useful for validating many - * GraphQL source files which together represent one conceptual application. - */ -function concatAST(documents) { - const definitions = []; + for (const [oldField, newField] of fieldsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldField.type, + newField.type, + ); - for (const doc of documents) { - definitions.push(...doc.definitions); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } } - return { - kind: _kinds.Kind.DOCUMENT, - definitions, - }; + return schemaChanges; } +function findUnionTypeChanges(oldType, newType) { + const schemaChanges = []; + const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); -/***/ }), - -/***/ 14691: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.extendSchema = extendSchema; -exports.extendSchemaImpl = extendSchemaImpl; - -var _devAssert = __nccwpck_require__(6205); - -var _inspect = __nccwpck_require__(70715); - -var _invariant = __nccwpck_require__(28864); + for (const newPossibleType of possibleTypesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.TYPE_ADDED_TO_UNION, + description: `${newPossibleType.name} was added to union type ${oldType.name}.`, + }); + } -var _keyMap = __nccwpck_require__(65169); + for (const oldPossibleType of possibleTypesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, + description: `${oldPossibleType.name} was removed from union type ${oldType.name}.`, + }); + } -var _mapValue = __nccwpck_require__(40176); + return schemaChanges; +} -var _kinds = __nccwpck_require__(36578); +function findEnumTypeChanges(oldType, newType) { + const schemaChanges = []; + const valuesDiff = diff(oldType.getValues(), newType.getValues()); -var _predicates = __nccwpck_require__(24854); + for (const newValue of valuesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.VALUE_ADDED_TO_ENUM, + description: `${newValue.name} was added to enum type ${oldType.name}.`, + }); + } -var _definition = __nccwpck_require__(82341); + for (const oldValue of valuesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, + description: `${oldValue.name} was removed from enum type ${oldType.name}.`, + }); + } -var _directives = __nccwpck_require__(27602); + return schemaChanges; +} -var _introspection = __nccwpck_require__(95678); +function findImplementedInterfacesChanges(oldType, newType) { + const schemaChanges = []; + const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); -var _scalars = __nccwpck_require__(41963); + for (const newInterface of interfacesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, + description: `${newInterface.name} added to interfaces implemented by ${oldType.name}.`, + }); + } -var _schema = __nccwpck_require__(17287); + for (const oldInterface of interfacesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, + description: `${oldType.name} no longer implements interface ${oldInterface.name}.`, + }); + } -var _validate = __nccwpck_require__(1581); + return schemaChanges; +} -var _values = __nccwpck_require__(32502); +function findFieldChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); -var _valueFromAST = __nccwpck_require__(60962); + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } -/** - * Produces a new schema given an existing schema and a document which may - * contain GraphQL type extensions and definitions. The original schema will - * remain unaltered. - * - * Because a schema represents a graph of references, a schema cannot be - * extended without effectively making an entire copy. We do not know until it's - * too late if subgraphs remain unchanged. - * - * This algorithm copies the provided schema, applying extensions while - * producing the copy. The original schema remains unaltered. - */ -function extendSchema(schema, documentAST, options) { - (0, _schema.assertSchema)(schema); - (documentAST != null && documentAST.kind === _kinds.Kind.DOCUMENT) || - (0, _devAssert.devAssert)(false, 'Must provide valid Document AST.'); + for (const [oldField, newField] of fieldsDiff.persisted) { + schemaChanges.push(...findArgChanges(oldType, oldField, newField)); + const isSafe = isChangeSafeForObjectOrInterfaceField( + oldField.type, + newField.type, + ); - if ( - (options === null || options === void 0 ? void 0 : options.assumeValid) !== - true && - (options === null || options === void 0 - ? void 0 - : options.assumeValidSDL) !== true - ) { - (0, _validate.assertValidSDLExtension)(documentAST, schema); + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } } - const schemaConfig = schema.toConfig(); - const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); - return schemaConfig === extendedConfig - ? schema - : new _schema.GraphQLSchema(extendedConfig); + return schemaChanges; } -/** - * @internal - */ -function extendSchemaImpl(schemaConfig, documentAST, options) { - var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid; +function findArgChanges(oldType, oldField, newField) { + const schemaChanges = []; + const argsDiff = diff(oldField.args, newField.args); - // Collect the type definitions and extensions found in the document. - const typeDefs = []; - const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can - // have the same name. For example, a type named "skip". + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.ARG_REMOVED, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`, + }); + } - const directiveDefs = []; - let schemaDef; // Schema extensions are collected which may add additional operation types. + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldArg.type, + newArg.type, + ); - const schemaExtensions = []; + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.ARG_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } else if (oldArg.defaultValue !== undefined) { + if (newArg.defaultValue === undefined) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, + }); + } else { + // Since we looking only for client's observable changes we should + // compare default values in the same representation as they are + // represented inside introspection. + const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type); + const newValueStr = stringifyValue(newArg.defaultValue, newArg.type); - for (const def of documentAST.definitions) { - if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) { - schemaDef = def; - } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) { - schemaExtensions.push(def); - } else if ((0, _predicates.isTypeDefinitionNode)(def)) { - typeDefs.push(def); - } else if ((0, _predicates.isTypeExtensionNode)(def)) { - const extendedTypeName = def.name.value; - const existingTypeExtensions = typeExtensionsMap[extendedTypeName]; - typeExtensionsMap[extendedTypeName] = existingTypeExtensions - ? existingTypeExtensions.concat([def]) - : [def]; - } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - directiveDefs.push(def); + if (oldValueStr !== newValueStr) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`, + }); + } + } } - } // If this document contains no new types, extensions, or directives then - // return the same unmodified GraphQLSchema instance. + } - if ( - Object.keys(typeExtensionsMap).length === 0 && - typeDefs.length === 0 && - directiveDefs.length === 0 && - schemaExtensions.length === 0 && - schemaDef == null - ) { - return schemaConfig; + for (const newArg of argsDiff.added) { + if ((0, _definition.isRequiredArgument)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_ARG_ADDED, + description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_ARG_ADDED, + description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } } - const typeMap = Object.create(null); + return schemaChanges; +} - for (const existingType of schemaConfig.types) { - typeMap[existingType.name] = extendNamedType(existingType); +function isChangeSafeForObjectOrInterfaceField(oldType, newType) { + if ((0, _definition.isListType)(oldType)) { + return ( + // if they're both lists, make sure the underlying types are compatible + ((0, _definition.isListType)(newType) && + isChangeSafeForObjectOrInterfaceField( + oldType.ofType, + newType.ofType, + )) || // moving from nullable to non-null of the same underlying type is safe + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); } - for (const typeNode of typeDefs) { - var _stdTypeMap$name; - - const name = typeNode.name.value; - typeMap[name] = - (_stdTypeMap$name = stdTypeMap[name]) !== null && - _stdTypeMap$name !== void 0 - ? _stdTypeMap$name - : buildType(typeNode); + if ((0, _definition.isNonNullType)(oldType)) { + // if they're both non-null, make sure the underlying types are compatible + return ( + (0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) + ); } - const operationTypes = { - // Get the extended root operation types. - query: schemaConfig.query && replaceNamedType(schemaConfig.query), - mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation), - subscription: - schemaConfig.subscription && replaceNamedType(schemaConfig.subscription), - // Then, incorporate schema definition and all schema extensions. - ...(schemaDef && getOperationTypes([schemaDef])), - ...getOperationTypes(schemaExtensions), - }; // Then produce and return a Schema config with these types. + return ( + // if they're both named types, see if their names are equivalent + ((0, _definition.isNamedType)(newType) && oldType.name === newType.name) || // moving from nullable to non-null of the same underlying type is safe + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); +} - return { - description: - (_schemaDef = schemaDef) === null || _schemaDef === void 0 - ? void 0 - : (_schemaDef$descriptio = _schemaDef.description) === null || - _schemaDef$descriptio === void 0 - ? void 0 - : _schemaDef$descriptio.value, - ...operationTypes, - types: Object.values(typeMap), - directives: [ - ...schemaConfig.directives.map(replaceDirective), - ...directiveDefs.map(buildDirective), - ], - extensions: Object.create(null), - astNode: - (_schemaDef2 = schemaDef) !== null && _schemaDef2 !== void 0 - ? _schemaDef2 - : schemaConfig.astNode, - extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), - assumeValid: - (_options$assumeValid = - options === null || options === void 0 - ? void 0 - : options.assumeValid) !== null && _options$assumeValid !== void 0 - ? _options$assumeValid - : false, - }; // Below are functions used for producing this schema that have closed over - // this scope and have access to the schema, cache, and newly defined types. +function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { + if ((0, _definition.isListType)(oldType)) { + // if they're both lists, make sure the underlying types are compatible + return ( + (0, _definition.isListType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) + ); + } - function replaceType(type) { - if ((0, _definition.isListType)(type)) { - // @ts-expect-error - return new _definition.GraphQLList(replaceType(type.ofType)); - } + if ((0, _definition.isNonNullType)(oldType)) { + return ( + // if they're both non-null, make sure the underlying types are + // compatible + ((0, _definition.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg( + oldType.ofType, + newType.ofType, + )) || // moving from non-null to nullable of the same underlying type is safe + (!(0, _definition.isNonNullType)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)) + ); + } // if they're both named types, see if their names are equivalent - if ((0, _definition.isNonNullType)(type)) { - // @ts-expect-error - return new _definition.GraphQLNonNull(replaceType(type.ofType)); - } // @ts-expect-error FIXME + return (0, _definition.isNamedType)(newType) && oldType.name === newType.name; +} - return replaceNamedType(type); +function typeKindName(type) { + if ((0, _definition.isScalarType)(type)) { + return 'a Scalar type'; } - function replaceNamedType(type) { - // Note: While this could make early assertions to get the correctly - // typed values, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - return typeMap[type.name]; + if ((0, _definition.isObjectType)(type)) { + return 'an Object type'; } - function replaceDirective(directive) { - const config = directive.toConfig(); - return new _directives.GraphQLDirective({ - ...config, - args: (0, _mapValue.mapValue)(config.args, extendArg), - }); + if ((0, _definition.isInterfaceType)(type)) { + return 'an Interface type'; } - function extendNamedType(type) { - if ( - (0, _introspection.isIntrospectionType)(type) || - (0, _scalars.isSpecifiedScalarType)(type) - ) { - // Builtin types are not extended. - return type; - } + if ((0, _definition.isUnionType)(type)) { + return 'a Union type'; + } - if ((0, _definition.isScalarType)(type)) { - return extendScalarType(type); - } + if ((0, _definition.isEnumType)(type)) { + return 'an Enum type'; + } - if ((0, _definition.isObjectType)(type)) { - return extendObjectType(type); - } + if ((0, _definition.isInputObjectType)(type)) { + return 'an Input type'; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. - if ((0, _definition.isInterfaceType)(type)) { - return extendInterfaceType(type); - } + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} - if ((0, _definition.isUnionType)(type)) { - return extendUnionType(type); - } +function stringifyValue(value, type) { + const ast = (0, _astFromValue.astFromValue)(value, type); + ast != null || (0, _invariant.invariant)(false); + return (0, _printer.print)((0, _sortValueNode.sortValueNode)(ast)); +} - if ((0, _definition.isEnumType)(type)) { - return extendEnumType(type); - } +function diff(oldArray, newArray) { + const added = []; + const removed = []; + const persisted = []; + const oldMap = (0, _keyMap.keyMap)(oldArray, ({ name }) => name); + const newMap = (0, _keyMap.keyMap)(newArray, ({ name }) => name); - if ((0, _definition.isInputObjectType)(type)) { - return extendInputObjectType(type); - } - /* c8 ignore next 3 */ - // Not reachable, all possible type definition nodes have been considered. + for (const oldItem of oldArray) { + const newItem = newMap[oldItem.name]; - false || - (0, _invariant.invariant)( - false, - 'Unexpected type: ' + (0, _inspect.inspect)(type), - ); + if (newItem === undefined) { + removed.push(oldItem); + } else { + persisted.push([oldItem, newItem]); + } } - function extendInputObjectType(type) { - var _typeExtensionsMap$co; - - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && - _typeExtensionsMap$co !== void 0 - ? _typeExtensionsMap$co - : []; - return new _definition.GraphQLInputObjectType({ - ...config, - fields: () => ({ - ...(0, _mapValue.mapValue)(config.fields, (field) => ({ - ...field, - type: replaceType(field.type), - })), - ...buildInputFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); + for (const newItem of newArray) { + if (oldMap[newItem.name] === undefined) { + added.push(newItem); + } } - function extendEnumType(type) { - var _typeExtensionsMap$ty; + return { + added, + persisted, + removed, + }; +} - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && - _typeExtensionsMap$ty !== void 0 - ? _typeExtensionsMap$ty - : []; - return new _definition.GraphQLEnumType({ - ...config, - values: { ...config.values, ...buildEnumValueMap(extensions) }, - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } - function extendScalarType(type) { - var _typeExtensionsMap$co2; +/***/ }), - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$co2 = typeExtensionsMap[config.name]) !== null && - _typeExtensionsMap$co2 !== void 0 - ? _typeExtensionsMap$co2 - : []; - let specifiedByURL = config.specifiedByURL; +/***/ 8902: +/***/ ((__unused_webpack_module, exports) => { - for (const extensionNode of extensions) { - var _getSpecifiedByURL; +"use strict"; - specifiedByURL = - (_getSpecifiedByURL = getSpecifiedByURL(extensionNode)) !== null && - _getSpecifiedByURL !== void 0 - ? _getSpecifiedByURL - : specifiedByURL; - } - return new _definition.GraphQLScalarType({ - ...config, - specifiedByURL, - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getIntrospectionQuery = getIntrospectionQuery; - function extendObjectType(type) { - var _typeExtensionsMap$co3; +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +function getIntrospectionQuery(options) { + const optionsWithDefault = { + descriptions: true, + specifiedByUrl: false, + directiveIsRepeatable: false, + schemaDescription: false, + inputValueDeprecation: false, + ...options, + }; + const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; + const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable + ? 'isRepeatable' + : ''; + const schemaDescription = optionsWithDefault.schemaDescription + ? descriptions + : ''; - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$co3 = typeExtensionsMap[config.name]) !== null && - _typeExtensionsMap$co3 !== void 0 - ? _typeExtensionsMap$co3 - : []; - return new _definition.GraphQLObjectType({ - ...config, - interfaces: () => [ - ...type.getInterfaces().map(replaceNamedType), - ...buildInterfaces(extensions), - ], - fields: () => ({ - ...(0, _mapValue.mapValue)(config.fields, extendField), - ...buildFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); + function inputDeprecation(str) { + return optionsWithDefault.inputValueDeprecation ? str : ''; } - function extendInterfaceType(type) { - var _typeExtensionsMap$co4; + return ` + query IntrospectionQuery { + __schema { + ${schemaDescription} + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + ${descriptions} + ${directiveIsRepeatable} + locations + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + } + } + } - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$co4 = typeExtensionsMap[config.name]) !== null && - _typeExtensionsMap$co4 !== void 0 - ? _typeExtensionsMap$co4 - : []; - return new _definition.GraphQLInterfaceType({ - ...config, - interfaces: () => [ - ...type.getInterfaces().map(replaceNamedType), - ...buildInterfaces(extensions), - ], - fields: () => ({ - ...(0, _mapValue.mapValue)(config.fields, extendField), - ...buildFieldMap(extensions), - }), - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } + fragment FullType on __Type { + kind + name + ${descriptions} + ${specifiedByUrl} + fields(includeDeprecated: true) { + name + ${descriptions} + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + ${descriptions} + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } - function extendUnionType(type) { - var _typeExtensionsMap$co5; + fragment InputValue on __InputValue { + name + ${descriptions} + type { ...TypeRef } + defaultValue + ${inputDeprecation('isDeprecated')} + ${inputDeprecation('deprecationReason')} + } - const config = type.toConfig(); - const extensions = - (_typeExtensionsMap$co5 = typeExtensionsMap[config.name]) !== null && - _typeExtensionsMap$co5 !== void 0 - ? _typeExtensionsMap$co5 - : []; - return new _definition.GraphQLUnionType({ - ...config, - types: () => [ - ...type.getTypes().map(replaceNamedType), - ...buildUnionTypes(extensions), - ], - extensionASTNodes: config.extensionASTNodes.concat(extensions), - }); - } + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } + } + `; +} - function extendField(field) { - return { - ...field, - type: replaceType(field.type), - args: field.args && (0, _mapValue.mapValue)(field.args, extendArg), - }; - } - function extendArg(arg) { - return { ...arg, type: replaceType(arg.type) }; - } +/***/ }), - function getOperationTypes(nodes) { - const opTypes = {}; +/***/ 43793: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - for (const node of nodes) { - var _node$operationTypes; +"use strict"; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const operationTypesNodes = - /* c8 ignore next */ - (_node$operationTypes = node.operationTypes) !== null && - _node$operationTypes !== void 0 - ? _node$operationTypes - : []; - for (const operationType of operationTypesNodes) { - // Note: While this could make early assertions to get the correctly - // typed values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - opTypes[operationType.operation] = getNamedType(operationType.type); - } - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getOperationAST = getOperationAST; - return opTypes; - } +var _kinds = __nccwpck_require__(36096); - function getNamedType(node) { - var _stdTypeMap$name2; +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ +function getOperationAST(documentAST, operationName) { + let operation = null; - const name = node.name.value; - const type = - (_stdTypeMap$name2 = stdTypeMap[name]) !== null && - _stdTypeMap$name2 !== void 0 - ? _stdTypeMap$name2 - : typeMap[name]; + for (const definition of documentAST.definitions) { + if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) { + var _definition$name; - if (type === undefined) { - throw new Error(`Unknown type: "${name}".`); - } + if (operationName == null) { + // If no operation name was provided, only return an Operation if there + // is one defined in the document. Upon encountering the second, return + // null. + if (operation) { + return null; + } - return type; + operation = definition; + } else if ( + ((_definition$name = definition.name) === null || + _definition$name === void 0 + ? void 0 + : _definition$name.value) === operationName + ) { + return definition; + } + } } - function getWrappedType(node) { - if (node.kind === _kinds.Kind.LIST_TYPE) { - return new _definition.GraphQLList(getWrappedType(node.type)); - } + return operation; +} - if (node.kind === _kinds.Kind.NON_NULL_TYPE) { - return new _definition.GraphQLNonNull(getWrappedType(node.type)); - } - return getNamedType(node); - } +/***/ }), - function buildDirective(node) { - var _node$description; +/***/ 30555: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - return new _directives.GraphQLDirective({ - name: node.name.value, - description: - (_node$description = node.description) === null || - _node$description === void 0 - ? void 0 - : _node$description.value, - // @ts-expect-error - locations: node.locations.map(({ value }) => value), - isRepeatable: node.repeatable, - args: buildArgumentMap(node.arguments), - astNode: node, - }); - } +"use strict"; - function buildFieldMap(nodes) { - const fieldConfigMap = Object.create(null); - for (const node of nodes) { - var _node$fields; +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getOperationRootType = getOperationRootType; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const nodeFields = - /* c8 ignore next */ - (_node$fields = node.fields) !== null && _node$fields !== void 0 - ? _node$fields - : []; +var _GraphQLError = __nccwpck_require__(93192); - for (const field of nodeFields) { - var _field$description; +/** + * Extracts the root type of the operation from the schema. + * + * @deprecated Please use `GraphQLSchema.getRootType` instead. Will be removed in v17 + */ +function getOperationRootType(schema, operation) { + if (operation.operation === 'query') { + const queryType = schema.getQueryType(); - fieldConfigMap[field.name.value] = { - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - type: getWrappedType(field.type), - description: - (_field$description = field.description) === null || - _field$description === void 0 - ? void 0 - : _field$description.value, - args: buildArgumentMap(field.arguments), - deprecationReason: getDeprecationReason(field), - astNode: field, - }; - } + if (!queryType) { + throw new _GraphQLError.GraphQLError( + 'Schema does not define the required query root type.', + { + nodes: operation, + }, + ); } - return fieldConfigMap; + return queryType; } - function buildArgumentMap(args) { - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const argsNodes = - /* c8 ignore next */ - args !== null && args !== void 0 ? args : []; - const argConfigMap = Object.create(null); - - for (const arg of argsNodes) { - var _arg$description; + if (operation.operation === 'mutation') { + const mutationType = schema.getMutationType(); - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - const type = getWrappedType(arg.type); - argConfigMap[arg.name.value] = { - type, - description: - (_arg$description = arg.description) === null || - _arg$description === void 0 - ? void 0 - : _arg$description.value, - defaultValue: (0, _valueFromAST.valueFromAST)(arg.defaultValue, type), - deprecationReason: getDeprecationReason(arg), - astNode: arg, - }; + if (!mutationType) { + throw new _GraphQLError.GraphQLError( + 'Schema is not configured for mutations.', + { + nodes: operation, + }, + ); } - return argConfigMap; + return mutationType; } - function buildInputFieldMap(nodes) { - const inputFieldMap = Object.create(null); - - for (const node of nodes) { - var _node$fields2; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const fieldsNodes = - /* c8 ignore next */ - (_node$fields2 = node.fields) !== null && _node$fields2 !== void 0 - ? _node$fields2 - : []; - - for (const field of fieldsNodes) { - var _field$description2; + if (operation.operation === 'subscription') { + const subscriptionType = schema.getSubscriptionType(); - // Note: While this could make assertions to get the correctly typed - // value, that would throw immediately while type system validation - // with validateSchema() will produce more actionable results. - const type = getWrappedType(field.type); - inputFieldMap[field.name.value] = { - type, - description: - (_field$description2 = field.description) === null || - _field$description2 === void 0 - ? void 0 - : _field$description2.value, - defaultValue: (0, _valueFromAST.valueFromAST)( - field.defaultValue, - type, - ), - deprecationReason: getDeprecationReason(field), - astNode: field, - }; - } + if (!subscriptionType) { + throw new _GraphQLError.GraphQLError( + 'Schema is not configured for subscriptions.', + { + nodes: operation, + }, + ); } - return inputFieldMap; + return subscriptionType; } - function buildEnumValueMap(nodes) { - const enumValueMap = Object.create(null); - - for (const node of nodes) { - var _node$values; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const valuesNodes = - /* c8 ignore next */ - (_node$values = node.values) !== null && _node$values !== void 0 - ? _node$values - : []; + throw new _GraphQLError.GraphQLError( + 'Can only have query, mutation and subscription operations.', + { + nodes: operation, + }, + ); +} - for (const value of valuesNodes) { - var _value$description; - enumValueMap[value.name.value] = { - description: - (_value$description = value.description) === null || - _value$description === void 0 - ? void 0 - : _value$description.value, - deprecationReason: getDeprecationReason(value), - astNode: value, - }; - } - } +/***/ }), - return enumValueMap; - } +/***/ 80669: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - function buildInterfaces(nodes) { - // Note: While this could make assertions to get the correctly typed - // values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - return nodes.flatMap( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - (node) => { - var _node$interfaces$map, _node$interfaces; +"use strict"; - return ( - /* c8 ignore next */ - (_node$interfaces$map = - (_node$interfaces = node.interfaces) === null || - _node$interfaces === void 0 - ? void 0 - : _node$interfaces.map(getNamedType)) !== null && - _node$interfaces$map !== void 0 - ? _node$interfaces$map - : [] - ); - }, - ); - } - function buildUnionTypes(nodes) { - // Note: While this could make assertions to get the correctly typed - // values below, that would throw immediately while type system - // validation with validateSchema() will produce more actionable results. - // @ts-expect-error - return nodes.flatMap( - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - (node) => { - var _node$types$map, _node$types; +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "BreakingChangeType", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.BreakingChangeType; + }, +})); +Object.defineProperty(exports, "DangerousChangeType", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.DangerousChangeType; + }, +})); +Object.defineProperty(exports, "TypeInfo", ({ + enumerable: true, + get: function () { + return _TypeInfo.TypeInfo; + }, +})); +Object.defineProperty(exports, "assertValidName", ({ + enumerable: true, + get: function () { + return _assertValidName.assertValidName; + }, +})); +Object.defineProperty(exports, "astFromValue", ({ + enumerable: true, + get: function () { + return _astFromValue.astFromValue; + }, +})); +Object.defineProperty(exports, "buildASTSchema", ({ + enumerable: true, + get: function () { + return _buildASTSchema.buildASTSchema; + }, +})); +Object.defineProperty(exports, "buildClientSchema", ({ + enumerable: true, + get: function () { + return _buildClientSchema.buildClientSchema; + }, +})); +Object.defineProperty(exports, "buildSchema", ({ + enumerable: true, + get: function () { + return _buildASTSchema.buildSchema; + }, +})); +Object.defineProperty(exports, "coerceInputValue", ({ + enumerable: true, + get: function () { + return _coerceInputValue.coerceInputValue; + }, +})); +Object.defineProperty(exports, "concatAST", ({ + enumerable: true, + get: function () { + return _concatAST.concatAST; + }, +})); +Object.defineProperty(exports, "doTypesOverlap", ({ + enumerable: true, + get: function () { + return _typeComparators.doTypesOverlap; + }, +})); +Object.defineProperty(exports, "extendSchema", ({ + enumerable: true, + get: function () { + return _extendSchema.extendSchema; + }, +})); +Object.defineProperty(exports, "findBreakingChanges", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.findBreakingChanges; + }, +})); +Object.defineProperty(exports, "findDangerousChanges", ({ + enumerable: true, + get: function () { + return _findBreakingChanges.findDangerousChanges; + }, +})); +Object.defineProperty(exports, "getIntrospectionQuery", ({ + enumerable: true, + get: function () { + return _getIntrospectionQuery.getIntrospectionQuery; + }, +})); +Object.defineProperty(exports, "getOperationAST", ({ + enumerable: true, + get: function () { + return _getOperationAST.getOperationAST; + }, +})); +Object.defineProperty(exports, "getOperationRootType", ({ + enumerable: true, + get: function () { + return _getOperationRootType.getOperationRootType; + }, +})); +Object.defineProperty(exports, "introspectionFromSchema", ({ + enumerable: true, + get: function () { + return _introspectionFromSchema.introspectionFromSchema; + }, +})); +Object.defineProperty(exports, "isEqualType", ({ + enumerable: true, + get: function () { + return _typeComparators.isEqualType; + }, +})); +Object.defineProperty(exports, "isTypeSubTypeOf", ({ + enumerable: true, + get: function () { + return _typeComparators.isTypeSubTypeOf; + }, +})); +Object.defineProperty(exports, "isValidNameError", ({ + enumerable: true, + get: function () { + return _assertValidName.isValidNameError; + }, +})); +Object.defineProperty(exports, "lexicographicSortSchema", ({ + enumerable: true, + get: function () { + return _lexicographicSortSchema.lexicographicSortSchema; + }, +})); +Object.defineProperty(exports, "printIntrospectionSchema", ({ + enumerable: true, + get: function () { + return _printSchema.printIntrospectionSchema; + }, +})); +Object.defineProperty(exports, "printSchema", ({ + enumerable: true, + get: function () { + return _printSchema.printSchema; + }, +})); +Object.defineProperty(exports, "printType", ({ + enumerable: true, + get: function () { + return _printSchema.printType; + }, +})); +Object.defineProperty(exports, "separateOperations", ({ + enumerable: true, + get: function () { + return _separateOperations.separateOperations; + }, +})); +Object.defineProperty(exports, "stripIgnoredCharacters", ({ + enumerable: true, + get: function () { + return _stripIgnoredCharacters.stripIgnoredCharacters; + }, +})); +Object.defineProperty(exports, "typeFromAST", ({ + enumerable: true, + get: function () { + return _typeFromAST.typeFromAST; + }, +})); +Object.defineProperty(exports, "valueFromAST", ({ + enumerable: true, + get: function () { + return _valueFromAST.valueFromAST; + }, +})); +Object.defineProperty(exports, "valueFromASTUntyped", ({ + enumerable: true, + get: function () { + return _valueFromASTUntyped.valueFromASTUntyped; + }, +})); +Object.defineProperty(exports, "visitWithTypeInfo", ({ + enumerable: true, + get: function () { + return _TypeInfo.visitWithTypeInfo; + }, +})); - return ( - /* c8 ignore next */ - (_node$types$map = - (_node$types = node.types) === null || _node$types === void 0 - ? void 0 - : _node$types.map(getNamedType)) !== null && - _node$types$map !== void 0 - ? _node$types$map - : [] - ); - }, - ); - } +var _getIntrospectionQuery = __nccwpck_require__(8902); - function buildType(astNode) { - var _typeExtensionsMap$na; +var _getOperationAST = __nccwpck_require__(43793); - const name = astNode.name.value; - const extensionASTNodes = - (_typeExtensionsMap$na = typeExtensionsMap[name]) !== null && - _typeExtensionsMap$na !== void 0 - ? _typeExtensionsMap$na - : []; +var _getOperationRootType = __nccwpck_require__(30555); - switch (astNode.kind) { - case _kinds.Kind.OBJECT_TYPE_DEFINITION: { - var _astNode$description; +var _introspectionFromSchema = __nccwpck_require__(26579); - const allNodes = [astNode, ...extensionASTNodes]; - return new _definition.GraphQLObjectType({ - name, - description: - (_astNode$description = astNode.description) === null || - _astNode$description === void 0 - ? void 0 - : _astNode$description.value, - interfaces: () => buildInterfaces(allNodes), - fields: () => buildFieldMap(allNodes), - astNode, - extensionASTNodes, - }); - } +var _buildClientSchema = __nccwpck_require__(27828); - case _kinds.Kind.INTERFACE_TYPE_DEFINITION: { - var _astNode$description2; +var _buildASTSchema = __nccwpck_require__(22079); - const allNodes = [astNode, ...extensionASTNodes]; - return new _definition.GraphQLInterfaceType({ - name, - description: - (_astNode$description2 = astNode.description) === null || - _astNode$description2 === void 0 - ? void 0 - : _astNode$description2.value, - interfaces: () => buildInterfaces(allNodes), - fields: () => buildFieldMap(allNodes), - astNode, - extensionASTNodes, - }); - } +var _extendSchema = __nccwpck_require__(28218); - case _kinds.Kind.ENUM_TYPE_DEFINITION: { - var _astNode$description3; +var _lexicographicSortSchema = __nccwpck_require__(22997); - const allNodes = [astNode, ...extensionASTNodes]; - return new _definition.GraphQLEnumType({ - name, - description: - (_astNode$description3 = astNode.description) === null || - _astNode$description3 === void 0 - ? void 0 - : _astNode$description3.value, - values: buildEnumValueMap(allNodes), - astNode, - extensionASTNodes, - }); - } +var _printSchema = __nccwpck_require__(13852); - case _kinds.Kind.UNION_TYPE_DEFINITION: { - var _astNode$description4; +var _typeFromAST = __nccwpck_require__(20207); - const allNodes = [astNode, ...extensionASTNodes]; - return new _definition.GraphQLUnionType({ - name, - description: - (_astNode$description4 = astNode.description) === null || - _astNode$description4 === void 0 - ? void 0 - : _astNode$description4.value, - types: () => buildUnionTypes(allNodes), - astNode, - extensionASTNodes, - }); - } +var _valueFromAST = __nccwpck_require__(71964); - case _kinds.Kind.SCALAR_TYPE_DEFINITION: { - var _astNode$description5; +var _valueFromASTUntyped = __nccwpck_require__(97416); - return new _definition.GraphQLScalarType({ - name, - description: - (_astNode$description5 = astNode.description) === null || - _astNode$description5 === void 0 - ? void 0 - : _astNode$description5.value, - specifiedByURL: getSpecifiedByURL(astNode), - astNode, - extensionASTNodes, - }); - } +var _astFromValue = __nccwpck_require__(61402); - case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: { - var _astNode$description6; +var _TypeInfo = __nccwpck_require__(63981); - const allNodes = [astNode, ...extensionASTNodes]; - return new _definition.GraphQLInputObjectType({ - name, - description: - (_astNode$description6 = astNode.description) === null || - _astNode$description6 === void 0 - ? void 0 - : _astNode$description6.value, - fields: () => buildInputFieldMap(allNodes), - astNode, - extensionASTNodes, - }); - } - } - } -} +var _coerceInputValue = __nccwpck_require__(47416); -const stdTypeMap = (0, _keyMap.keyMap)( - [..._scalars.specifiedScalarTypes, ..._introspection.introspectionTypes], - (type) => type.name, -); -/** - * Given a field or enum value node, returns the string value for the - * deprecation reason. - */ +var _concatAST = __nccwpck_require__(53841); -function getDeprecationReason(node) { - const deprecated = (0, _values.getDirectiveValues)( - _directives.GraphQLDeprecatedDirective, - node, - ); // @ts-expect-error validated by `getDirectiveValues` +var _separateOperations = __nccwpck_require__(23751); - return deprecated === null || deprecated === void 0 - ? void 0 - : deprecated.reason; -} -/** - * Given a scalar node, returns the string value for the specifiedByURL. - */ +var _stripIgnoredCharacters = __nccwpck_require__(79345); -function getSpecifiedByURL(node) { - const specifiedBy = (0, _values.getDirectiveValues)( - _directives.GraphQLSpecifiedByDirective, - node, - ); // @ts-expect-error validated by `getDirectiveValues` +var _typeComparators = __nccwpck_require__(33981); - return specifiedBy === null || specifiedBy === void 0 - ? void 0 - : specifiedBy.url; -} +var _assertValidName = __nccwpck_require__(63786); + +var _findBreakingChanges = __nccwpck_require__(1791); /***/ }), -/***/ 4778: +/***/ 26579: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -32937,502 +57391,387 @@ function getSpecifiedByURL(node) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.DangerousChangeType = exports.BreakingChangeType = void 0; -exports.findBreakingChanges = findBreakingChanges; -exports.findDangerousChanges = findDangerousChanges; +exports.introspectionFromSchema = introspectionFromSchema; -var _inspect = __nccwpck_require__(70715); +var _invariant = __nccwpck_require__(31338); -var _invariant = __nccwpck_require__(28864); +var _parser = __nccwpck_require__(8515); -var _keyMap = __nccwpck_require__(65169); +var _execute = __nccwpck_require__(75510); -var _printer = __nccwpck_require__(46157); +var _getIntrospectionQuery = __nccwpck_require__(8902); -var _definition = __nccwpck_require__(82341); +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ +function introspectionFromSchema(schema, options) { + const optionsWithDefaults = { + specifiedByUrl: true, + directiveIsRepeatable: true, + schemaDescription: true, + inputValueDeprecation: true, + ...options, + }; + const document = (0, _parser.parse)( + (0, _getIntrospectionQuery.getIntrospectionQuery)(optionsWithDefaults), + ); + const result = (0, _execute.executeSync)({ + schema, + document, + }); + (!result.errors && result.data) || (0, _invariant.invariant)(false); + return result.data; +} -var _scalars = __nccwpck_require__(41963); -var _astFromValue = __nccwpck_require__(14268); +/***/ }), -var _sortValueNode = __nccwpck_require__(20104); +/***/ 22997: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var BreakingChangeType; -exports.BreakingChangeType = BreakingChangeType; +"use strict"; -(function (BreakingChangeType) { - BreakingChangeType['TYPE_REMOVED'] = 'TYPE_REMOVED'; - BreakingChangeType['TYPE_CHANGED_KIND'] = 'TYPE_CHANGED_KIND'; - BreakingChangeType['TYPE_REMOVED_FROM_UNION'] = 'TYPE_REMOVED_FROM_UNION'; - BreakingChangeType['VALUE_REMOVED_FROM_ENUM'] = 'VALUE_REMOVED_FROM_ENUM'; - BreakingChangeType['REQUIRED_INPUT_FIELD_ADDED'] = - 'REQUIRED_INPUT_FIELD_ADDED'; - BreakingChangeType['IMPLEMENTED_INTERFACE_REMOVED'] = - 'IMPLEMENTED_INTERFACE_REMOVED'; - BreakingChangeType['FIELD_REMOVED'] = 'FIELD_REMOVED'; - BreakingChangeType['FIELD_CHANGED_KIND'] = 'FIELD_CHANGED_KIND'; - BreakingChangeType['REQUIRED_ARG_ADDED'] = 'REQUIRED_ARG_ADDED'; - BreakingChangeType['ARG_REMOVED'] = 'ARG_REMOVED'; - BreakingChangeType['ARG_CHANGED_KIND'] = 'ARG_CHANGED_KIND'; - BreakingChangeType['DIRECTIVE_REMOVED'] = 'DIRECTIVE_REMOVED'; - BreakingChangeType['DIRECTIVE_ARG_REMOVED'] = 'DIRECTIVE_ARG_REMOVED'; - BreakingChangeType['REQUIRED_DIRECTIVE_ARG_ADDED'] = - 'REQUIRED_DIRECTIVE_ARG_ADDED'; - BreakingChangeType['DIRECTIVE_REPEATABLE_REMOVED'] = - 'DIRECTIVE_REPEATABLE_REMOVED'; - BreakingChangeType['DIRECTIVE_LOCATION_REMOVED'] = - 'DIRECTIVE_LOCATION_REMOVED'; -})( - BreakingChangeType || (exports.BreakingChangeType = BreakingChangeType = {}), -); -var DangerousChangeType; -exports.DangerousChangeType = DangerousChangeType; +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.lexicographicSortSchema = lexicographicSortSchema; -(function (DangerousChangeType) { - DangerousChangeType['VALUE_ADDED_TO_ENUM'] = 'VALUE_ADDED_TO_ENUM'; - DangerousChangeType['TYPE_ADDED_TO_UNION'] = 'TYPE_ADDED_TO_UNION'; - DangerousChangeType['OPTIONAL_INPUT_FIELD_ADDED'] = - 'OPTIONAL_INPUT_FIELD_ADDED'; - DangerousChangeType['OPTIONAL_ARG_ADDED'] = 'OPTIONAL_ARG_ADDED'; - DangerousChangeType['IMPLEMENTED_INTERFACE_ADDED'] = - 'IMPLEMENTED_INTERFACE_ADDED'; - DangerousChangeType['ARG_DEFAULT_VALUE_CHANGE'] = 'ARG_DEFAULT_VALUE_CHANGE'; -})( - DangerousChangeType || - (exports.DangerousChangeType = DangerousChangeType = {}), -); +var _inspect = __nccwpck_require__(85856); + +var _invariant = __nccwpck_require__(31338); + +var _keyValMap = __nccwpck_require__(63345); + +var _naturalCompare = __nccwpck_require__(72220); + +var _definition = __nccwpck_require__(57741); + +var _directives = __nccwpck_require__(50828); + +var _introspection = __nccwpck_require__(8077); + +var _schema = __nccwpck_require__(354); /** - * Given two schemas, returns an Array containing descriptions of all the types - * of breaking changes covered by the other functions down below. + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. */ -function findBreakingChanges(oldSchema, newSchema) { - // @ts-expect-error - return findSchemaChanges(oldSchema, newSchema).filter( - (change) => change.type in BreakingChangeType, +function lexicographicSortSchema(schema) { + const schemaConfig = schema.toConfig(); + const typeMap = (0, _keyValMap.keyValMap)( + sortByName(schemaConfig.types), + (type) => type.name, + sortNamedType, ); -} -/** - * Given two schemas, returns an Array containing descriptions of all the types - * of potentially dangerous changes covered by the other functions down below. - */ + return new _schema.GraphQLSchema({ + ...schemaConfig, + types: Object.values(typeMap), + directives: sortByName(schemaConfig.directives).map(sortDirective), + query: replaceMaybeType(schemaConfig.query), + mutation: replaceMaybeType(schemaConfig.mutation), + subscription: replaceMaybeType(schemaConfig.subscription), + }); -function findDangerousChanges(oldSchema, newSchema) { - // @ts-expect-error - return findSchemaChanges(oldSchema, newSchema).filter( - (change) => change.type in DangerousChangeType, - ); -} + function replaceType(type) { + if ((0, _definition.isListType)(type)) { + // @ts-expect-error + return new _definition.GraphQLList(replaceType(type.ofType)); + } else if ((0, _definition.isNonNullType)(type)) { + // @ts-expect-error + return new _definition.GraphQLNonNull(replaceType(type.ofType)); + } // @ts-expect-error FIXME: TS Conversion -function findSchemaChanges(oldSchema, newSchema) { - return [ - ...findTypeChanges(oldSchema, newSchema), - ...findDirectiveChanges(oldSchema, newSchema), - ]; -} + return replaceNamedType(type); + } -function findDirectiveChanges(oldSchema, newSchema) { - const schemaChanges = []; - const directivesDiff = diff( - oldSchema.getDirectives(), - newSchema.getDirectives(), - ); + function replaceNamedType(type) { + return typeMap[type.name]; + } - for (const oldDirective of directivesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_REMOVED, - description: `${oldDirective.name} was removed.`, + function replaceMaybeType(maybeType) { + return maybeType && replaceNamedType(maybeType); + } + + function sortDirective(directive) { + const config = directive.toConfig(); + return new _directives.GraphQLDirective({ + ...config, + locations: sortBy(config.locations, (x) => x), + args: sortArgs(config.args), }); } - for (const [oldDirective, newDirective] of directivesDiff.persisted) { - const argsDiff = diff(oldDirective.args, newDirective.args); + function sortArgs(args) { + return sortObjMap(args, (arg) => ({ ...arg, type: replaceType(arg.type) })); + } - for (const newArg of argsDiff.added) { - if ((0, _definition.isRequiredArgument)(newArg)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, - description: `A required arg ${newArg.name} on directive ${oldDirective.name} was added.`, - }); - } + function sortFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + args: field.args && sortArgs(field.args), + })); + } + + function sortInputFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + })); + } + + function sortTypes(array) { + return sortByName(array).map(replaceNamedType); + } + + function sortNamedType(type) { + if ( + (0, _definition.isScalarType)(type) || + (0, _introspection.isIntrospectionType)(type) + ) { + return type; } - for (const oldArg of argsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, - description: `${oldArg.name} was removed from ${oldDirective.name}.`, + if ((0, _definition.isObjectType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLObjectType({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), }); } - if (oldDirective.isRepeatable && !newDirective.isRepeatable) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, - description: `Repeatable flag was removed from ${oldDirective.name}.`, + if ((0, _definition.isInterfaceType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLInterfaceType({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), }); } - for (const location of oldDirective.locations) { - if (!newDirective.locations.includes(location)) { - schemaChanges.push({ - type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, - description: `${location} was removed from ${oldDirective.name}.`, - }); - } + if ((0, _definition.isUnionType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLUnionType({ + ...config, + types: () => sortTypes(config.types), + }); } - } - return schemaChanges; -} + if ((0, _definition.isEnumType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLEnumType({ + ...config, + values: sortObjMap(config.values, (value) => value), + }); + } -function findTypeChanges(oldSchema, newSchema) { - const schemaChanges = []; - const typesDiff = diff( - Object.values(oldSchema.getTypeMap()), - Object.values(newSchema.getTypeMap()), - ); + if ((0, _definition.isInputObjectType)(type)) { + const config = type.toConfig(); + return new _definition.GraphQLInputObjectType({ + ...config, + fields: () => sortInputFields(config.fields), + }); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. - for (const oldType of typesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_REMOVED, - description: (0, _scalars.isSpecifiedScalarType)(oldType) - ? `Standard scalar ${oldType.name} was removed because it is not referenced anymore.` - : `${oldType.name} was removed.`, - }); + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); } +} - for (const [oldType, newType] of typesDiff.persisted) { - if ( - (0, _definition.isEnumType)(oldType) && - (0, _definition.isEnumType)(newType) - ) { - schemaChanges.push(...findEnumTypeChanges(oldType, newType)); - } else if ( - (0, _definition.isUnionType)(oldType) && - (0, _definition.isUnionType)(newType) - ) { - schemaChanges.push(...findUnionTypeChanges(oldType, newType)); - } else if ( - (0, _definition.isInputObjectType)(oldType) && - (0, _definition.isInputObjectType)(newType) - ) { - schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); - } else if ( - (0, _definition.isObjectType)(oldType) && - (0, _definition.isObjectType)(newType) - ) { - schemaChanges.push( - ...findFieldChanges(oldType, newType), - ...findImplementedInterfacesChanges(oldType, newType), - ); - } else if ( - (0, _definition.isInterfaceType)(oldType) && - (0, _definition.isInterfaceType)(newType) - ) { - schemaChanges.push( - ...findFieldChanges(oldType, newType), - ...findImplementedInterfacesChanges(oldType, newType), - ); - } else if (oldType.constructor !== newType.constructor) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_CHANGED_KIND, - description: - `${oldType.name} changed from ` + - `${typeKindName(oldType)} to ${typeKindName(newType)}.`, - }); - } +function sortObjMap(map, sortValueFn) { + const sortedMap = Object.create(null); + + for (const key of Object.keys(map).sort(_naturalCompare.naturalCompare)) { + sortedMap[key] = sortValueFn(map[key]); } - return schemaChanges; + return sortedMap; } -function findInputObjectTypeChanges(oldType, newType) { - const schemaChanges = []; - const fieldsDiff = diff( - Object.values(oldType.getFields()), - Object.values(newType.getFields()), - ); +function sortByName(array) { + return sortBy(array, (obj) => obj.name); +} - for (const newField of fieldsDiff.added) { - if ((0, _definition.isRequiredInputField)(newField)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, - description: `A required field ${newField.name} on input type ${oldType.name} was added.`, - }); - } else { - schemaChanges.push({ - type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, - description: `An optional field ${newField.name} on input type ${oldType.name} was added.`, - }); - } - } +function sortBy(array, mapToKey) { + return array.slice().sort((obj1, obj2) => { + const key1 = mapToKey(obj1); + const key2 = mapToKey(obj2); + return (0, _naturalCompare.naturalCompare)(key1, key2); + }); +} - for (const oldField of fieldsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_REMOVED, - description: `${oldType.name}.${oldField.name} was removed.`, - }); - } - for (const [oldField, newField] of fieldsDiff.persisted) { - const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( - oldField.type, - newField.type, - ); +/***/ }), - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} changed type from ` + - `${String(oldField.type)} to ${String(newField.type)}.`, - }); - } - } +/***/ 13852: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - return schemaChanges; -} +"use strict"; -function findUnionTypeChanges(oldType, newType) { - const schemaChanges = []; - const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); - for (const newPossibleType of possibleTypesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.TYPE_ADDED_TO_UNION, - description: `${newPossibleType.name} was added to union type ${oldType.name}.`, - }); - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printIntrospectionSchema = printIntrospectionSchema; +exports.printSchema = printSchema; +exports.printType = printType; + +var _inspect = __nccwpck_require__(85856); - for (const oldPossibleType of possibleTypesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, - description: `${oldPossibleType.name} was removed from union type ${oldType.name}.`, - }); - } +var _invariant = __nccwpck_require__(31338); - return schemaChanges; -} +var _blockString = __nccwpck_require__(49074); -function findEnumTypeChanges(oldType, newType) { - const schemaChanges = []; - const valuesDiff = diff(oldType.getValues(), newType.getValues()); +var _kinds = __nccwpck_require__(36096); - for (const newValue of valuesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.VALUE_ADDED_TO_ENUM, - description: `${newValue.name} was added to enum type ${oldType.name}.`, - }); - } +var _printer = __nccwpck_require__(54697); - for (const oldValue of valuesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, - description: `${oldValue.name} was removed from enum type ${oldType.name}.`, - }); - } +var _definition = __nccwpck_require__(57741); - return schemaChanges; -} +var _directives = __nccwpck_require__(50828); -function findImplementedInterfacesChanges(oldType, newType) { - const schemaChanges = []; - const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); +var _introspection = __nccwpck_require__(8077); - for (const newInterface of interfacesDiff.added) { - schemaChanges.push({ - type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, - description: `${newInterface.name} added to interfaces implemented by ${oldType.name}.`, - }); - } +var _scalars = __nccwpck_require__(94420); - for (const oldInterface of interfacesDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, - description: `${oldType.name} no longer implements interface ${oldInterface.name}.`, - }); - } +var _astFromValue = __nccwpck_require__(61402); - return schemaChanges; +function printSchema(schema) { + return printFilteredSchema( + schema, + (n) => !(0, _directives.isSpecifiedDirective)(n), + isDefinedType, + ); } -function findFieldChanges(oldType, newType) { - const schemaChanges = []; - const fieldsDiff = diff( - Object.values(oldType.getFields()), - Object.values(newType.getFields()), +function printIntrospectionSchema(schema) { + return printFilteredSchema( + schema, + _directives.isSpecifiedDirective, + _introspection.isIntrospectionType, ); +} - for (const oldField of fieldsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_REMOVED, - description: `${oldType.name}.${oldField.name} was removed.`, - }); - } +function isDefinedType(type) { + return ( + !(0, _scalars.isSpecifiedScalarType)(type) && + !(0, _introspection.isIntrospectionType)(type) + ); +} - for (const [oldField, newField] of fieldsDiff.persisted) { - schemaChanges.push(...findArgChanges(oldType, oldField, newField)); - const isSafe = isChangeSafeForObjectOrInterfaceField( - oldField.type, - newField.type, - ); +function printFilteredSchema(schema, directiveFilter, typeFilter) { + const directives = schema.getDirectives().filter(directiveFilter); + const types = Object.values(schema.getTypeMap()).filter(typeFilter); + return [ + printSchemaDefinition(schema), + ...directives.map((directive) => printDirective(directive)), + ...types.map((type) => printType(type)), + ] + .filter(Boolean) + .join('\n\n'); +} - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.FIELD_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} changed type from ` + - `${String(oldField.type)} to ${String(newField.type)}.`, - }); - } +function printSchemaDefinition(schema) { + if (schema.description == null && isSchemaOfCommonNames(schema)) { + return; } - return schemaChanges; -} - -function findArgChanges(oldType, oldField, newField) { - const schemaChanges = []; - const argsDiff = diff(oldField.args, newField.args); + const operationTypes = []; + const queryType = schema.getQueryType(); - for (const oldArg of argsDiff.removed) { - schemaChanges.push({ - type: BreakingChangeType.ARG_REMOVED, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`, - }); + if (queryType) { + operationTypes.push(` query: ${queryType.name}`); } - for (const [oldArg, newArg] of argsDiff.persisted) { - const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( - oldArg.type, - newArg.type, - ); - - if (!isSafe) { - schemaChanges.push({ - type: BreakingChangeType.ARG_CHANGED_KIND, - description: - `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ` + - `${String(oldArg.type)} to ${String(newArg.type)}.`, - }); - } else if (oldArg.defaultValue !== undefined) { - if (newArg.defaultValue === undefined) { - schemaChanges.push({ - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, - }); - } else { - // Since we looking only for client's observable changes we should - // compare default values in the same representation as they are - // represented inside introspection. - const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type); - const newValueStr = stringifyValue(newArg.defaultValue, newArg.type); + const mutationType = schema.getMutationType(); - if (oldValueStr !== newValueStr) { - schemaChanges.push({ - type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, - description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`, - }); - } - } - } + if (mutationType) { + operationTypes.push(` mutation: ${mutationType.name}`); } - for (const newArg of argsDiff.added) { - if ((0, _definition.isRequiredArgument)(newArg)) { - schemaChanges.push({ - type: BreakingChangeType.REQUIRED_ARG_ADDED, - description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, - }); - } else { - schemaChanges.push({ - type: DangerousChangeType.OPTIONAL_ARG_ADDED, - description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, - }); - } + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + operationTypes.push(` subscription: ${subscriptionType.name}`); } - return schemaChanges; + return printDescription(schema) + `schema {\n${operationTypes.join('\n')}\n}`; } +/** + * GraphQL schema define root types for each type of operation. These types are + * the same as any other type and can be named in any manner, however there is + * a common naming convention: + * + * ```graphql + * schema { + * query: Query + * mutation: Mutation + * subscription: Subscription + * } + * ``` + * + * When using this naming convention, the schema description can be omitted. + */ -function isChangeSafeForObjectOrInterfaceField(oldType, newType) { - if ((0, _definition.isListType)(oldType)) { - return ( - // if they're both lists, make sure the underlying types are compatible - ((0, _definition.isListType)(newType) && - isChangeSafeForObjectOrInterfaceField( - oldType.ofType, - newType.ofType, - )) || // moving from nullable to non-null of the same underlying type is safe - ((0, _definition.isNonNullType)(newType) && - isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) - ); - } +function isSchemaOfCommonNames(schema) { + const queryType = schema.getQueryType(); - if ((0, _definition.isNonNullType)(oldType)) { - // if they're both non-null, make sure the underlying types are compatible - return ( - (0, _definition.isNonNullType)(newType) && - isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) - ); + if (queryType && queryType.name !== 'Query') { + return false; } - return ( - // if they're both named types, see if their names are equivalent - ((0, _definition.isNamedType)(newType) && oldType.name === newType.name) || // moving from nullable to non-null of the same underlying type is safe - ((0, _definition.isNonNullType)(newType) && - isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) - ); -} + const mutationType = schema.getMutationType(); -function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { - if ((0, _definition.isListType)(oldType)) { - // if they're both lists, make sure the underlying types are compatible - return ( - (0, _definition.isListType)(newType) && - isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) - ); + if (mutationType && mutationType.name !== 'Mutation') { + return false; } - if ((0, _definition.isNonNullType)(oldType)) { - return ( - // if they're both non-null, make sure the underlying types are - // compatible - ((0, _definition.isNonNullType)(newType) && - isChangeSafeForInputObjectFieldOrFieldArg( - oldType.ofType, - newType.ofType, - )) || // moving from non-null to nullable of the same underlying type is safe - (!(0, _definition.isNonNullType)(newType) && - isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)) - ); - } // if they're both named types, see if their names are equivalent + const subscriptionType = schema.getSubscriptionType(); - return (0, _definition.isNamedType)(newType) && oldType.name === newType.name; + if (subscriptionType && subscriptionType.name !== 'Subscription') { + return false; + } + + return true; } -function typeKindName(type) { +function printType(type) { if ((0, _definition.isScalarType)(type)) { - return 'a Scalar type'; + return printScalar(type); } if ((0, _definition.isObjectType)(type)) { - return 'an Object type'; + return printObject(type); } if ((0, _definition.isInterfaceType)(type)) { - return 'an Interface type'; + return printInterface(type); } if ((0, _definition.isUnionType)(type)) { - return 'a Union type'; + return printUnion(type); } if ((0, _definition.isEnumType)(type)) { - return 'an Enum type'; + return printEnum(type); } if ((0, _definition.isInputObjectType)(type)) { - return 'an Input type'; + return printInputObject(type); } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. @@ -33444,188 +57783,182 @@ function typeKindName(type) { ); } -function stringifyValue(value, type) { - const ast = (0, _astFromValue.astFromValue)(value, type); - ast != null || (0, _invariant.invariant)(false); - return (0, _printer.print)((0, _sortValueNode.sortValueNode)(ast)); +function printScalar(type) { + return ( + printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) + ); } -function diff(oldArray, newArray) { - const added = []; - const removed = []; - const persisted = []; - const oldMap = (0, _keyMap.keyMap)(oldArray, ({ name }) => name); - const newMap = (0, _keyMap.keyMap)(newArray, ({ name }) => name); +function printImplementedInterfaces(type) { + const interfaces = type.getInterfaces(); + return interfaces.length + ? ' implements ' + interfaces.map((i) => i.name).join(' & ') + : ''; +} - for (const oldItem of oldArray) { - const newItem = newMap[oldItem.name]; +function printObject(type) { + return ( + printDescription(type) + + `type ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} - if (newItem === undefined) { - removed.push(oldItem); - } else { - persisted.push([oldItem, newItem]); - } - } +function printInterface(type) { + return ( + printDescription(type) + + `interface ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} - for (const newItem of newArray) { - if (oldMap[newItem.name] === undefined) { - added.push(newItem); - } +function printUnion(type) { + const types = type.getTypes(); + const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; + return printDescription(type) + 'union ' + type.name + possibleTypes; +} + +function printEnum(type) { + const values = type + .getValues() + .map( + (value, i) => + printDescription(value, ' ', !i) + + ' ' + + value.name + + printDeprecated(value.deprecationReason), + ); + return printDescription(type) + `enum ${type.name}` + printBlock(values); +} + +function printInputObject(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), + ); + return printDescription(type) + `input ${type.name}` + printBlock(fields); +} + +function printFields(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => + printDescription(f, ' ', !i) + + ' ' + + f.name + + printArgs(f.args, ' ') + + ': ' + + String(f.type) + + printDeprecated(f.deprecationReason), + ); + return printBlock(fields); +} + +function printBlock(items) { + return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; +} + +function printArgs(args, indentation = '') { + if (args.length === 0) { + return ''; + } // If every arg does not have a description, print them on one line. + + if (args.every((arg) => !arg.description)) { + return '(' + args.map(printInputValue).join(', ') + ')'; } - return { - added, - persisted, - removed, - }; + return ( + '(\n' + + args + .map( + (arg, i) => + printDescription(arg, ' ' + indentation, !i) + + ' ' + + indentation + + printInputValue(arg), + ) + .join('\n') + + '\n' + + indentation + + ')' + ); } +function printInputValue(arg) { + const defaultAST = (0, _astFromValue.astFromValue)( + arg.defaultValue, + arg.type, + ); + let argDecl = arg.name + ': ' + String(arg.type); -/***/ }), + if (defaultAST) { + argDecl += ` = ${(0, _printer.print)(defaultAST)}`; + } -/***/ 77436: -/***/ ((__unused_webpack_module, exports) => { + return argDecl + printDeprecated(arg.deprecationReason); +} -"use strict"; +function printDirective(directive) { + return ( + printDescription(directive) + + 'directive @' + + directive.name + + printArgs(directive.args) + + (directive.isRepeatable ? ' repeatable' : '') + + ' on ' + + directive.locations.join(' | ') + ); +} +function printDeprecated(reason) { + if (reason == null) { + return ''; + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.getIntrospectionQuery = getIntrospectionQuery; + if (reason !== _directives.DEFAULT_DEPRECATION_REASON) { + const astValue = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: reason, + }); + return ` @deprecated(reason: ${astValue})`; + } -/** - * Produce the GraphQL query recommended for a full schema introspection. - * Accepts optional IntrospectionOptions. - */ -function getIntrospectionQuery(options) { - const optionsWithDefault = { - descriptions: true, - specifiedByUrl: false, - directiveIsRepeatable: false, - schemaDescription: false, - inputValueDeprecation: false, - ...options, - }; - const descriptions = optionsWithDefault.descriptions ? 'description' : ''; - const specifiedByUrl = optionsWithDefault.specifiedByUrl - ? 'specifiedByURL' - : ''; - const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable - ? 'isRepeatable' - : ''; - const schemaDescription = optionsWithDefault.schemaDescription - ? descriptions - : ''; + return ' @deprecated'; +} - function inputDeprecation(str) { - return optionsWithDefault.inputValueDeprecation ? str : ''; +function printSpecifiedByURL(scalar) { + if (scalar.specifiedByURL == null) { + return ''; } - return ` - query IntrospectionQuery { - __schema { - ${schemaDescription} - queryType { name } - mutationType { name } - subscriptionType { name } - types { - ...FullType - } - directives { - name - ${descriptions} - ${directiveIsRepeatable} - locations - args${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - } - } - } + const astValue = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: scalar.specifiedByURL, + }); + return ` @specifiedBy(url: ${astValue})`; +} - fragment FullType on __Type { - kind - name - ${descriptions} - ${specifiedByUrl} - fields(includeDeprecated: true) { - name - ${descriptions} - args${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - type { - ...TypeRef - } - isDeprecated - deprecationReason - } - inputFields${inputDeprecation('(includeDeprecated: true)')} { - ...InputValue - } - interfaces { - ...TypeRef - } - enumValues(includeDeprecated: true) { - name - ${descriptions} - isDeprecated - deprecationReason - } - possibleTypes { - ...TypeRef - } - } +function printDescription(def, indentation = '', firstInBlock = true) { + const { description } = def; - fragment InputValue on __InputValue { - name - ${descriptions} - type { ...TypeRef } - defaultValue - ${inputDeprecation('isDeprecated')} - ${inputDeprecation('deprecationReason')} - } + if (description == null) { + return ''; + } - fragment TypeRef on __Type { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - ofType { - kind - name - } - } - } - } - } - } - } - } - `; + const blockString = (0, _printer.print)({ + kind: _kinds.Kind.STRING, + value: description, + block: (0, _blockString.isPrintableAsBlockString)(description), + }); + const prefix = + indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; } /***/ }), -/***/ 97823: +/***/ 23751: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -33634,49 +57967,94 @@ function getIntrospectionQuery(options) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.getOperationAST = getOperationAST; +exports.separateOperations = separateOperations; + +var _kinds = __nccwpck_require__(36096); -var _kinds = __nccwpck_require__(36578); +var _visitor = __nccwpck_require__(69826); /** - * Returns an operation AST given a document AST and optionally an operation - * name. If a name is not provided, an operation is only returned if only one is - * provided in the document. + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. */ -function getOperationAST(documentAST, operationName) { - let operation = null; +function separateOperations(documentAST) { + const operations = []; + const depGraph = Object.create(null); // Populate metadata and build a dependency graph. - for (const definition of documentAST.definitions) { - if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) { - var _definition$name; + for (const definitionNode of documentAST.definitions) { + switch (definitionNode.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + operations.push(definitionNode); + break; - if (operationName == null) { - // If no operation name was provided, only return an Operation if there - // is one defined in the document. Upon encountering the second, return - // null. - if (operation) { - return null; - } + case _kinds.Kind.FRAGMENT_DEFINITION: + depGraph[definitionNode.name.value] = collectDependencies( + definitionNode.selectionSet, + ); + break; - operation = definition; - } else if ( - ((_definition$name = definition.name) === null || - _definition$name === void 0 - ? void 0 - : _definition$name.value) === operationName - ) { - return definition; + default: // ignore non-executable definitions + } + } // For each operation, produce a new synthesized AST which includes only what + // is necessary for completing that operation. + + const separatedDocumentASTs = Object.create(null); + + for (const operation of operations) { + const dependencies = new Set(); + + for (const fragmentName of collectDependencies(operation.selectionSet)) { + collectTransitiveDependencies(dependencies, depGraph, fragmentName); + } // Provides the empty string for anonymous operations. + + const operationName = operation.name ? operation.name.value : ''; // The list of definition nodes to be included for this operation, sorted + // to retain the same order as the original document. + + separatedDocumentASTs[operationName] = { + kind: _kinds.Kind.DOCUMENT, + definitions: documentAST.definitions.filter( + (node) => + node === operation || + (node.kind === _kinds.Kind.FRAGMENT_DEFINITION && + dependencies.has(node.name.value)), + ), + }; + } + + return separatedDocumentASTs; +} + +// From a dependency graph, collects a list of transitive dependencies by +// recursing through a dependency graph. +function collectTransitiveDependencies(collected, depGraph, fromName) { + if (!collected.has(fromName)) { + collected.add(fromName); + const immediateDeps = depGraph[fromName]; + + if (immediateDeps !== undefined) { + for (const toName of immediateDeps) { + collectTransitiveDependencies(collected, depGraph, toName); } } } +} - return operation; +function collectDependencies(selectionSet) { + const dependencies = []; + (0, _visitor.visit)(selectionSet, { + FragmentSpread(node) { + dependencies.push(node.name.value); + }, + }); + return dependencies; } /***/ }), -/***/ 44995: +/***/ 6177: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -33685,73 +58063,53 @@ function getOperationAST(documentAST, operationName) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.getOperationRootType = getOperationRootType; +exports.sortValueNode = sortValueNode; + +var _naturalCompare = __nccwpck_require__(72220); -var _GraphQLError = __nccwpck_require__(442); +var _kinds = __nccwpck_require__(36096); /** - * Extracts the root type of the operation from the schema. + * Sort ValueNode. * - * @deprecated Please use `GraphQLSchema.getRootType` instead. Will be removed in v17 + * This function returns a sorted copy of the given ValueNode. + * + * @internal */ -function getOperationRootType(schema, operation) { - if (operation.operation === 'query') { - const queryType = schema.getQueryType(); - - if (!queryType) { - throw new _GraphQLError.GraphQLError( - 'Schema does not define the required query root type.', - { - nodes: operation, - }, - ); - } - - return queryType; - } - - if (operation.operation === 'mutation') { - const mutationType = schema.getMutationType(); - - if (!mutationType) { - throw new _GraphQLError.GraphQLError( - 'Schema is not configured for mutations.', - { - nodes: operation, - }, - ); - } - - return mutationType; - } - - if (operation.operation === 'subscription') { - const subscriptionType = schema.getSubscriptionType(); +function sortValueNode(valueNode) { + switch (valueNode.kind) { + case _kinds.Kind.OBJECT: + return { ...valueNode, fields: sortFields(valueNode.fields) }; - if (!subscriptionType) { - throw new _GraphQLError.GraphQLError( - 'Schema is not configured for subscriptions.', - { - nodes: operation, - }, - ); - } + case _kinds.Kind.LIST: + return { ...valueNode, values: valueNode.values.map(sortValueNode) }; - return subscriptionType; + case _kinds.Kind.INT: + case _kinds.Kind.FLOAT: + case _kinds.Kind.STRING: + case _kinds.Kind.BOOLEAN: + case _kinds.Kind.NULL: + case _kinds.Kind.ENUM: + case _kinds.Kind.VARIABLE: + return valueNode; } +} - throw new _GraphQLError.GraphQLError( - 'Can only have query, mutation and subscription operations.', - { - nodes: operation, - }, - ); +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => + (0, _naturalCompare.naturalCompare)(fieldA.name.value, fieldB.name.value), + ); } /***/ }), -/***/ 97206: +/***/ 79345: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -33760,239 +58118,251 @@ function getOperationRootType(schema, operation) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -Object.defineProperty(exports, "BreakingChangeType", ({ - enumerable: true, - get: function () { - return _findBreakingChanges.BreakingChangeType; - }, -})); -Object.defineProperty(exports, "DangerousChangeType", ({ - enumerable: true, - get: function () { - return _findBreakingChanges.DangerousChangeType; - }, -})); -Object.defineProperty(exports, "TypeInfo", ({ - enumerable: true, - get: function () { - return _TypeInfo.TypeInfo; - }, -})); -Object.defineProperty(exports, "assertValidName", ({ - enumerable: true, - get: function () { - return _assertValidName.assertValidName; - }, -})); -Object.defineProperty(exports, "astFromValue", ({ - enumerable: true, - get: function () { - return _astFromValue.astFromValue; - }, -})); -Object.defineProperty(exports, "buildASTSchema", ({ - enumerable: true, - get: function () { - return _buildASTSchema.buildASTSchema; - }, -})); -Object.defineProperty(exports, "buildClientSchema", ({ - enumerable: true, - get: function () { - return _buildClientSchema.buildClientSchema; - }, -})); -Object.defineProperty(exports, "buildSchema", ({ - enumerable: true, - get: function () { - return _buildASTSchema.buildSchema; - }, -})); -Object.defineProperty(exports, "coerceInputValue", ({ - enumerable: true, - get: function () { - return _coerceInputValue.coerceInputValue; - }, -})); -Object.defineProperty(exports, "concatAST", ({ - enumerable: true, - get: function () { - return _concatAST.concatAST; - }, -})); -Object.defineProperty(exports, "doTypesOverlap", ({ - enumerable: true, - get: function () { - return _typeComparators.doTypesOverlap; - }, -})); -Object.defineProperty(exports, "extendSchema", ({ - enumerable: true, - get: function () { - return _extendSchema.extendSchema; - }, -})); -Object.defineProperty(exports, "findBreakingChanges", ({ - enumerable: true, - get: function () { - return _findBreakingChanges.findBreakingChanges; - }, -})); -Object.defineProperty(exports, "findDangerousChanges", ({ - enumerable: true, - get: function () { - return _findBreakingChanges.findDangerousChanges; - }, -})); -Object.defineProperty(exports, "getIntrospectionQuery", ({ - enumerable: true, - get: function () { - return _getIntrospectionQuery.getIntrospectionQuery; - }, -})); -Object.defineProperty(exports, "getOperationAST", ({ - enumerable: true, - get: function () { - return _getOperationAST.getOperationAST; - }, -})); -Object.defineProperty(exports, "getOperationRootType", ({ - enumerable: true, - get: function () { - return _getOperationRootType.getOperationRootType; - }, -})); -Object.defineProperty(exports, "introspectionFromSchema", ({ - enumerable: true, - get: function () { - return _introspectionFromSchema.introspectionFromSchema; - }, -})); -Object.defineProperty(exports, "isEqualType", ({ - enumerable: true, - get: function () { - return _typeComparators.isEqualType; - }, -})); -Object.defineProperty(exports, "isTypeSubTypeOf", ({ - enumerable: true, - get: function () { - return _typeComparators.isTypeSubTypeOf; - }, -})); -Object.defineProperty(exports, "isValidNameError", ({ - enumerable: true, - get: function () { - return _assertValidName.isValidNameError; - }, -})); -Object.defineProperty(exports, "lexicographicSortSchema", ({ - enumerable: true, - get: function () { - return _lexicographicSortSchema.lexicographicSortSchema; - }, -})); -Object.defineProperty(exports, "printIntrospectionSchema", ({ - enumerable: true, - get: function () { - return _printSchema.printIntrospectionSchema; - }, -})); -Object.defineProperty(exports, "printSchema", ({ - enumerable: true, - get: function () { - return _printSchema.printSchema; - }, -})); -Object.defineProperty(exports, "printType", ({ - enumerable: true, - get: function () { - return _printSchema.printType; - }, -})); -Object.defineProperty(exports, "separateOperations", ({ - enumerable: true, - get: function () { - return _separateOperations.separateOperations; - }, -})); -Object.defineProperty(exports, "stripIgnoredCharacters", ({ - enumerable: true, - get: function () { - return _stripIgnoredCharacters.stripIgnoredCharacters; - }, -})); -Object.defineProperty(exports, "typeFromAST", ({ - enumerable: true, - get: function () { - return _typeFromAST.typeFromAST; - }, -})); -Object.defineProperty(exports, "valueFromAST", ({ - enumerable: true, - get: function () { - return _valueFromAST.valueFromAST; - }, -})); -Object.defineProperty(exports, "valueFromASTUntyped", ({ - enumerable: true, - get: function () { - return _valueFromASTUntyped.valueFromASTUntyped; - }, -})); -Object.defineProperty(exports, "visitWithTypeInfo", ({ - enumerable: true, - get: function () { - return _TypeInfo.visitWithTypeInfo; - }, -})); +exports.stripIgnoredCharacters = stripIgnoredCharacters; + +var _blockString = __nccwpck_require__(49074); + +var _lexer = __nccwpck_require__(11548); + +var _source = __nccwpck_require__(43985); + +var _tokenKind = __nccwpck_require__(11142); + +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ +function stripIgnoredCharacters(source) { + const sourceObj = (0, _source.isSource)(source) + ? source + : new _source.Source(source); + const body = sourceObj.body; + const lexer = new _lexer.Lexer(sourceObj); + let strippedBody = ''; + let wasLastAddedTokenNonPunctuator = false; + + while (lexer.advance().kind !== _tokenKind.TokenKind.EOF) { + const currentToken = lexer.token; + const tokenKind = currentToken.kind; + /** + * Every two non-punctuator tokens should have space between them. + * Also prevent case of non-punctuator token following by spread resulting + * in invalid token (e.g. `1...` is invalid Float token). + */ + + const isNonPunctuator = !(0, _lexer.isPunctuatorTokenKind)( + currentToken.kind, + ); + + if (wasLastAddedTokenNonPunctuator) { + if ( + isNonPunctuator || + currentToken.kind === _tokenKind.TokenKind.SPREAD + ) { + strippedBody += ' '; + } + } + + const tokenBody = body.slice(currentToken.start, currentToken.end); -var _getIntrospectionQuery = __nccwpck_require__(77436); + if (tokenKind === _tokenKind.TokenKind.BLOCK_STRING) { + strippedBody += (0, _blockString.printBlockString)(currentToken.value, { + minimize: true, + }); + } else { + strippedBody += tokenBody; + } + + wasLastAddedTokenNonPunctuator = isNonPunctuator; + } + + return strippedBody; +} + + +/***/ }), + +/***/ 33981: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; -var _getOperationAST = __nccwpck_require__(97823); -var _getOperationRootType = __nccwpck_require__(44995); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.doTypesOverlap = doTypesOverlap; +exports.isEqualType = isEqualType; +exports.isTypeSubTypeOf = isTypeSubTypeOf; -var _introspectionFromSchema = __nccwpck_require__(35883); +var _definition = __nccwpck_require__(57741); -var _buildClientSchema = __nccwpck_require__(89653); +/** + * Provided two types, return true if the types are equal (invariant). + */ +function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } // If either type is non-null, the other must also be non-null. -var _buildASTSchema = __nccwpck_require__(81503); + if ( + (0, _definition.isNonNullType)(typeA) && + (0, _definition.isNonNullType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // If either type is a list, the other must also be a list. -var _extendSchema = __nccwpck_require__(14691); + if ( + (0, _definition.isListType)(typeA) && + (0, _definition.isListType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // Otherwise the types are not equal. -var _lexicographicSortSchema = __nccwpck_require__(88506); + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ -var _printSchema = __nccwpck_require__(22829); +function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } // If superType is non-null, maybeSubType must also be non-null. -var _typeFromAST = __nccwpck_require__(32901); + if ((0, _definition.isNonNullType)(superType)) { + if ((0, _definition.isNonNullType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } -var _valueFromAST = __nccwpck_require__(60962); + return false; + } -var _valueFromASTUntyped = __nccwpck_require__(44051); + if ((0, _definition.isNonNullType)(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } // If superType type is a list, maybeSubType type must also be a list. -var _astFromValue = __nccwpck_require__(14268); + if ((0, _definition.isListType)(superType)) { + if ((0, _definition.isListType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } -var _TypeInfo = __nccwpck_require__(86215); + return false; + } -var _coerceInputValue = __nccwpck_require__(56977); + if ((0, _definition.isListType)(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. -var _concatAST = __nccwpck_require__(17329); + return ( + (0, _definition.isAbstractType)(superType) && + ((0, _definition.isInterfaceType)(maybeSubType) || + (0, _definition.isObjectType)(maybeSubType)) && + schema.isSubType(superType, maybeSubType) + ); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ -var _separateOperations = __nccwpck_require__(4280); +function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } -var _stripIgnoredCharacters = __nccwpck_require__(14778); + if ((0, _definition.isAbstractType)(typeA)) { + if ((0, _definition.isAbstractType)(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } // Determine if the latter type is a possible concrete type of the former. -var _typeComparators = __nccwpck_require__(72159); + return schema.isSubType(typeA, typeB); + } -var _assertValidName = __nccwpck_require__(21570); + if ((0, _definition.isAbstractType)(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } // Otherwise the types do not overlap. -var _findBreakingChanges = __nccwpck_require__(4778); + return false; +} /***/ }), -/***/ 35883: +/***/ 20207: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -34001,48 +58371,33 @@ var _findBreakingChanges = __nccwpck_require__(4778); Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.introspectionFromSchema = introspectionFromSchema; +exports.typeFromAST = typeFromAST; -var _invariant = __nccwpck_require__(28864); +var _kinds = __nccwpck_require__(36096); -var _parser = __nccwpck_require__(89937); +var _definition = __nccwpck_require__(57741); -var _execute = __nccwpck_require__(60201); +function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case _kinds.Kind.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLList(innerType); + } -var _getIntrospectionQuery = __nccwpck_require__(77436); + case _kinds.Kind.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLNonNull(innerType); + } -/** - * Build an IntrospectionQuery from a GraphQLSchema - * - * IntrospectionQuery is useful for utilities that care about type and field - * relationships, but do not need to traverse through those relationships. - * - * This is the inverse of buildClientSchema. The primary use case is outside - * of the server context, for instance when doing schema comparisons. - */ -function introspectionFromSchema(schema, options) { - const optionsWithDefaults = { - specifiedByUrl: true, - directiveIsRepeatable: true, - schemaDescription: true, - inputValueDeprecation: true, - ...options, - }; - const document = (0, _parser.parse)( - (0, _getIntrospectionQuery.getIntrospectionQuery)(optionsWithDefaults), - ); - const result = (0, _execute.executeSync)({ - schema, - document, - }); - (!result.errors && result.data) || (0, _invariant.invariant)(false); - return result.data; + case _kinds.Kind.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } } /***/ }), -/***/ 88506: +/***/ 71964: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -34051,675 +58406,825 @@ function introspectionFromSchema(schema, options) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.lexicographicSortSchema = lexicographicSortSchema; - -var _inspect = __nccwpck_require__(70715); - -var _invariant = __nccwpck_require__(28864); - -var _keyValMap = __nccwpck_require__(98673); +exports.valueFromAST = valueFromAST; -var _naturalCompare = __nccwpck_require__(48917); +var _inspect = __nccwpck_require__(85856); -var _definition = __nccwpck_require__(82341); +var _invariant = __nccwpck_require__(31338); -var _directives = __nccwpck_require__(27602); +var _keyMap = __nccwpck_require__(22660); -var _introspection = __nccwpck_require__(95678); +var _kinds = __nccwpck_require__(36096); -var _schema = __nccwpck_require__(17287); +var _definition = __nccwpck_require__(57741); /** - * Sort GraphQLSchema. + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | * - * This function returns a sorted copy of the given GraphQLSchema. */ -function lexicographicSortSchema(schema) { - const schemaConfig = schema.toConfig(); - const typeMap = (0, _keyValMap.keyValMap)( - sortByName(schemaConfig.types), - (type) => type.name, - sortNamedType, - ); - return new _schema.GraphQLSchema({ - ...schemaConfig, - types: Object.values(typeMap), - directives: sortByName(schemaConfig.directives).map(sortDirective), - query: replaceMaybeType(schemaConfig.query), - mutation: replaceMaybeType(schemaConfig.mutation), - subscription: replaceMaybeType(schemaConfig.subscription), - }); +function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } - function replaceType(type) { - if ((0, _definition.isListType)(type)) { - // @ts-expect-error - return new _definition.GraphQLList(replaceType(type.ofType)); - } else if ((0, _definition.isNonNullType)(type)) { - // @ts-expect-error - return new _definition.GraphQLNonNull(replaceType(type.ofType)); - } // @ts-expect-error FIXME: TS Conversion + if (valueNode.kind === _kinds.Kind.VARIABLE) { + const variableName = valueNode.name.value; - return replaceNamedType(type); - } + if (variables == null || variables[variableName] === undefined) { + // No valid return value. + return; + } - function replaceNamedType(type) { - return typeMap[type.name]; - } + const variableValue = variables[variableName]; - function replaceMaybeType(maybeType) { - return maybeType && replaceNamedType(maybeType); - } + if (variableValue === null && (0, _definition.isNonNullType)(type)) { + return; // Invalid: intentionally return no value. + } // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. - function sortDirective(directive) { - const config = directive.toConfig(); - return new _directives.GraphQLDirective({ - ...config, - locations: sortBy(config.locations, (x) => x), - args: sortArgs(config.args), - }); + return variableValue; } - function sortArgs(args) { - return sortObjMap(args, (arg) => ({ ...arg, type: replaceType(arg.type) })); - } + if ((0, _definition.isNonNullType)(type)) { + if (valueNode.kind === _kinds.Kind.NULL) { + return; // Invalid: intentionally return no value. + } - function sortFields(fieldsMap) { - return sortObjMap(fieldsMap, (field) => ({ - ...field, - type: replaceType(field.type), - args: field.args && sortArgs(field.args), - })); + return valueFromAST(valueNode, type.ofType, variables); } - function sortInputFields(fieldsMap) { - return sortObjMap(fieldsMap, (field) => ({ - ...field, - type: replaceType(field.type), - })); + if (valueNode.kind === _kinds.Kind.NULL) { + // This is explicitly returning the value null. + return null; } - function sortTypes(array) { - return sortByName(array).map(replaceNamedType); - } + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; - function sortNamedType(type) { - if ( - (0, _definition.isScalarType)(type) || - (0, _introspection.isIntrospectionType)(type) - ) { - return type; + if (valueNode.kind === _kinds.Kind.LIST) { + const coercedValues = []; + + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if ((0, _definition.isNonNullType)(itemType)) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(null); + } else { + const itemValue = valueFromAST(itemNode, itemType, variables); + + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(itemValue); + } + } + + return coercedValues; } - if ((0, _definition.isObjectType)(type)) { - const config = type.toConfig(); - return new _definition.GraphQLObjectType({ - ...config, - interfaces: () => sortTypes(config.interfaces), - fields: () => sortFields(config.fields), - }); + const coercedValue = valueFromAST(valueNode, itemType, variables); + + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. } - if ((0, _definition.isInterfaceType)(type)) { - const config = type.toConfig(); - return new _definition.GraphQLInterfaceType({ - ...config, - interfaces: () => sortTypes(config.interfaces), - fields: () => sortFields(config.fields), - }); + return [coercedValue]; + } + + if ((0, _definition.isInputObjectType)(type)) { + if (valueNode.kind !== _kinds.Kind.OBJECT) { + return; // Invalid: intentionally return no value. } - if ((0, _definition.isUnionType)(type)) { - const config = type.toConfig(); - return new _definition.GraphQLUnionType({ - ...config, - types: () => sortTypes(config.types), - }); + const coercedObj = Object.create(null); + const fieldNodes = (0, _keyMap.keyMap)( + valueNode.fields, + (field) => field.name.value, + ); + + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes[field.name]; + + if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + return; // Invalid: intentionally return no value. + } + + continue; + } + + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedObj[field.name] = fieldValue; } - if ((0, _definition.isEnumType)(type)) { - const config = type.toConfig(); - return new _definition.GraphQLEnumType({ - ...config, - values: sortObjMap(config.values, (value) => value), - }); + return coercedObj; + } + + if ((0, _definition.isLeafType)(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + + try { + result = type.parseLiteral(valueNode, variables); + } catch (_error) { + return; // Invalid: intentionally return no value. } - if ((0, _definition.isInputObjectType)(type)) { - const config = type.toConfig(); - return new _definition.GraphQLInputObjectType({ - ...config, - fields: () => sortInputFields(config.fields), - }); + if (result === undefined) { + return; // Invalid: intentionally return no value. } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - false || - (0, _invariant.invariant)( - false, - 'Unexpected type: ' + (0, _inspect.inspect)(type), - ); + return result; } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} // Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. + +function isMissingVariable(valueNode, variables) { + return ( + valueNode.kind === _kinds.Kind.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined) + ); } -function sortObjMap(map, sortValueFn) { - const sortedMap = Object.create(null); - for (const key of Object.keys(map).sort(_naturalCompare.naturalCompare)) { - sortedMap[key] = sortValueFn(map[key]); - } +/***/ }), - return sortedMap; -} +/***/ 97416: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -function sortByName(array) { - return sortBy(array, (obj) => obj.name); -} +"use strict"; -function sortBy(array, mapToKey) { - return array.slice().sort((obj1, obj2) => { - const key1 = mapToKey(obj1); - const key2 = mapToKey(obj2); - return (0, _naturalCompare.naturalCompare)(key1, key2); - }); + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.valueFromASTUntyped = valueFromASTUntyped; + +var _keyValMap = __nccwpck_require__(63345); + +var _kinds = __nccwpck_require__(36096); + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value + * will reflect the provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case _kinds.Kind.NULL: + return null; + + case _kinds.Kind.INT: + return parseInt(valueNode.value, 10); + + case _kinds.Kind.FLOAT: + return parseFloat(valueNode.value); + + case _kinds.Kind.STRING: + case _kinds.Kind.ENUM: + case _kinds.Kind.BOOLEAN: + return valueNode.value; + + case _kinds.Kind.LIST: + return valueNode.values.map((node) => + valueFromASTUntyped(node, variables), + ); + + case _kinds.Kind.OBJECT: + return (0, _keyValMap.keyValMap)( + valueNode.fields, + (field) => field.name.value, + (field) => valueFromASTUntyped(field.value, variables), + ); + + case _kinds.Kind.VARIABLE: + return variables === null || variables === void 0 + ? void 0 + : variables[valueNode.name.value]; + } } -/***/ }), +/***/ }), + +/***/ 62003: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ValidationContext = + exports.SDLValidationContext = + exports.ASTValidationContext = + void 0; + +var _kinds = __nccwpck_require__(36096); + +var _visitor = __nccwpck_require__(69826); + +var _TypeInfo = __nccwpck_require__(63981); + +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + + reportError(error) { + this._onError(error); + } + + getDocument() { + return this._ast; + } -/***/ 22829: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + getFragment(name) { + let fragments; -"use strict"; + if (this._fragments) { + fragments = this._fragments; + } else { + fragments = Object.create(null); + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.printIntrospectionSchema = printIntrospectionSchema; -exports.printSchema = printSchema; -exports.printType = printType; + this._fragments = fragments; + } -var _inspect = __nccwpck_require__(70715); + return fragments[name]; + } -var _invariant = __nccwpck_require__(28864); + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); -var _blockString = __nccwpck_require__(25466); + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; -var _kinds = __nccwpck_require__(36578); + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) { + spreads.push(selection); + } else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } -var _printer = __nccwpck_require__(46157); + this._fragmentSpreads.set(node, spreads); + } -var _definition = __nccwpck_require__(82341); + return spreads; + } -var _directives = __nccwpck_require__(27602); + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); -var _introspection = __nccwpck_require__(95678); + if (!fragments) { + fragments = []; + const collectedNames = Object.create(null); + const nodesToVisit = [operation.selectionSet]; + let node; -var _scalars = __nccwpck_require__(41963); + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; -var _astFromValue = __nccwpck_require__(14268); + if (collectedNames[fragName] !== true) { + collectedNames[fragName] = true; + const fragment = this.getFragment(fragName); -function printSchema(schema) { - return printFilteredSchema( - schema, - (n) => !(0, _directives.isSpecifiedDirective)(n), - isDefinedType, - ); -} + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } -function printIntrospectionSchema(schema) { - return printFilteredSchema( - schema, - _directives.isSpecifiedDirective, - _introspection.isIntrospectionType, - ); -} + this._recursivelyReferencedFragments.set(operation, fragments); + } -function isDefinedType(type) { - return ( - !(0, _scalars.isSpecifiedScalarType)(type) && - !(0, _introspection.isIntrospectionType)(type) - ); + return fragments; + } } -function printFilteredSchema(schema, directiveFilter, typeFilter) { - const directives = schema.getDirectives().filter(directiveFilter); - const types = Object.values(schema.getTypeMap()).filter(typeFilter); - return [ - printSchemaDefinition(schema), - ...directives.map((directive) => printDirective(directive)), - ...types.map((type) => printType(type)), - ] - .filter(Boolean) - .join('\n\n'); -} +exports.ASTValidationContext = ASTValidationContext; -function printSchemaDefinition(schema) { - if (schema.description == null && isSchemaOfCommonNames(schema)) { - return; +class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; } - const operationTypes = []; - const queryType = schema.getQueryType(); + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } - if (queryType) { - operationTypes.push(` query: ${queryType.name}`); + getSchema() { + return this._schema; } +} - const mutationType = schema.getMutationType(); +exports.SDLValidationContext = SDLValidationContext; - if (mutationType) { - operationTypes.push(` mutation: ${mutationType.name}`); +class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); } - const subscriptionType = schema.getSubscriptionType(); + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } - if (subscriptionType) { - operationTypes.push(` subscription: ${subscriptionType.name}`); + getSchema() { + return this._schema; } - return printDescription(schema) + `schema {\n${operationTypes.join('\n')}\n}`; -} -/** - * GraphQL schema define root types for each type of operation. These types are - * the same as any other type and can be named in any manner, however there is - * a common naming convention: - * - * ```graphql - * schema { - * query: Query - * mutation: Mutation - * subscription: Subscription - * } - * ``` - * - * When using this naming convention, the schema description can be omitted. - */ + getVariableUsages(node) { + let usages = this._variableUsages.get(node); -function isSchemaOfCommonNames(schema) { - const queryType = schema.getQueryType(); + if (!usages) { + const newUsages = []; + const typeInfo = new _TypeInfo.TypeInfo(this._schema); + (0, _visitor.visit)( + node, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, { + VariableDefinition: () => false, - if (queryType && queryType.name !== 'Query') { - return false; - } + Variable(variable) { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + defaultValue: typeInfo.getDefaultValue(), + }); + }, + }), + ); + usages = newUsages; - const mutationType = schema.getMutationType(); + this._variableUsages.set(node, usages); + } - if (mutationType && mutationType.name !== 'Mutation') { - return false; + return usages; } - const subscriptionType = schema.getSubscriptionType(); + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); - if (subscriptionType && subscriptionType.name !== 'Subscription') { - return false; - } + if (!usages) { + usages = this.getVariableUsages(operation); - return true; -} + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } -function printType(type) { - if ((0, _definition.isScalarType)(type)) { - return printScalar(type); - } + this._recursiveVariableUsages.set(operation, usages); + } - if ((0, _definition.isObjectType)(type)) { - return printObject(type); + return usages; } - if ((0, _definition.isInterfaceType)(type)) { - return printInterface(type); + getType() { + return this._typeInfo.getType(); } - if ((0, _definition.isUnionType)(type)) { - return printUnion(type); + getParentType() { + return this._typeInfo.getParentType(); } - if ((0, _definition.isEnumType)(type)) { - return printEnum(type); + getInputType() { + return this._typeInfo.getInputType(); } - if ((0, _definition.isInputObjectType)(type)) { - return printInputObject(type); + getParentInputType() { + return this._typeInfo.getParentInputType(); } - /* c8 ignore next 3 */ - // Not reachable, all possible types have been considered. - - false || - (0, _invariant.invariant)( - false, - 'Unexpected type: ' + (0, _inspect.inspect)(type), - ); -} - -function printScalar(type) { - return ( - printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) - ); -} - -function printImplementedInterfaces(type) { - const interfaces = type.getInterfaces(); - return interfaces.length - ? ' implements ' + interfaces.map((i) => i.name).join(' & ') - : ''; -} - -function printObject(type) { - return ( - printDescription(type) + - `type ${type.name}` + - printImplementedInterfaces(type) + - printFields(type) - ); -} - -function printInterface(type) { - return ( - printDescription(type) + - `interface ${type.name}` + - printImplementedInterfaces(type) + - printFields(type) - ); -} - -function printUnion(type) { - const types = type.getTypes(); - const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; - return printDescription(type) + 'union ' + type.name + possibleTypes; -} - -function printEnum(type) { - const values = type - .getValues() - .map( - (value, i) => - printDescription(value, ' ', !i) + - ' ' + - value.name + - printDeprecated(value.deprecationReason), - ); - return printDescription(type) + `enum ${type.name}` + printBlock(values); -} - -function printInputObject(type) { - const fields = Object.values(type.getFields()).map( - (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), - ); - return printDescription(type) + `input ${type.name}` + printBlock(fields); -} - -function printFields(type) { - const fields = Object.values(type.getFields()).map( - (f, i) => - printDescription(f, ' ', !i) + - ' ' + - f.name + - printArgs(f.args, ' ') + - ': ' + - String(f.type) + - printDeprecated(f.deprecationReason), - ); - return printBlock(fields); -} -function printBlock(items) { - return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; -} + getFieldDef() { + return this._typeInfo.getFieldDef(); + } -function printArgs(args, indentation = '') { - if (args.length === 0) { - return ''; - } // If every arg does not have a description, print them on one line. + getDirective() { + return this._typeInfo.getDirective(); + } - if (args.every((arg) => !arg.description)) { - return '(' + args.map(printInputValue).join(', ') + ')'; + getArgument() { + return this._typeInfo.getArgument(); } - return ( - '(\n' + - args - .map( - (arg, i) => - printDescription(arg, ' ' + indentation, !i) + - ' ' + - indentation + - printInputValue(arg), - ) - .join('\n') + - '\n' + - indentation + - ')' - ); + getEnumValue() { + return this._typeInfo.getEnumValue(); + } } -function printInputValue(arg) { - const defaultAST = (0, _astFromValue.astFromValue)( - arg.defaultValue, - arg.type, - ); - let argDecl = arg.name + ': ' + String(arg.type); +exports.ValidationContext = ValidationContext; - if (defaultAST) { - argDecl += ` = ${(0, _printer.print)(defaultAST)}`; - } - return argDecl + printDeprecated(arg.deprecationReason); -} +/***/ }), -function printDirective(directive) { - return ( - printDescription(directive) + - 'directive @' + - directive.name + - printArgs(directive.args) + - (directive.isRepeatable ? ' repeatable' : '') + - ' on ' + - directive.locations.join(' | ') - ); -} +/***/ 99241: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -function printDeprecated(reason) { - if (reason == null) { - return ''; - } +"use strict"; - if (reason !== _directives.DEFAULT_DEPRECATION_REASON) { - const astValue = (0, _printer.print)({ - kind: _kinds.Kind.STRING, - value: reason, - }); - return ` @deprecated(reason: ${astValue})`; - } - return ' @deprecated'; -} +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ + enumerable: true, + get: function () { + return _ExecutableDefinitionsRule.ExecutableDefinitionsRule; + }, +})); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", ({ + enumerable: true, + get: function () { + return _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule; + }, +})); +Object.defineProperty(exports, "KnownArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownArgumentNamesRule.KnownArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownDirectivesRule", ({ + enumerable: true, + get: function () { + return _KnownDirectivesRule.KnownDirectivesRule; + }, +})); +Object.defineProperty(exports, "KnownFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownFragmentNamesRule.KnownFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownTypeNamesRule", ({ + enumerable: true, + get: function () { + return _KnownTypeNamesRule.KnownTypeNamesRule; + }, +})); +Object.defineProperty(exports, "LoneAnonymousOperationRule", ({ + enumerable: true, + get: function () { + return _LoneAnonymousOperationRule.LoneAnonymousOperationRule; + }, +})); +Object.defineProperty(exports, "LoneSchemaDefinitionRule", ({ + enumerable: true, + get: function () { + return _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule; + }, +})); +Object.defineProperty(exports, "NoDeprecatedCustomRule", ({ + enumerable: true, + get: function () { + return _NoDeprecatedCustomRule.NoDeprecatedCustomRule; + }, +})); +Object.defineProperty(exports, "NoFragmentCyclesRule", ({ + enumerable: true, + get: function () { + return _NoFragmentCyclesRule.NoFragmentCyclesRule; + }, +})); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", ({ + enumerable: true, + get: function () { + return _NoSchemaIntrospectionCustomRule.NoSchemaIntrospectionCustomRule; + }, +})); +Object.defineProperty(exports, "NoUndefinedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUndefinedVariablesRule.NoUndefinedVariablesRule; + }, +})); +Object.defineProperty(exports, "NoUnusedFragmentsRule", ({ + enumerable: true, + get: function () { + return _NoUnusedFragmentsRule.NoUnusedFragmentsRule; + }, +})); +Object.defineProperty(exports, "NoUnusedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUnusedVariablesRule.NoUnusedVariablesRule; + }, +})); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", ({ + enumerable: true, + get: function () { + return _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule; + }, +})); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", ({ + enumerable: true, + get: function () { + return _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule; + }, +})); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", ({ + enumerable: true, + get: function () { + return _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule; + }, +})); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", ({ + enumerable: true, + get: function () { + return _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule; + }, +})); +Object.defineProperty(exports, "ScalarLeafsRule", ({ + enumerable: true, + get: function () { + return _ScalarLeafsRule.ScalarLeafsRule; + }, +})); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ + enumerable: true, + get: function () { + return _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentNamesRule.UniqueArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule; + }, +})); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFragmentNamesRule.UniqueFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationNamesRule.UniqueOperationNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationTypesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationTypesRule.UniqueOperationTypesRule; + }, +})); +Object.defineProperty(exports, "UniqueTypeNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueTypeNamesRule.UniqueTypeNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueVariableNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueVariableNamesRule.UniqueVariableNamesRule; + }, +})); +Object.defineProperty(exports, "ValidationContext", ({ + enumerable: true, + get: function () { + return _ValidationContext.ValidationContext; + }, +})); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "VariablesAreInputTypesRule", ({ + enumerable: true, + get: function () { + return _VariablesAreInputTypesRule.VariablesAreInputTypesRule; + }, +})); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", ({ + enumerable: true, + get: function () { + return _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule; + }, +})); +Object.defineProperty(exports, "specifiedRules", ({ + enumerable: true, + get: function () { + return _specifiedRules.specifiedRules; + }, +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.validate; + }, +})); + +var _validate = __nccwpck_require__(16405); -function printSpecifiedByURL(scalar) { - if (scalar.specifiedByURL == null) { - return ''; - } +var _ValidationContext = __nccwpck_require__(62003); - const astValue = (0, _printer.print)({ - kind: _kinds.Kind.STRING, - value: scalar.specifiedByURL, - }); - return ` @specifiedBy(url: ${astValue})`; -} +var _specifiedRules = __nccwpck_require__(22133); -function printDescription(def, indentation = '', firstInBlock = true) { - const { description } = def; +var _ExecutableDefinitionsRule = __nccwpck_require__(75435); - if (description == null) { - return ''; - } +var _FieldsOnCorrectTypeRule = __nccwpck_require__(76404); - const blockString = (0, _printer.print)({ - kind: _kinds.Kind.STRING, - value: description, - block: (0, _blockString.isPrintableAsBlockString)(description), - }); - const prefix = - indentation && !firstInBlock ? '\n' + indentation : indentation; - return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; -} +var _FragmentsOnCompositeTypesRule = __nccwpck_require__(58070); +var _KnownArgumentNamesRule = __nccwpck_require__(48902); -/***/ }), +var _KnownDirectivesRule = __nccwpck_require__(33957); -/***/ 4280: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +var _KnownFragmentNamesRule = __nccwpck_require__(77080); -"use strict"; +var _KnownTypeNamesRule = __nccwpck_require__(90986); +var _LoneAnonymousOperationRule = __nccwpck_require__(41561); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.separateOperations = separateOperations; +var _NoFragmentCyclesRule = __nccwpck_require__(31379); -var _kinds = __nccwpck_require__(36578); +var _NoUndefinedVariablesRule = __nccwpck_require__(79299); -var _visitor = __nccwpck_require__(78625); +var _NoUnusedFragmentsRule = __nccwpck_require__(67081); -/** - * separateOperations accepts a single AST document which may contain many - * operations and fragments and returns a collection of AST documents each of - * which contains a single operation as well the fragment definitions it - * refers to. - */ -function separateOperations(documentAST) { - const operations = []; - const depGraph = Object.create(null); // Populate metadata and build a dependency graph. +var _NoUnusedVariablesRule = __nccwpck_require__(30410); - for (const definitionNode of documentAST.definitions) { - switch (definitionNode.kind) { - case _kinds.Kind.OPERATION_DEFINITION: - operations.push(definitionNode); - break; +var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(10742); - case _kinds.Kind.FRAGMENT_DEFINITION: - depGraph[definitionNode.name.value] = collectDependencies( - definitionNode.selectionSet, - ); - break; +var _PossibleFragmentSpreadsRule = __nccwpck_require__(30727); - default: // ignore non-executable definitions - } - } // For each operation, produce a new synthesized AST which includes only what - // is necessary for completing that operation. +var _ProvidedRequiredArgumentsRule = __nccwpck_require__(96066); - const separatedDocumentASTs = Object.create(null); +var _ScalarLeafsRule = __nccwpck_require__(1312); - for (const operation of operations) { - const dependencies = new Set(); +var _SingleFieldSubscriptionsRule = __nccwpck_require__(38681); - for (const fragmentName of collectDependencies(operation.selectionSet)) { - collectTransitiveDependencies(dependencies, depGraph, fragmentName); - } // Provides the empty string for anonymous operations. +var _UniqueArgumentNamesRule = __nccwpck_require__(19407); - const operationName = operation.name ? operation.name.value : ''; // The list of definition nodes to be included for this operation, sorted - // to retain the same order as the original document. +var _UniqueDirectivesPerLocationRule = __nccwpck_require__(9694); - separatedDocumentASTs[operationName] = { - kind: _kinds.Kind.DOCUMENT, - definitions: documentAST.definitions.filter( - (node) => - node === operation || - (node.kind === _kinds.Kind.FRAGMENT_DEFINITION && - dependencies.has(node.name.value)), - ), - }; - } +var _UniqueFragmentNamesRule = __nccwpck_require__(8644); - return separatedDocumentASTs; -} +var _UniqueInputFieldNamesRule = __nccwpck_require__(77231); -// From a dependency graph, collects a list of transitive dependencies by -// recursing through a dependency graph. -function collectTransitiveDependencies(collected, depGraph, fromName) { - if (!collected.has(fromName)) { - collected.add(fromName); - const immediateDeps = depGraph[fromName]; +var _UniqueOperationNamesRule = __nccwpck_require__(63870); - if (immediateDeps !== undefined) { - for (const toName of immediateDeps) { - collectTransitiveDependencies(collected, depGraph, toName); - } - } - } -} +var _UniqueVariableNamesRule = __nccwpck_require__(10351); -function collectDependencies(selectionSet) { - const dependencies = []; - (0, _visitor.visit)(selectionSet, { - FragmentSpread(node) { - dependencies.push(node.name.value); - }, - }); - return dependencies; -} +var _ValuesOfCorrectTypeRule = __nccwpck_require__(29362); +var _VariablesAreInputTypesRule = __nccwpck_require__(50655); -/***/ }), +var _VariablesInAllowedPositionRule = __nccwpck_require__(93729); -/***/ 20104: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +var _LoneSchemaDefinitionRule = __nccwpck_require__(94081); -"use strict"; +var _UniqueOperationTypesRule = __nccwpck_require__(79072); +var _UniqueTypeNamesRule = __nccwpck_require__(42372); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.sortValueNode = sortValueNode; +var _UniqueEnumValueNamesRule = __nccwpck_require__(57266); -var _naturalCompare = __nccwpck_require__(48917); +var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(20746); -var _kinds = __nccwpck_require__(36578); +var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(16146); -/** - * Sort ValueNode. - * - * This function returns a sorted copy of the given ValueNode. - * - * @internal - */ -function sortValueNode(valueNode) { - switch (valueNode.kind) { - case _kinds.Kind.OBJECT: - return { ...valueNode, fields: sortFields(valueNode.fields) }; +var _UniqueDirectiveNamesRule = __nccwpck_require__(6518); - case _kinds.Kind.LIST: - return { ...valueNode, values: valueNode.values.map(sortValueNode) }; +var _PossibleTypeExtensionsRule = __nccwpck_require__(43548); - case _kinds.Kind.INT: - case _kinds.Kind.FLOAT: - case _kinds.Kind.STRING: - case _kinds.Kind.BOOLEAN: - case _kinds.Kind.NULL: - case _kinds.Kind.ENUM: - case _kinds.Kind.VARIABLE: - return valueNode; - } -} +var _NoDeprecatedCustomRule = __nccwpck_require__(26104); -function sortFields(fields) { - return fields - .map((fieldNode) => ({ - ...fieldNode, - value: sortValueNode(fieldNode.value), - })) - .sort((fieldA, fieldB) => - (0, _naturalCompare.naturalCompare)(fieldA.name.value, fieldB.name.value), - ); -} +var _NoSchemaIntrospectionCustomRule = __nccwpck_require__(23310); /***/ }), -/***/ 14778: +/***/ 75435: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -34728,127 +59233,52 @@ function sortFields(fields) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.stripIgnoredCharacters = stripIgnoredCharacters; - -var _blockString = __nccwpck_require__(25466); +exports.ExecutableDefinitionsRule = ExecutableDefinitionsRule; -var _lexer = __nccwpck_require__(6529); +var _GraphQLError = __nccwpck_require__(93192); -var _source = __nccwpck_require__(51561); +var _kinds = __nccwpck_require__(36096); -var _tokenKind = __nccwpck_require__(9520); +var _predicates = __nccwpck_require__(19007); /** - * Strips characters that are not significant to the validity or execution - * of a GraphQL document: - * - UnicodeBOM - * - WhiteSpace - * - LineTerminator - * - Comment - * - Comma - * - BlockString indentation - * - * Note: It is required to have a delimiter character between neighboring - * non-punctuator tokens and this function always uses single space as delimiter. - * - * It is guaranteed that both input and output documents if parsed would result - * in the exact same AST except for nodes location. - * - * Warning: It is guaranteed that this function will always produce stable results. - * However, it's not guaranteed that it will stay the same between different - * releases due to bugfixes or changes in the GraphQL specification. - * - * Query example: - * - * ```graphql - * query SomeQuery($foo: String!, $bar: String) { - * someField(foo: $foo, bar: $bar) { - * a - * b { - * c - * d - * } - * } - * } - * ``` - * - * Becomes: - * - * ```graphql - * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} - * ``` - * - * SDL example: - * - * ```graphql - * """ - * Type description - * """ - * type Foo { - * """ - * Field description - * """ - * bar: String - * } - * ``` + * Executable definitions * - * Becomes: + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. * - * ```graphql - * """Type description""" type Foo{"""Field description""" bar:String} - * ``` + * See https://spec.graphql.org/draft/#sec-Executable-Definitions */ -function stripIgnoredCharacters(source) { - const sourceObj = (0, _source.isSource)(source) - ? source - : new _source.Source(source); - const body = sourceObj.body; - const lexer = new _lexer.Lexer(sourceObj); - let strippedBody = ''; - let wasLastAddedTokenNonPunctuator = false; - - while (lexer.advance().kind !== _tokenKind.TokenKind.EOF) { - const currentToken = lexer.token; - const tokenKind = currentToken.kind; - /** - * Every two non-punctuator tokens should have space between them. - * Also prevent case of non-punctuator token following by spread resulting - * in invalid token (e.g. `1...` is invalid Float token). - */ - - const isNonPunctuator = !(0, _lexer.isPunctuatorTokenKind)( - currentToken.kind, - ); - - if (wasLastAddedTokenNonPunctuator) { - if ( - isNonPunctuator || - currentToken.kind === _tokenKind.TokenKind.SPREAD - ) { - strippedBody += ' '; +function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!(0, _predicates.isExecutableDefinitionNode)(definition)) { + const defName = + definition.kind === _kinds.Kind.SCHEMA_DEFINITION || + definition.kind === _kinds.Kind.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError( + new _GraphQLError.GraphQLError( + `The ${defName} definition is not executable.`, + { + nodes: definition, + }, + ), + ); + } } - } - - const tokenBody = body.slice(currentToken.start, currentToken.end); - - if (tokenKind === _tokenKind.TokenKind.BLOCK_STRING) { - strippedBody += (0, _blockString.printBlockString)(currentToken.value, { - minimize: true, - }); - } else { - strippedBody += tokenBody; - } - - wasLastAddedTokenNonPunctuator = isNonPunctuator; - } - return strippedBody; + return false; + }, + }; } /***/ }), -/***/ 72159: +/***/ 76404: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -34857,157 +59287,151 @@ function stripIgnoredCharacters(source) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.doTypesOverlap = doTypesOverlap; -exports.isEqualType = isEqualType; -exports.isTypeSubTypeOf = isTypeSubTypeOf; +exports.FieldsOnCorrectTypeRule = FieldsOnCorrectTypeRule; -var _definition = __nccwpck_require__(82341); +var _didYouMean = __nccwpck_require__(4475); -/** - * Provided two types, return true if the types are equal (invariant). - */ -function isEqualType(typeA, typeB) { - // Equivalent types are equal. - if (typeA === typeB) { - return true; - } // If either type is non-null, the other must also be non-null. +var _naturalCompare = __nccwpck_require__(72220); - if ( - (0, _definition.isNonNullType)(typeA) && - (0, _definition.isNonNullType)(typeB) - ) { - return isEqualType(typeA.ofType, typeB.ofType); - } // If either type is a list, the other must also be a list. +var _suggestionList = __nccwpck_require__(11642); - if ( - (0, _definition.isListType)(typeA) && - (0, _definition.isListType)(typeB) - ) { - return isEqualType(typeA.ofType, typeB.ofType); - } // Otherwise the types are not equal. +var _GraphQLError = __nccwpck_require__(93192); + +var _definition = __nccwpck_require__(57741); - return false; -} /** - * Provided a type and a super type, return true if the first type is either - * equal or a subset of the second super type (covariant). + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections */ +function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); -function isTypeSubTypeOf(schema, maybeSubType, superType) { - // Equivalent type is a valid subtype - if (maybeSubType === superType) { - return true; - } // If superType is non-null, maybeSubType must also be non-null. - - if ((0, _definition.isNonNullType)(superType)) { - if ((0, _definition.isNonNullType)(maybeSubType)) { - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); - } - - return false; - } - - if ((0, _definition.isNonNullType)(maybeSubType)) { - // If superType is nullable, maybeSubType may be non-null or nullable. - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); - } // If superType type is a list, maybeSubType type must also be a list. + if (type) { + const fieldDef = context.getFieldDef(); - if ((0, _definition.isListType)(superType)) { - if ((0, _definition.isListType)(maybeSubType)) { - return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); - } + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; // First determine if there are any suggested types to condition on. - return false; - } + let suggestion = (0, _didYouMean.didYouMean)( + 'to use an inline fragment on', + getSuggestedTypeNames(schema, type, fieldName), + ); // If there are no suggested types, then perhaps this was a typo? - if ((0, _definition.isListType)(maybeSubType)) { - // If superType is not a list, maybeSubType must also be not a list. - return false; - } // If superType type is an abstract type, check if it is super type of maybeSubType. - // Otherwise, the child type is not a valid subtype of the parent type. + if (suggestion === '') { + suggestion = (0, _didYouMean.didYouMean)( + getSuggestedFieldNames(type, fieldName), + ); + } // Report an error, including helpful suggestions. - return ( - (0, _definition.isAbstractType)(superType) && - ((0, _definition.isInterfaceType)(maybeSubType) || - (0, _definition.isObjectType)(maybeSubType)) && - schema.isSubType(superType, maybeSubType) - ); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot query field "${fieldName}" on type "${type.name}".` + + suggestion, + { + nodes: node, + }, + ), + ); + } + } + }, + }; } /** - * Provided two composite types, determine if they "overlap". Two composite - * types overlap when the Sets of possible concrete types for each intersect. - * - * This is often used to determine if a fragment of a given type could possibly - * be visited in a context of another type. - * - * This function is commutative. + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. */ -function doTypesOverlap(schema, typeA, typeB) { - // Equivalent types overlap - if (typeA === typeB) { - return true; - } - - if ((0, _definition.isAbstractType)(typeA)) { - if ((0, _definition.isAbstractType)(typeB)) { - // If both types are abstract, then determine if there is any intersection - // between possible concrete types of each. - return schema - .getPossibleTypes(typeA) - .some((type) => schema.isSubType(typeB, type)); - } // Determine if the latter type is a possible concrete type of the former. - - return schema.isSubType(typeA, typeB); +function getSuggestedTypeNames(schema, type, fieldName) { + if (!(0, _definition.isAbstractType)(type)) { + // Must be an Object type, which does not have possible fields. + return []; } - if ((0, _definition.isAbstractType)(typeB)) { - // Determine if the former type is a possible concrete type of the latter. - return schema.isSubType(typeB, typeA); - } // Otherwise the types do not overlap. + const suggestedTypes = new Set(); + const usageCount = Object.create(null); - return false; -} + for (const possibleType of schema.getPossibleTypes(type)) { + if (!possibleType.getFields()[fieldName]) { + continue; + } // This object type defines this field. + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; -/***/ }), + for (const possibleInterface of possibleType.getInterfaces()) { + var _usageCount$possibleI; -/***/ 32901: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (!possibleInterface.getFields()[fieldName]) { + continue; + } // This interface type defines this field. -"use strict"; + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + ((_usageCount$possibleI = usageCount[possibleInterface.name]) !== + null && _usageCount$possibleI !== void 0 + ? _usageCount$possibleI + : 0) + 1; + } + } + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.typeFromAST = typeFromAST; + if (usageCountDiff !== 0) { + return usageCountDiff; + } // Suggest super types first followed by subtypes -var _kinds = __nccwpck_require__(36578); + if ( + (0, _definition.isInterfaceType)(typeA) && + schema.isSubType(typeA, typeB) + ) { + return -1; + } -var _definition = __nccwpck_require__(82341); + if ( + (0, _definition.isInterfaceType)(typeB) && + schema.isSubType(typeB, typeA) + ) { + return 1; + } -function typeFromAST(schema, typeNode) { - switch (typeNode.kind) { - case _kinds.Kind.LIST_TYPE: { - const innerType = typeFromAST(schema, typeNode.type); - return innerType && new _definition.GraphQLList(innerType); - } + return (0, _naturalCompare.naturalCompare)(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ - case _kinds.Kind.NON_NULL_TYPE: { - const innerType = typeFromAST(schema, typeNode.type); - return innerType && new _definition.GraphQLNonNull(innerType); - } +function getSuggestedFieldNames(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + const possibleFieldNames = Object.keys(type.getFields()); + return (0, _suggestionList.suggestionList)(fieldName, possibleFieldNames); + } // Otherwise, must be a Union type, which does not define fields. - case _kinds.Kind.NAMED_TYPE: - return schema.getType(typeNode.name.value); - } + return []; } /***/ }), -/***/ 60962: +/***/ 58070: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -35016,191 +59440,75 @@ function typeFromAST(schema, typeNode) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.valueFromAST = valueFromAST; - -var _inspect = __nccwpck_require__(70715); +exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule; -var _invariant = __nccwpck_require__(28864); +var _GraphQLError = __nccwpck_require__(93192); -var _keyMap = __nccwpck_require__(65169); +var _printer = __nccwpck_require__(54697); -var _kinds = __nccwpck_require__(36578); +var _definition = __nccwpck_require__(57741); -var _definition = __nccwpck_require__(82341); +var _typeFromAST = __nccwpck_require__(20207); /** - * Produces a JavaScript value given a GraphQL Value AST. - * - * A GraphQL type must be provided, which will be used to interpret different - * GraphQL Value literals. - * - * Returns `undefined` when the value could not be validly coerced according to - * the provided type. + * Fragments on composite type * - * | GraphQL Value | JSON Value | - * | -------------------- | ------------- | - * | Input Object | Object | - * | List | Array | - * | Boolean | Boolean | - * | String | String | - * | Int / Float | Number | - * | Enum Value | Unknown | - * | NullValue | null | + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types */ -function valueFromAST(valueNode, type, variables) { - if (!valueNode) { - // When there is no node, then there is also no value. - // Importantly, this is different from returning the value null. - return; - } - - if (valueNode.kind === _kinds.Kind.VARIABLE) { - const variableName = valueNode.name.value; - - if (variables == null || variables[variableName] === undefined) { - // No valid return value. - return; - } - - const variableValue = variables[variableName]; - - if (variableValue === null && (0, _definition.isNonNullType)(type)) { - return; // Invalid: intentionally return no value. - } // Note: This does no further checking that this variable is correct. - // This assumes that this query has been validated and the variable - // usage here is of the correct type. - - return variableValue; - } - - if ((0, _definition.isNonNullType)(type)) { - if (valueNode.kind === _kinds.Kind.NULL) { - return; // Invalid: intentionally return no value. - } - - return valueFromAST(valueNode, type.ofType, variables); - } - - if (valueNode.kind === _kinds.Kind.NULL) { - // This is explicitly returning the value null. - return null; - } - - if ((0, _definition.isListType)(type)) { - const itemType = type.ofType; - - if (valueNode.kind === _kinds.Kind.LIST) { - const coercedValues = []; - - for (const itemNode of valueNode.values) { - if (isMissingVariable(itemNode, variables)) { - // If an array contains a missing variable, it is either coerced to - // null or if the item type is non-null, it considered invalid. - if ((0, _definition.isNonNullType)(itemType)) { - return; // Invalid: intentionally return no value. - } - - coercedValues.push(null); - } else { - const itemValue = valueFromAST(itemNode, itemType, variables); - - if (itemValue === undefined) { - return; // Invalid: intentionally return no value. - } - - coercedValues.push(itemValue); - } - } - - return coercedValues; - } - - const coercedValue = valueFromAST(valueNode, itemType, variables); - - if (coercedValue === undefined) { - return; // Invalid: intentionally return no value. - } - - return [coercedValue]; - } - - if ((0, _definition.isInputObjectType)(type)) { - if (valueNode.kind !== _kinds.Kind.OBJECT) { - return; // Invalid: intentionally return no value. - } - - const coercedObj = Object.create(null); - const fieldNodes = (0, _keyMap.keyMap)( - valueNode.fields, - (field) => field.name.value, - ); +function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; - for (const field of Object.values(type.getFields())) { - const fieldNode = fieldNodes[field.name]; + if (typeCondition) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + typeCondition, + ); - if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { - if (field.defaultValue !== undefined) { - coercedObj[field.name] = field.defaultValue; - } else if ((0, _definition.isNonNullType)(field.type)) { - return; // Invalid: intentionally return no value. + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment cannot condition on non composite type "${typeStr}".`, + { + nodes: typeCondition, + }, + ), + ); } - - continue; } + }, - const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + FragmentDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.typeCondition, + ); - if (fieldValue === undefined) { - return; // Invalid: intentionally return no value. + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(node.typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, + { + nodes: node.typeCondition, + }, + ), + ); } - - coercedObj[field.name] = fieldValue; - } - - return coercedObj; - } - - if ((0, _definition.isLeafType)(type)) { - // Scalars and Enums fulfill parsing a literal value via parseLiteral(). - // Invalid values represent a failure to parse correctly, in which case - // no value is returned. - let result; - - try { - result = type.parseLiteral(valueNode, variables); - } catch (_error) { - return; // Invalid: intentionally return no value. - } - - if (result === undefined) { - return; // Invalid: intentionally return no value. - } - - return result; - } - /* c8 ignore next 3 */ - // Not reachable, all possible input types have been considered. - - false || - (0, _invariant.invariant)( - false, - 'Unexpected input type: ' + (0, _inspect.inspect)(type), - ); -} // Returns true if the provided valueNode is a variable which is not defined -// in the set of variables. - -function isMissingVariable(valueNode, variables) { - return ( - valueNode.kind === _kinds.Kind.VARIABLE && - (variables == null || variables[valueNode.name.value] === undefined) - ); + }, + }; } /***/ }), -/***/ 44051: +/***/ 48902: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -35209,67 +59517,126 @@ function isMissingVariable(valueNode, variables) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.valueFromASTUntyped = valueFromASTUntyped; +exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule; +exports.KnownArgumentNamesRule = KnownArgumentNamesRule; + +var _didYouMean = __nccwpck_require__(4475); + +var _suggestionList = __nccwpck_require__(11642); + +var _GraphQLError = __nccwpck_require__(93192); -var _keyValMap = __nccwpck_require__(98673); +var _kinds = __nccwpck_require__(36096); -var _kinds = __nccwpck_require__(36578); +var _directives = __nccwpck_require__(50828); /** - * Produces a JavaScript value given a GraphQL Value AST. - * - * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value - * will reflect the provided GraphQL value AST. + * Known argument names * - * | GraphQL Value | JavaScript Value | - * | -------------------- | ---------------- | - * | Input Object | Object | - * | List | Array | - * | Boolean | Boolean | - * | String / Enum | String | - * | Int / Float | Number | - * | Null | null | + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations */ -function valueFromASTUntyped(valueNode, variables) { - switch (valueNode.kind) { - case _kinds.Kind.NULL: - return null; +function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), - case _kinds.Kind.INT: - return parseInt(valueNode.value, 10); + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); - case _kinds.Kind.FLOAT: - return parseFloat(valueNode.value); + if (!argDef && fieldDef && parentType) { + const argName = argNode.name.value; + const knownArgsNames = fieldDef.args.map((arg) => arg.name); + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgsNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + }, + }; +} +/** + * @internal + */ - case _kinds.Kind.STRING: - case _kinds.Kind.ENUM: - case _kinds.Kind.BOOLEAN: - return valueNode.value; +function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; - case _kinds.Kind.LIST: - return valueNode.values.map((node) => - valueFromASTUntyped(node, variables), - ); + for (const directive of definedDirectives) { + directiveArgs[directive.name] = directive.args.map((arg) => arg.name); + } - case _kinds.Kind.OBJECT: - return (0, _keyValMap.keyValMap)( - valueNode.fields, - (field) => field.name.value, - (field) => valueFromASTUntyped(field.value, variables), - ); + const astDefinitions = context.getDocument().definitions; - case _kinds.Kind.VARIABLE: - return variables === null || variables === void 0 - ? void 0 - : variables[valueNode.name.value]; + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argsNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); + } } + + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs[directiveName]; + + if (directiveNode.arguments && knownArgs) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + + if (!knownArgs.includes(argName)) { + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgs, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on directive "@${directiveName}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + } + } + + return false; + }, + }; } /***/ }), -/***/ 9656: +/***/ 33957: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -35278,563 +59645,532 @@ function valueFromASTUntyped(valueNode, variables) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.ValidationContext = - exports.SDLValidationContext = - exports.ASTValidationContext = - void 0; +exports.KnownDirectivesRule = KnownDirectivesRule; -var _kinds = __nccwpck_require__(36578); +var _inspect = __nccwpck_require__(85856); -var _visitor = __nccwpck_require__(78625); +var _invariant = __nccwpck_require__(31338); + +var _GraphQLError = __nccwpck_require__(93192); + +var _ast = __nccwpck_require__(90733); -var _TypeInfo = __nccwpck_require__(86215); +var _directiveLocation = __nccwpck_require__(53012); + +var _kinds = __nccwpck_require__(36096); + +var _directives = __nccwpck_require__(50828); /** - * An instance of this class is passed as the "this" context to all validators, - * allowing access to commonly useful contextual information from within a - * validation rule. + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined */ -class ASTValidationContext { - constructor(ast, onError) { - this._ast = ast; - this._fragments = undefined; - this._fragmentSpreads = new Map(); - this._recursivelyReferencedFragments = new Map(); - this._onError = onError; - } +function KnownDirectivesRule(context) { + const locationsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; - get [Symbol.toStringTag]() { - return 'ASTValidationContext'; + for (const directive of definedDirectives) { + locationsMap[directive.name] = directive.locations; } - reportError(error) { - this._onError(error); - } + const astDefinitions = context.getDocument().definitions; - getDocument() { - return this._ast; + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + locationsMap[def.name.value] = def.locations.map((name) => name.value); + } } - getFragment(name) { - let fragments; + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap[name]; - if (this._fragments) { - fragments = this._fragments; - } else { - fragments = Object.create(null); + if (!locations) { + context.reportError( + new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, { + nodes: node, + }), + ); + return; + } - for (const defNode of this.getDocument().definitions) { - if (defNode.kind === _kinds.Kind.FRAGMENT_DEFINITION) { - fragments[defNode.name.value] = defNode; - } + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + + if (candidateLocation && !locations.includes(candidateLocation)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${name}" may not be used on ${candidateLocation}.`, + { + nodes: node, + }, + ), + ); } + }, + }; +} - this._fragments = fragments; - } +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors[ancestors.length - 1]; + 'kind' in appliedTo || (0, _invariant.invariant)(false); - return fragments[name]; - } + switch (appliedTo.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); - getFragmentSpreads(node) { - let spreads = this._fragmentSpreads.get(node); + case _kinds.Kind.FIELD: + return _directiveLocation.DirectiveLocation.FIELD; + + case _kinds.Kind.FRAGMENT_SPREAD: + return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD; - if (!spreads) { - spreads = []; - const setsToVisit = [node]; - let set; + case _kinds.Kind.INLINE_FRAGMENT: + return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT; - while ((set = setsToVisit.pop())) { - for (const selection of set.selections) { - if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) { - spreads.push(selection); - } else if (selection.selectionSet) { - setsToVisit.push(selection.selectionSet); - } - } - } + case _kinds.Kind.FRAGMENT_DEFINITION: + return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION; - this._fragmentSpreads.set(node, spreads); - } + case _kinds.Kind.VARIABLE_DEFINITION: + return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION; - return spreads; - } + case _kinds.Kind.SCHEMA_DEFINITION: + case _kinds.Kind.SCHEMA_EXTENSION: + return _directiveLocation.DirectiveLocation.SCHEMA; - getRecursivelyReferencedFragments(operation) { - let fragments = this._recursivelyReferencedFragments.get(operation); + case _kinds.Kind.SCALAR_TYPE_DEFINITION: + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.SCALAR; - if (!fragments) { - fragments = []; - const collectedNames = Object.create(null); - const nodesToVisit = [operation.selectionSet]; - let node; + case _kinds.Kind.OBJECT_TYPE_DEFINITION: + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.OBJECT; - while ((node = nodesToVisit.pop())) { - for (const spread of this.getFragmentSpreads(node)) { - const fragName = spread.name.value; + case _kinds.Kind.FIELD_DEFINITION: + return _directiveLocation.DirectiveLocation.FIELD_DEFINITION; - if (collectedNames[fragName] !== true) { - collectedNames[fragName] = true; - const fragment = this.getFragment(fragName); + case _kinds.Kind.INTERFACE_TYPE_DEFINITION: + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INTERFACE; - if (fragment) { - fragments.push(fragment); - nodesToVisit.push(fragment.selectionSet); - } - } - } - } + case _kinds.Kind.UNION_TYPE_DEFINITION: + case _kinds.Kind.UNION_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.UNION; - this._recursivelyReferencedFragments.set(operation, fragments); - } + case _kinds.Kind.ENUM_TYPE_DEFINITION: + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.ENUM; - return fragments; - } -} + case _kinds.Kind.ENUM_VALUE_DEFINITION: + return _directiveLocation.DirectiveLocation.ENUM_VALUE; -exports.ASTValidationContext = ASTValidationContext; + case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INPUT_OBJECT; -class SDLValidationContext extends ASTValidationContext { - constructor(ast, schema, onError) { - super(ast, onError); - this._schema = schema; - } + case _kinds.Kind.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + 'kind' in parentNode || (0, _invariant.invariant)(false); + return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION + ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION + : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. - get [Symbol.toStringTag]() { - return 'SDLValidationContext'; - } + /* c8 ignore next */ - getSchema() { - return this._schema; + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(appliedTo.kind), + ); } } -exports.SDLValidationContext = SDLValidationContext; +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case _ast.OperationTypeNode.QUERY: + return _directiveLocation.DirectiveLocation.QUERY; -class ValidationContext extends ASTValidationContext { - constructor(schema, ast, typeInfo, onError) { - super(ast, onError); - this._schema = schema; - this._typeInfo = typeInfo; - this._variableUsages = new Map(); - this._recursiveVariableUsages = new Map(); - } + case _ast.OperationTypeNode.MUTATION: + return _directiveLocation.DirectiveLocation.MUTATION; - get [Symbol.toStringTag]() { - return 'ValidationContext'; + case _ast.OperationTypeNode.SUBSCRIPTION: + return _directiveLocation.DirectiveLocation.SUBSCRIPTION; } +} - getSchema() { - return this._schema; - } - getVariableUsages(node) { - let usages = this._variableUsages.get(node); +/***/ }), - if (!usages) { - const newUsages = []; - const typeInfo = new _TypeInfo.TypeInfo(this._schema); - (0, _visitor.visit)( - node, - (0, _TypeInfo.visitWithTypeInfo)(typeInfo, { - VariableDefinition: () => false, +/***/ 77080: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - Variable(variable) { - newUsages.push({ - node: variable, - type: typeInfo.getInputType(), - defaultValue: typeInfo.getDefaultValue(), - }); - }, - }), - ); - usages = newUsages; +"use strict"; - this._variableUsages.set(node, usages); - } - return usages; - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownFragmentNamesRule = KnownFragmentNamesRule; - getRecursiveVariableUsages(operation) { - let usages = this._recursiveVariableUsages.get(operation); +var _GraphQLError = __nccwpck_require__(93192); - if (!usages) { - usages = this.getVariableUsages(operation); +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); - for (const frag of this.getRecursivelyReferencedFragments(operation)) { - usages = usages.concat(this.getVariableUsages(frag)); + if (!fragment) { + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown fragment "${fragmentName}".`, + { + nodes: node.name, + }, + ), + ); } + }, + }; +} - this._recursiveVariableUsages.set(operation, usages); - } - return usages; - } +/***/ }), - getType() { - return this._typeInfo.getType(); - } +/***/ 90986: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - getParentType() { - return this._typeInfo.getParentType(); - } +"use strict"; - getInputType() { - return this._typeInfo.getInputType(); - } - getParentInputType() { - return this._typeInfo.getParentInputType(); - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownTypeNamesRule = KnownTypeNamesRule; - getFieldDef() { - return this._typeInfo.getFieldDef(); - } +var _didYouMean = __nccwpck_require__(4475); - getDirective() { - return this._typeInfo.getDirective(); - } +var _suggestionList = __nccwpck_require__(11642); - getArgument() { - return this._typeInfo.getArgument(); - } +var _GraphQLError = __nccwpck_require__(93192); - getEnumValue() { - return this._typeInfo.getEnumValue(); - } -} +var _predicates = __nccwpck_require__(19007); -exports.ValidationContext = ValidationContext; +var _introspection = __nccwpck_require__(8077); +var _scalars = __nccwpck_require__(94420); -/***/ }), +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +function KnownTypeNamesRule(context) { + const schema = context.getSchema(); + const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); + const definedTypes = Object.create(null); -/***/ 87682: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = true; + } + } -"use strict"; + const typeNames = [ + ...Object.keys(existingTypesMap), + ...Object.keys(definedTypes), + ]; + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + if (!existingTypesMap[typeName] && !definedTypes[typeName]) { + var _ancestors$; -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ - enumerable: true, - get: function () { - return _ExecutableDefinitionsRule.ExecutableDefinitionsRule; - }, -})); -Object.defineProperty(exports, "FieldsOnCorrectTypeRule", ({ - enumerable: true, - get: function () { - return _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule; - }, -})); -Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", ({ - enumerable: true, - get: function () { - return _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule; - }, -})); -Object.defineProperty(exports, "KnownArgumentNamesRule", ({ - enumerable: true, - get: function () { - return _KnownArgumentNamesRule.KnownArgumentNamesRule; - }, -})); -Object.defineProperty(exports, "KnownDirectivesRule", ({ - enumerable: true, - get: function () { - return _KnownDirectivesRule.KnownDirectivesRule; - }, -})); -Object.defineProperty(exports, "KnownFragmentNamesRule", ({ - enumerable: true, - get: function () { - return _KnownFragmentNamesRule.KnownFragmentNamesRule; - }, -})); -Object.defineProperty(exports, "KnownTypeNamesRule", ({ - enumerable: true, - get: function () { - return _KnownTypeNamesRule.KnownTypeNamesRule; - }, -})); -Object.defineProperty(exports, "LoneAnonymousOperationRule", ({ - enumerable: true, - get: function () { - return _LoneAnonymousOperationRule.LoneAnonymousOperationRule; - }, -})); -Object.defineProperty(exports, "LoneSchemaDefinitionRule", ({ - enumerable: true, - get: function () { - return _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule; - }, -})); -Object.defineProperty(exports, "NoDeprecatedCustomRule", ({ - enumerable: true, - get: function () { - return _NoDeprecatedCustomRule.NoDeprecatedCustomRule; - }, -})); -Object.defineProperty(exports, "NoFragmentCyclesRule", ({ - enumerable: true, - get: function () { - return _NoFragmentCyclesRule.NoFragmentCyclesRule; - }, -})); -Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", ({ - enumerable: true, - get: function () { - return _NoSchemaIntrospectionCustomRule.NoSchemaIntrospectionCustomRule; - }, -})); -Object.defineProperty(exports, "NoUndefinedVariablesRule", ({ - enumerable: true, - get: function () { - return _NoUndefinedVariablesRule.NoUndefinedVariablesRule; - }, -})); -Object.defineProperty(exports, "NoUnusedFragmentsRule", ({ - enumerable: true, - get: function () { - return _NoUnusedFragmentsRule.NoUnusedFragmentsRule; - }, -})); -Object.defineProperty(exports, "NoUnusedVariablesRule", ({ - enumerable: true, - get: function () { - return _NoUnusedVariablesRule.NoUnusedVariablesRule; - }, -})); -Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", ({ - enumerable: true, - get: function () { - return _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule; - }, -})); -Object.defineProperty(exports, "PossibleFragmentSpreadsRule", ({ - enumerable: true, - get: function () { - return _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule; - }, -})); -Object.defineProperty(exports, "PossibleTypeExtensionsRule", ({ - enumerable: true, - get: function () { - return _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule; - }, -})); -Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", ({ - enumerable: true, - get: function () { - return _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule; - }, -})); -Object.defineProperty(exports, "ScalarLeafsRule", ({ - enumerable: true, - get: function () { - return _ScalarLeafsRule.ScalarLeafsRule; - }, -})); -Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ - enumerable: true, - get: function () { - return _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule; - }, -})); -Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueArgumentNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueArgumentNamesRule.UniqueArgumentNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueDirectiveNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", ({ - enumerable: true, - get: function () { - return _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule; - }, -})); -Object.defineProperty(exports, "UniqueEnumValueNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueFragmentNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueFragmentNamesRule.UniqueFragmentNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueInputFieldNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueOperationNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueOperationNamesRule.UniqueOperationNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueOperationTypesRule", ({ - enumerable: true, - get: function () { - return _UniqueOperationTypesRule.UniqueOperationTypesRule; - }, -})); -Object.defineProperty(exports, "UniqueTypeNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueTypeNamesRule.UniqueTypeNamesRule; - }, -})); -Object.defineProperty(exports, "UniqueVariableNamesRule", ({ - enumerable: true, - get: function () { - return _UniqueVariableNamesRule.UniqueVariableNamesRule; - }, -})); -Object.defineProperty(exports, "ValidationContext", ({ - enumerable: true, - get: function () { - return _ValidationContext.ValidationContext; - }, -})); -Object.defineProperty(exports, "ValuesOfCorrectTypeRule", ({ - enumerable: true, - get: function () { - return _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule; - }, -})); -Object.defineProperty(exports, "VariablesAreInputTypesRule", ({ - enumerable: true, - get: function () { - return _VariablesAreInputTypesRule.VariablesAreInputTypesRule; - }, -})); -Object.defineProperty(exports, "VariablesInAllowedPositionRule", ({ - enumerable: true, - get: function () { - return _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule; - }, -})); -Object.defineProperty(exports, "specifiedRules", ({ - enumerable: true, - get: function () { - return _specifiedRules.specifiedRules; - }, -})); -Object.defineProperty(exports, "validate", ({ - enumerable: true, - get: function () { - return _validate.validate; - }, -})); + const definitionNode = + (_ancestors$ = ancestors[2]) !== null && _ancestors$ !== void 0 + ? _ancestors$ + : parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + + if (isSDL && standardTypeNames.includes(typeName)) { + return; + } + + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + isSDL ? standardTypeNames.concat(typeNames) : typeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown type "${typeName}".` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +const standardTypeNames = [ + ..._scalars.specifiedScalarTypes, + ..._introspection.introspectionTypes, +].map((type) => type.name); + +function isSDLNode(value) { + return ( + 'kind' in value && + ((0, _predicates.isTypeSystemDefinitionNode)(value) || + (0, _predicates.isTypeSystemExtensionNode)(value)) + ); +} + + +/***/ }), -var _validate = __nccwpck_require__(1581); +/***/ 41561: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var _ValidationContext = __nccwpck_require__(9656); +"use strict"; -var _specifiedRules = __nccwpck_require__(69807); -var _ExecutableDefinitionsRule = __nccwpck_require__(39581); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule; -var _FieldsOnCorrectTypeRule = __nccwpck_require__(98591); +var _GraphQLError = __nccwpck_require__(93192); -var _FragmentsOnCompositeTypesRule = __nccwpck_require__(39095); +var _kinds = __nccwpck_require__(36096); -var _KnownArgumentNamesRule = __nccwpck_require__(42485); +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter( + (definition) => definition.kind === _kinds.Kind.OPERATION_DEFINITION, + ).length; + }, -var _KnownDirectivesRule = __nccwpck_require__(14658); + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + 'This anonymous operation must be the only defined operation.', + { + nodes: node, + }, + ), + ); + } + }, + }; +} -var _KnownFragmentNamesRule = __nccwpck_require__(21458); -var _KnownTypeNamesRule = __nccwpck_require__(10426); +/***/ }), -var _LoneAnonymousOperationRule = __nccwpck_require__(74917); +/***/ 94081: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var _NoFragmentCyclesRule = __nccwpck_require__(78050); +"use strict"; -var _NoUndefinedVariablesRule = __nccwpck_require__(78876); -var _NoUnusedFragmentsRule = __nccwpck_require__(71887); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule; -var _NoUnusedVariablesRule = __nccwpck_require__(4014); +var _GraphQLError = __nccwpck_require__(93192); -var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(95679); +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +function LoneSchemaDefinitionRule(context) { + var _ref, _ref2, _oldSchema$astNode; -var _PossibleFragmentSpreadsRule = __nccwpck_require__(2585); + const oldSchema = context.getSchema(); + const alreadyDefined = + (_ref = + (_ref2 = + (_oldSchema$astNode = + oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.astNode) !== null && _oldSchema$astNode !== void 0 + ? _oldSchema$astNode + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getQueryType()) !== null && _ref2 !== void 0 + ? _ref2 + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getMutationType()) !== null && _ref !== void 0 + ? _ref + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Cannot define a new schema within a schema extension.', + { + nodes: node, + }, + ), + ); + return; + } -var _ProvidedRequiredArgumentsRule = __nccwpck_require__(12849); + if (schemaDefinitionsCount > 0) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Must provide only one schema definition.', + { + nodes: node, + }, + ), + ); + } -var _ScalarLeafsRule = __nccwpck_require__(14200); + ++schemaDefinitionsCount; + }, + }; +} -var _SingleFieldSubscriptionsRule = __nccwpck_require__(68608); -var _UniqueArgumentNamesRule = __nccwpck_require__(25105); +/***/ }), -var _UniqueDirectivesPerLocationRule = __nccwpck_require__(73540); +/***/ 31379: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var _UniqueFragmentNamesRule = __nccwpck_require__(66550); +"use strict"; -var _UniqueInputFieldNamesRule = __nccwpck_require__(58417); -var _UniqueOperationNamesRule = __nccwpck_require__(29177); +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoFragmentCyclesRule = NoFragmentCyclesRule; -var _UniqueVariableNamesRule = __nccwpck_require__(70991); +var _GraphQLError = __nccwpck_require__(93192); -var _ValuesOfCorrectTypeRule = __nccwpck_require__(1641); +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors -var _VariablesAreInputTypesRule = __nccwpck_require__(78960); + const spreadPath = []; // Position in the spread path -var _VariablesInAllowedPositionRule = __nccwpck_require__(80499); + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, -var _LoneSchemaDefinitionRule = __nccwpck_require__(25445); + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. -var _UniqueOperationTypesRule = __nccwpck_require__(86273); + function detectCycleRecursive(fragment) { + if (visitedFrags[fragment.name.value]) { + return; + } -var _UniqueTypeNamesRule = __nccwpck_require__(45639); + const fragmentName = fragment.name.value; + visitedFrags[fragmentName] = true; + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); -var _UniqueEnumValueNamesRule = __nccwpck_require__(51589); + if (spreadNodes.length === 0) { + return; + } -var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(82965); + spreadPathIndexByName[fragmentName] = spreadPath.length; -var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(85496); + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); -var _UniqueDirectiveNamesRule = __nccwpck_require__(6964); + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); -var _PossibleTypeExtensionsRule = __nccwpck_require__(10969); + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), + { + nodes: cyclePath, + }, + ), + ); + } -var _NoDeprecatedCustomRule = __nccwpck_require__(64994); + spreadPath.pop(); + } -var _NoSchemaIntrospectionCustomRule = __nccwpck_require__(283); + spreadPathIndexByName[fragmentName] = undefined; + } +} /***/ }), -/***/ 39581: +/***/ 79299: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -35843,44 +60179,50 @@ var _NoSchemaIntrospectionCustomRule = __nccwpck_require__(283); Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.ExecutableDefinitionsRule = ExecutableDefinitionsRule; - -var _GraphQLError = __nccwpck_require__(442); - -var _kinds = __nccwpck_require__(36578); +exports.NoUndefinedVariablesRule = NoUndefinedVariablesRule; -var _predicates = __nccwpck_require__(24854); +var _GraphQLError = __nccwpck_require__(93192); /** - * Executable definitions + * No undefined variables * - * A GraphQL document is only valid for execution if all definitions are either - * operation or fragment definitions. + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. * - * See https://spec.graphql.org/draft/#sec-Executable-Definitions + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined */ -function ExecutableDefinitionsRule(context) { +function NoUndefinedVariablesRule(context) { + let variableNameDefined = Object.create(null); return { - Document(node) { - for (const definition of node.definitions) { - if (!(0, _predicates.isExecutableDefinitionNode)(definition)) { - const defName = - definition.kind === _kinds.Kind.SCHEMA_DEFINITION || - definition.kind === _kinds.Kind.SCHEMA_EXTENSION - ? 'schema' - : '"' + definition.name.value + '"'; - context.reportError( - new _GraphQLError.GraphQLError( - `The ${defName} definition is not executable.`, - { - nodes: definition, - }, - ), - ); + OperationDefinition: { + enter() { + variableNameDefined = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + const varName = node.name.value; + + if (variableNameDefined[varName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, + { + nodes: [node, operation], + }, + ), + ); + } } - } + }, + }, - return false; + VariableDefinition(node) { + variableNameDefined[node.variable.name.value] = true; }, }; } @@ -35888,7 +60230,7 @@ function ExecutableDefinitionsRule(context) { /***/ }), -/***/ 98591: +/***/ 67081: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -35897,151 +60239,132 @@ function ExecutableDefinitionsRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.FieldsOnCorrectTypeRule = FieldsOnCorrectTypeRule; - -var _didYouMean = __nccwpck_require__(28052); - -var _naturalCompare = __nccwpck_require__(48917); - -var _suggestionList = __nccwpck_require__(69977); - -var _GraphQLError = __nccwpck_require__(442); +exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule; -var _definition = __nccwpck_require__(82341); +var _GraphQLError = __nccwpck_require__(93192); /** - * Fields on correct type + * No unused fragments * - * A GraphQL document is only valid if all fields selected are defined by the - * parent type, or are an allowed meta field such as __typename. + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. * - * See https://spec.graphql.org/draft/#sec-Field-Selections + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used */ -function FieldsOnCorrectTypeRule(context) { +function NoUnusedFragmentsRule(context) { + const operationDefs = []; + const fragmentDefs = []; return { - Field(node) { - const type = context.getParentType(); + OperationDefinition(node) { + operationDefs.push(node); + return false; + }, - if (type) { - const fieldDef = context.getFieldDef(); + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, - if (!fieldDef) { - // This field doesn't exist, lets look for suggestions. - const schema = context.getSchema(); - const fieldName = node.name.value; // First determine if there are any suggested types to condition on. + Document: { + leave() { + const fragmentNameUsed = Object.create(null); - let suggestion = (0, _didYouMean.didYouMean)( - 'to use an inline fragment on', - getSuggestedTypeNames(schema, type, fieldName), - ); // If there are no suggested types, then perhaps this was a typo? + for (const operation of operationDefs) { + for (const fragment of context.getRecursivelyReferencedFragments( + operation, + )) { + fragmentNameUsed[fragment.name.value] = true; + } + } - if (suggestion === '') { - suggestion = (0, _didYouMean.didYouMean)( - getSuggestedFieldNames(type, fieldName), - ); - } // Report an error, including helpful suggestions. + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; - context.reportError( - new _GraphQLError.GraphQLError( - `Cannot query field "${fieldName}" on type "${type.name}".` + - suggestion, - { - nodes: node, - }, - ), - ); + if (fragmentNameUsed[fragName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${fragName}" is never used.`, + { + nodes: fragmentDef, + }, + ), + ); + } } - } + }, }, }; } -/** - * Go through all of the implementations of type, as well as the interfaces that - * they implement. If any of those types include the provided field, suggest them, - * sorted by how often the type is referenced. - */ - -function getSuggestedTypeNames(schema, type, fieldName) { - if (!(0, _definition.isAbstractType)(type)) { - // Must be an Object type, which does not have possible fields. - return []; - } - const suggestedTypes = new Set(); - const usageCount = Object.create(null); - for (const possibleType of schema.getPossibleTypes(type)) { - if (!possibleType.getFields()[fieldName]) { - continue; - } // This object type defines this field. +/***/ }), - suggestedTypes.add(possibleType); - usageCount[possibleType.name] = 1; +/***/ 30410: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - for (const possibleInterface of possibleType.getInterfaces()) { - var _usageCount$possibleI; +"use strict"; - if (!possibleInterface.getFields()[fieldName]) { - continue; - } // This interface type defines this field. - suggestedTypes.add(possibleInterface); - usageCount[possibleInterface.name] = - ((_usageCount$possibleI = usageCount[possibleInterface.name]) !== - null && _usageCount$possibleI !== void 0 - ? _usageCount$possibleI - : 0) + 1; - } - } +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUnusedVariablesRule = NoUnusedVariablesRule; - return [...suggestedTypes] - .sort((typeA, typeB) => { - // Suggest both interface and object types based on how common they are. - const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; +var _GraphQLError = __nccwpck_require__(93192); - if (usageCountDiff !== 0) { - return usageCountDiff; - } // Suggest super types first followed by subtypes +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +function NoUnusedVariablesRule(context) { + let variableDefs = []; + return { + OperationDefinition: { + enter() { + variableDefs = []; + }, - if ( - (0, _definition.isInterfaceType)(typeA) && - schema.isSubType(typeA, typeB) - ) { - return -1; - } + leave(operation) { + const variableNameUsed = Object.create(null); + const usages = context.getRecursiveVariableUsages(operation); - if ( - (0, _definition.isInterfaceType)(typeB) && - schema.isSubType(typeB, typeA) - ) { - return 1; - } + for (const { node } of usages) { + variableNameUsed[node.name.value] = true; + } - return (0, _naturalCompare.naturalCompare)(typeA.name, typeB.name); - }) - .map((x) => x.name); -} -/** - * For the field name provided, determine if there are any similar field names - * that may be the result of a typo. - */ + for (const variableDef of variableDefs) { + const variableName = variableDef.variable.name.value; -function getSuggestedFieldNames(type, fieldName) { - if ( - (0, _definition.isObjectType)(type) || - (0, _definition.isInterfaceType)(type) - ) { - const possibleFieldNames = Object.keys(type.getFields()); - return (0, _suggestionList.suggestionList)(fieldName, possibleFieldNames); - } // Otherwise, must be a Union type, which does not define fields. + if (variableNameUsed[variableName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, + { + nodes: variableDef, + }, + ), + ); + } + } + }, + }, - return []; + VariableDefinition(def) { + variableDefs.push(def); + }, + }; } /***/ }), -/***/ 39095: +/***/ 10742: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36050,63 +60373,71 @@ function getSuggestedFieldNames(type, fieldName) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule; +exports.OverlappingFieldsCanBeMergedRule = OverlappingFieldsCanBeMergedRule; + +var _inspect = __nccwpck_require__(85856); + +var _GraphQLError = __nccwpck_require__(93192); + +var _kinds = __nccwpck_require__(36096); -var _GraphQLError = __nccwpck_require__(442); +var _printer = __nccwpck_require__(54697); -var _printer = __nccwpck_require__(46157); +var _definition = __nccwpck_require__(57741); -var _definition = __nccwpck_require__(82341); +var _sortValueNode = __nccwpck_require__(6177); -var _typeFromAST = __nccwpck_require__(32901); +var _typeFromAST = __nccwpck_require__(20207); + +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map( + ([responseName, subReason]) => + `subfields "${responseName}" conflict because ` + + reasonMessage(subReason), + ) + .join(' and '); + } + return reason; +} /** - * Fragments on composite type + * Overlapping fields can be merged * - * Fragments use a type condition to determine if they apply, since fragments - * can only be spread into a composite type (object, interface, or union), the - * type condition must also be a composite type. + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. * - * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging */ -function FragmentsOnCompositeTypesRule(context) { - return { - InlineFragment(node) { - const typeCondition = node.typeCondition; - - if (typeCondition) { - const type = (0, _typeFromAST.typeFromAST)( - context.getSchema(), - typeCondition, - ); - if (type && !(0, _definition.isCompositeType)(type)) { - const typeStr = (0, _printer.print)(typeCondition); - context.reportError( - new _GraphQLError.GraphQLError( - `Fragment cannot condition on non composite type "${typeStr}".`, - { - nodes: typeCondition, - }, - ), - ); - } - } - }, +function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when two fragments are compared "between" each other for + // conflicts. Two fragments may be compared many times, so memoizing this can + // dramatically improve the performance of this validator. + const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. - FragmentDefinition(node) { - const type = (0, _typeFromAST.typeFromAST)( - context.getSchema(), - node.typeCondition, + const cachedFieldsAndFragmentNames = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + context.getParentType(), + selectionSet, ); - if (type && !(0, _definition.isCompositeType)(type)) { - const typeStr = (0, _printer.print)(node.typeCondition); + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); context.reportError( new _GraphQLError.GraphQLError( - `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, + `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, { - nodes: node.typeCondition, + nodes: fields1.concat(fields2), }, ), ); @@ -36115,357 +60446,753 @@ function FragmentsOnCompositeTypesRule(context) { }; } +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentType, + selectionSet, +) { + const conflicts = []; + const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, + ); // (A) Find find all conflicts "within" the fields of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. -/***/ }), + collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, + ); -/***/ 42485: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (fragmentNames.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread fragment name found. + for (let i = 0; i < fragmentNames.length; i++) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fieldMap, + fragmentNames[i], + ); // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment names to every other + // item in that same list (except for itself). -"use strict"; + for (let j = i + 1; j < fragmentNames.length; j++) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fragmentNames[i], + fragmentNames[j], + ); + } + } + } + return conflicts; +} // Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule; -exports.KnownArgumentNamesRule = KnownArgumentNamesRule; +function collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fragmentName, +) { + const fragment = context.getFragment(fragmentName); -var _didYouMean = __nccwpck_require__(28052); + if (!fragment) { + return; + } -var _suggestionList = __nccwpck_require__(69977); + const [fieldMap2, referencedFragmentNames] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, + ); // Do not compare a fragment's fieldMap to itself. -var _GraphQLError = __nccwpck_require__(442); + if (fieldMap === fieldMap2) { + return; + } // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. -var _kinds = __nccwpck_require__(36578); + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fieldMap2, + ); // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. -var _directives = __nccwpck_require__(27602); + for (const referencedFragmentName of referencedFragmentNames) { + // Memoize so two fragments are not compared for conflicts more than once. + if ( + comparedFragmentPairs.has( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ) + ) { + continue; + } -/** - * Known argument names - * - * A GraphQL field is only valid if all supplied arguments are defined by - * that field. - * - * See https://spec.graphql.org/draft/#sec-Argument-Names - * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations - */ -function KnownArgumentNamesRule(context) { - return { - // eslint-disable-next-line new-cap - ...KnownArgumentNamesOnDirectivesRule(context), + comparedFragmentPairs.add( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ); + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + referencedFragmentName, + ); + } +} // Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. - Argument(argNode) { - const argDef = context.getArgument(); - const fieldDef = context.getFieldDef(); - const parentType = context.getParentType(); +function collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, +) { + // No need to compare a fragment to itself. + if (fragmentName1 === fragmentName2) { + return; + } // Memoize so two fragments are not compared for conflicts more than once. - if (!argDef && fieldDef && parentType) { - const argName = argNode.name.value; - const knownArgsNames = fieldDef.args.map((arg) => arg.name); - const suggestions = (0, _suggestionList.suggestionList)( - argName, - knownArgsNames, - ); - context.reportError( - new _GraphQLError.GraphQLError( - `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + - (0, _didYouMean.didYouMean)(suggestions), - { - nodes: argNode, - }, - ), - ); - } - }, - }; -} -/** - * @internal - */ + if ( + comparedFragmentPairs.has( + fragmentName1, + fragmentName2, + areMutuallyExclusive, + ) + ) { + return; + } -function KnownArgumentNamesOnDirectivesRule(context) { - const directiveArgs = Object.create(null); - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : _directives.specifiedDirectives; + comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentName1); + const fragment2 = context.getFragment(fragmentName2); - for (const directive of definedDirectives) { - directiveArgs[directive.name] = directive.args.map((arg) => arg.name); + if (!fragment1 || !fragment2) { + return; } - const astDefinitions = context.getDocument().definitions; + const [fieldMap1, referencedFragmentNames1] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment1, + ); + const [fieldMap2, referencedFragmentNames2] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment2, + ); // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). - for (const def of astDefinitions) { - if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - var _def$arguments; + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + for (const referencedFragmentName2 of referencedFragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + referencedFragmentName2, + ); + } // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. - /* c8 ignore next */ - const argsNodes = - (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 - ? _def$arguments - : []; - directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); + for (const referencedFragmentName1 of referencedFragmentNames1) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + referencedFragmentName1, + fragmentName2, + ); + } +} // Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. + +function findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + parentType1, + selectionSet1, + parentType2, + selectionSet2, +) { + const conflicts = []; + const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType1, + selectionSet1, + ); + const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType2, + selectionSet2, + ); // (H) First, collect all conflicts between these two collections of field. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fragmentName2, + ); + } // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + + for (const fragmentName1 of fragmentNames1) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap2, + fragmentName1, + ); + } // (J) Also collect conflicts between any fragment names by the first and + // fragment names by the second. This compares each item in the first set of + // names to each item in the second set of names. + + for (const fragmentName1 of fragmentNames1) { + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, + ); } } - return { - Directive(directiveNode) { - const directiveName = directiveNode.name.value; - const knownArgs = directiveArgs[directiveName]; + return conflicts; +} // Collect all Conflicts "within" one collection of fields. - if (directiveNode.arguments && knownArgs) { - for (const argNode of directiveNode.arguments) { - const argName = argNode.name.value; +function collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of Object.entries(fieldMap)) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, // within one collection is never mutually exclusive + responseName, + fields[i], + fields[j], + ); - if (!knownArgs.includes(argName)) { - const suggestions = (0, _suggestionList.suggestionList)( - argName, - knownArgs, - ); - context.reportError( - new _GraphQLError.GraphQLError( - `Unknown argument "${argName}" on directive "@${directiveName}".` + - (0, _didYouMean.didYouMean)(suggestions), - { - nodes: argNode, - }, - ), - ); + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. + +function collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + fieldMap1, + fieldMap2, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of Object.entries(fieldMap1)) { + const fields2 = fieldMap2[responseName]; + + if (fields2) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, + ); + + if (conflict) { + conflicts.push(conflict); } } } + } + } +} // Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. + +function findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, +) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. - return false; - }, - }; -} + const areMutuallyExclusive = + parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + (0, _definition.isObjectType)(parentType1) && + (0, _definition.isObjectType)(parentType2)); + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; -/***/ }), + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } // Two field calls must have the same arguments. -/***/ 14658: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (!sameArguments(node1, node2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } // The return type for each field. -"use strict"; + const type1 = def1 === null || def1 === void 0 ? void 0 : def1.type; + const type2 = def2 === null || def2 === void 0 ? void 0 : def2.type; + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${(0, _inspect.inspect)( + type1, + )}" and "${(0, _inspect.inspect)(type2)}"`, + ], + [node1], + [node2], + ]; + } // Collect and compare sub-fields. Use the same "visited fragment names" list + // for both collections so fields in a fragment reference are never + // compared to themselves. -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.KnownDirectivesRule = KnownDirectivesRule; + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + (0, _definition.getNamedType)(type1), + selectionSet1, + (0, _definition.getNamedType)(type2), + selectionSet2, + ); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} -var _inspect = __nccwpck_require__(70715); +function sameArguments(node1, node2) { + const args1 = node1.arguments; + const args2 = node2.arguments; -var _invariant = __nccwpck_require__(28864); + if (args1 === undefined || args1.length === 0) { + return args2 === undefined || args2.length === 0; + } -var _GraphQLError = __nccwpck_require__(442); + if (args2 === undefined || args2.length === 0) { + return false; + } + /* c8 ignore next */ -var _ast = __nccwpck_require__(22744); + if (args1.length !== args2.length) { + /* c8 ignore next */ + return false; + /* c8 ignore next */ + } -var _directiveLocation = __nccwpck_require__(95311); + const values2 = new Map(args2.map(({ name, value }) => [name.value, value])); + return args1.every((arg1) => { + const value1 = arg1.value; + const value2 = values2.get(arg1.name.value); -var _kinds = __nccwpck_require__(36578); + if (value2 === undefined) { + return false; + } -var _directives = __nccwpck_require__(27602); + return stringifyValue(value1) === stringifyValue(value2); + }); +} -/** - * Known directives - * - * A GraphQL document is only valid if all `@directives` are known by the - * schema and legally positioned. - * - * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined - */ -function KnownDirectivesRule(context) { - const locationsMap = Object.create(null); - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : _directives.specifiedDirectives; +function stringifyValue(value) { + return (0, _printer.print)((0, _sortValueNode.sortValueNode)(value)); +} // Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. - for (const directive of definedDirectives) { - locationsMap[directive.name] = directive.locations; +function doTypesConflict(type1, type2) { + if ((0, _definition.isListType)(type1)) { + return (0, _definition.isListType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; } - const astDefinitions = context.getDocument().definitions; - - for (const def of astDefinitions) { - if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - locationsMap[def.name.value] = def.locations.map((name) => name.value); - } + if ((0, _definition.isListType)(type2)) { + return true; } - return { - Directive(node, _key, _parent, _path, ancestors) { - const name = node.name.value; - const locations = locationsMap[name]; + if ((0, _definition.isNonNullType)(type1)) { + return (0, _definition.isNonNullType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } - if (!locations) { - context.reportError( - new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, { - nodes: node, - }), - ); - return; - } + if ((0, _definition.isNonNullType)(type2)) { + return true; + } - const candidateLocation = getDirectiveLocationForASTPath(ancestors); + if ( + (0, _definition.isLeafType)(type1) || + (0, _definition.isLeafType)(type2) + ) { + return type1 !== type2; + } - if (candidateLocation && !locations.includes(candidateLocation)) { - context.reportError( - new _GraphQLError.GraphQLError( - `Directive "@${name}" may not be used on ${candidateLocation}.`, - { - nodes: node, - }, - ), - ); - } - }, - }; -} + return false; +} // Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment names +// referenced via fragment spreads. -function getDirectiveLocationForASTPath(ancestors) { - const appliedTo = ancestors[ancestors.length - 1]; - 'kind' in appliedTo || (0, _invariant.invariant)(false); +function getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, +) { + const cached = cachedFieldsAndFragmentNames.get(selectionSet); - switch (appliedTo.kind) { - case _kinds.Kind.OPERATION_DEFINITION: - return getDirectiveLocationForOperation(appliedTo.operation); + if (cached) { + return cached; + } - case _kinds.Kind.FIELD: - return _directiveLocation.DirectiveLocation.FIELD; + const nodeAndDefs = Object.create(null); + const fragmentNames = Object.create(null); - case _kinds.Kind.FRAGMENT_SPREAD: - return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD; + _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, + ); - case _kinds.Kind.INLINE_FRAGMENT: - return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT; + const result = [nodeAndDefs, Object.keys(fragmentNames)]; + cachedFieldsAndFragmentNames.set(selectionSet, result); + return result; +} // Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment names referenced via fragment spreads. - case _kinds.Kind.FRAGMENT_DEFINITION: - return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION; +function getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, +) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); - case _kinds.Kind.VARIABLE_DEFINITION: - return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION; + if (cached) { + return cached; + } - case _kinds.Kind.SCHEMA_DEFINITION: - case _kinds.Kind.SCHEMA_EXTENSION: - return _directiveLocation.DirectiveLocation.SCHEMA; + const fragmentType = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + fragment.typeCondition, + ); + return getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragmentType, + fragment.selectionSet, + ); +} - case _kinds.Kind.SCALAR_TYPE_DEFINITION: - case _kinds.Kind.SCALAR_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.SCALAR; +function _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _kinds.Kind.FIELD: { + const fieldName = selection.name.value; + let fieldDef; - case _kinds.Kind.OBJECT_TYPE_DEFINITION: - case _kinds.Kind.OBJECT_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.OBJECT; + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + fieldDef = parentType.getFields()[fieldName]; + } - case _kinds.Kind.FIELD_DEFINITION: - return _directiveLocation.DirectiveLocation.FIELD_DEFINITION; + const responseName = selection.alias + ? selection.alias.value + : fieldName; - case _kinds.Kind.INTERFACE_TYPE_DEFINITION: - case _kinds.Kind.INTERFACE_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.INTERFACE; + if (!nodeAndDefs[responseName]) { + nodeAndDefs[responseName] = []; + } - case _kinds.Kind.UNION_TYPE_DEFINITION: - case _kinds.Kind.UNION_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.UNION; + nodeAndDefs[responseName].push([parentType, selection, fieldDef]); + break; + } - case _kinds.Kind.ENUM_TYPE_DEFINITION: - case _kinds.Kind.ENUM_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.ENUM; + case _kinds.Kind.FRAGMENT_SPREAD: + fragmentNames[selection.name.value] = true; + break; - case _kinds.Kind.ENUM_VALUE_DEFINITION: - return _directiveLocation.DirectiveLocation.ENUM_VALUE; + case _kinds.Kind.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) + : parentType; - case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: - case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: - return _directiveLocation.DirectiveLocation.INPUT_OBJECT; + _collectFieldsAndFragmentNames( + context, + inlineFragmentType, + selection.selectionSet, + nodeAndDefs, + fragmentNames, + ); - case _kinds.Kind.INPUT_VALUE_DEFINITION: { - const parentNode = ancestors[ancestors.length - 3]; - 'kind' in parentNode || (0, _invariant.invariant)(false); - return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION - ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION - : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION; + break; + } } - // Not reachable, all possible types have been considered. - - /* c8 ignore next */ - - default: - false || - (0, _invariant.invariant)( - false, - 'Unexpected kind: ' + (0, _inspect.inspect)(appliedTo.kind), - ); } -} - -function getDirectiveLocationForOperation(operation) { - switch (operation) { - case _ast.OperationTypeNode.QUERY: - return _directiveLocation.DirectiveLocation.QUERY; - - case _ast.OperationTypeNode.MUTATION: - return _directiveLocation.DirectiveLocation.MUTATION; +} // Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. - case _ast.OperationTypeNode.SUBSCRIPTION: - return _directiveLocation.DirectiveLocation.SUBSCRIPTION; +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; } } +/** + * A way to keep track of pairs of things when the ordering of the pair does not matter. + */ +class PairSet { + constructor() { + this._data = new Map(); + } -/***/ }), - -/***/ 21458: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + has(a, b, areMutuallyExclusive) { + var _this$_data$get; -"use strict"; + const [key1, key2] = a < b ? [a, b] : [b, a]; + const result = + (_this$_data$get = this._data.get(key1)) === null || + _this$_data$get === void 0 + ? void 0 + : _this$_data$get.get(key2); + if (result === undefined) { + return false; + } // areMutuallyExclusive being false is a superset of being true, hence if + // we want to know if this PairSet "has" these two with no exclusivity, + // we have to ensure it was added as such. -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.KnownFragmentNamesRule = KnownFragmentNamesRule; + return areMutuallyExclusive ? true : areMutuallyExclusive === result; + } -var _GraphQLError = __nccwpck_require__(442); + add(a, b, areMutuallyExclusive) { + const [key1, key2] = a < b ? [a, b] : [b, a]; -/** - * Known fragment names - * - * A GraphQL document is only valid if all `...Fragment` fragment spreads refer - * to fragments defined in the same document. - * - * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined - */ -function KnownFragmentNamesRule(context) { - return { - FragmentSpread(node) { - const fragmentName = node.name.value; - const fragment = context.getFragment(fragmentName); + const map = this._data.get(key1); - if (!fragment) { - context.reportError( - new _GraphQLError.GraphQLError( - `Unknown fragment "${fragmentName}".`, - { - nodes: node.name, - }, - ), - ); - } - }, - }; + if (map === undefined) { + this._data.set(key1, new Map([[key2, areMutuallyExclusive]])); + } else { + map.set(key2, areMutuallyExclusive); + } + } } /***/ }), -/***/ 10426: +/***/ 30727: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36474,68 +61201,45 @@ function KnownFragmentNamesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.KnownTypeNamesRule = KnownTypeNamesRule; - -var _didYouMean = __nccwpck_require__(28052); +exports.PossibleFragmentSpreadsRule = PossibleFragmentSpreadsRule; -var _suggestionList = __nccwpck_require__(69977); +var _inspect = __nccwpck_require__(85856); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); -var _predicates = __nccwpck_require__(24854); +var _definition = __nccwpck_require__(57741); -var _introspection = __nccwpck_require__(95678); +var _typeComparators = __nccwpck_require__(33981); -var _scalars = __nccwpck_require__(41963); +var _typeFromAST = __nccwpck_require__(20207); /** - * Known type names - * - * A GraphQL document is only valid if referenced types (specifically - * variable definitions and fragment conditions) are defined by the type schema. + * Possible fragment spread * - * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. */ -function KnownTypeNamesRule(context) { - const schema = context.getSchema(); - const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); - const definedTypes = Object.create(null); - - for (const def of context.getDocument().definitions) { - if ((0, _predicates.isTypeDefinitionNode)(def)) { - definedTypes[def.name.value] = true; - } - } - - const typeNames = [ - ...Object.keys(existingTypesMap), - ...Object.keys(definedTypes), - ]; +function PossibleFragmentSpreadsRule(context) { return { - NamedType(node, _1, parent, _2, ancestors) { - const typeName = node.name.value; - - if (!existingTypesMap[typeName] && !definedTypes[typeName]) { - var _ancestors$; - - const definitionNode = - (_ancestors$ = ancestors[2]) !== null && _ancestors$ !== void 0 - ? _ancestors$ - : parent; - const isSDL = definitionNode != null && isSDLNode(definitionNode); - - if (isSDL && standardTypeNames.includes(typeName)) { - return; - } + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); - const suggestedTypes = (0, _suggestionList.suggestionList)( - typeName, - isSDL ? standardTypeNames.concat(typeNames) : typeNames, - ); + if ( + (0, _definition.isCompositeType)(fragType) && + (0, _definition.isCompositeType)(parentType) && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); context.reportError( new _GraphQLError.GraphQLError( - `Unknown type "${typeName}".` + - (0, _didYouMean.didYouMean)(suggestedTypes), + `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node, }, @@ -36543,62 +61247,26 @@ function KnownTypeNamesRule(context) { ); } }, - }; -} - -const standardTypeNames = [ - ..._scalars.specifiedScalarTypes, - ..._introspection.introspectionTypes, -].map((type) => type.name); - -function isSDLNode(value) { - return ( - 'kind' in value && - ((0, _predicates.isTypeSystemDefinitionNode)(value) || - (0, _predicates.isTypeSystemExtensionNode)(value)) - ); -} - - -/***/ }), - -/***/ 74917: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule; - -var _GraphQLError = __nccwpck_require__(442); -var _kinds = __nccwpck_require__(36578); - -/** - * Lone anonymous operation - * - * A GraphQL document is only valid if when it contains an anonymous operation - * (the query short-hand) that it contains only that one operation definition. - * - * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation - */ -function LoneAnonymousOperationRule(context) { - let operationCount = 0; - return { - Document(node) { - operationCount = node.definitions.filter( - (definition) => definition.kind === _kinds.Kind.OPERATION_DEFINITION, - ).length; - }, + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); - OperationDefinition(node) { - if (!node.name && operationCount > 1) { + if ( + fragType && + parentType && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); context.reportError( new _GraphQLError.GraphQLError( - 'This anonymous operation must be the only defined operation.', + `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, { nodes: node, }, @@ -36609,10 +61277,25 @@ function LoneAnonymousOperationRule(context) { }; } +function getFragmentType(context, name) { + const frag = context.getFragment(name); + + if (frag) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + frag.typeCondition, + ); + + if ((0, _definition.isCompositeType)(type)) { + return type; + } + } +} + /***/ }), -/***/ 25445: +/***/ 43548: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36621,166 +61304,177 @@ function LoneAnonymousOperationRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule; +exports.PossibleTypeExtensionsRule = PossibleTypeExtensionsRule; + +var _didYouMean = __nccwpck_require__(4475); + +var _inspect = __nccwpck_require__(85856); + +var _invariant = __nccwpck_require__(31338); -var _GraphQLError = __nccwpck_require__(442); +var _suggestionList = __nccwpck_require__(11642); + +var _GraphQLError = __nccwpck_require__(93192); + +var _kinds = __nccwpck_require__(36096); + +var _predicates = __nccwpck_require__(19007); + +var _definition = __nccwpck_require__(57741); /** - * Lone Schema definition + * Possible type extension * - * A GraphQL document is only valid if it contains only one schema definition. + * A type extension is only valid if the type is defined and has the same kind. */ -function LoneSchemaDefinitionRule(context) { - var _ref, _ref2, _oldSchema$astNode; +function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = def; + } + } - const oldSchema = context.getSchema(); - const alreadyDefined = - (_ref = - (_ref2 = - (_oldSchema$astNode = - oldSchema === null || oldSchema === void 0 - ? void 0 - : oldSchema.astNode) !== null && _oldSchema$astNode !== void 0 - ? _oldSchema$astNode - : oldSchema === null || oldSchema === void 0 - ? void 0 - : oldSchema.getQueryType()) !== null && _ref2 !== void 0 - ? _ref2 - : oldSchema === null || oldSchema === void 0 - ? void 0 - : oldSchema.getMutationType()) !== null && _ref !== void 0 - ? _ref - : oldSchema === null || oldSchema === void 0 - ? void 0 - : oldSchema.getSubscriptionType(); - let schemaDefinitionsCount = 0; return { - SchemaDefinition(node) { - if (alreadyDefined) { - context.reportError( - new _GraphQLError.GraphQLError( - 'Cannot define a new schema within a schema extension.', - { - nodes: node, - }, - ), - ); - return; - } + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; - if (schemaDefinitionsCount > 0) { + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes[typeName]; + const existingType = + schema === null || schema === void 0 ? void 0 : schema.getType(typeName); + let expectedKind; + + if (defNode) { + expectedKind = defKindToExtKind[defNode.kind]; + } else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + + if (expectedKind) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); context.reportError( new _GraphQLError.GraphQLError( - 'Must provide only one schema definition.', + `Cannot extend non-${kindStr} type "${typeName}".`, { - nodes: node, + nodes: defNode ? [defNode, node] : node, }, ), ); } - - ++schemaDefinitionsCount; - }, - }; + } else { + const allTypeNames = Object.keys({ + ...definedTypes, + ...(schema === null || schema === void 0 + ? void 0 + : schema.getTypeMap()), + }); + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + allTypeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot extend type "${typeName}" because it is not defined.` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node.name, + }, + ), + ); + } + } } +const defKindToExtKind = { + [_kinds.Kind.SCALAR_TYPE_DEFINITION]: _kinds.Kind.SCALAR_TYPE_EXTENSION, + [_kinds.Kind.OBJECT_TYPE_DEFINITION]: _kinds.Kind.OBJECT_TYPE_EXTENSION, + [_kinds.Kind.INTERFACE_TYPE_DEFINITION]: _kinds.Kind.INTERFACE_TYPE_EXTENSION, + [_kinds.Kind.UNION_TYPE_DEFINITION]: _kinds.Kind.UNION_TYPE_EXTENSION, + [_kinds.Kind.ENUM_TYPE_DEFINITION]: _kinds.Kind.ENUM_TYPE_EXTENSION, + [_kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION]: + _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION, +}; -/***/ }), - -/***/ 78050: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; +function typeToExtKind(type) { + if ((0, _definition.isScalarType)(type)) { + return _kinds.Kind.SCALAR_TYPE_EXTENSION; + } + if ((0, _definition.isObjectType)(type)) { + return _kinds.Kind.OBJECT_TYPE_EXTENSION; + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.NoFragmentCyclesRule = NoFragmentCyclesRule; + if ((0, _definition.isInterfaceType)(type)) { + return _kinds.Kind.INTERFACE_TYPE_EXTENSION; + } -var _GraphQLError = __nccwpck_require__(442); + if ((0, _definition.isUnionType)(type)) { + return _kinds.Kind.UNION_TYPE_EXTENSION; + } -/** - * No fragment cycles - * - * The graph of fragment spreads must not form any cycles including spreading itself. - * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. - * - * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles - */ -function NoFragmentCyclesRule(context) { - // Tracks already visited fragments to maintain O(N) and to ensure that cycles - // are not redundantly reported. - const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors + if ((0, _definition.isEnumType)(type)) { + return _kinds.Kind.ENUM_TYPE_EXTENSION; + } - const spreadPath = []; // Position in the spread path + if ((0, _definition.isInputObjectType)(type)) { + return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered - const spreadPathIndexByName = Object.create(null); - return { - OperationDefinition: () => false, + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} - FragmentDefinition(node) { - detectCycleRecursive(node); - return false; - }, - }; // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle was found but continues to explore - // the graph to find all possible cycles. +function extensionKindToTypeName(kind) { + switch (kind) { + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return 'scalar'; - function detectCycleRecursive(fragment) { - if (visitedFrags[fragment.name.value]) { - return; - } + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return 'object'; - const fragmentName = fragment.name.value; - visitedFrags[fragmentName] = true; - const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return 'interface'; - if (spreadNodes.length === 0) { - return; - } + case _kinds.Kind.UNION_TYPE_EXTENSION: + return 'union'; - spreadPathIndexByName[fragmentName] = spreadPath.length; + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return 'enum'; - for (const spreadNode of spreadNodes) { - const spreadName = spreadNode.name.value; - const cycleIndex = spreadPathIndexByName[spreadName]; - spreadPath.push(spreadNode); + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered - if (cycleIndex === undefined) { - const spreadFragment = context.getFragment(spreadName); + /* c8 ignore next */ - if (spreadFragment) { - detectCycleRecursive(spreadFragment); - } - } else { - const cyclePath = spreadPath.slice(cycleIndex); - const viaPath = cyclePath - .slice(0, -1) - .map((s) => '"' + s.name.value + '"') - .join(', '); - context.reportError( - new _GraphQLError.GraphQLError( - `Cannot spread fragment "${spreadName}" within itself` + - (viaPath !== '' ? ` via ${viaPath}.` : '.'), - { - nodes: cyclePath, - }, - ), + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(kind), ); - } - - spreadPath.pop(); - } - - spreadPathIndexByName[fragmentName] = undefined; } } /***/ }), -/***/ 78876: +/***/ 96066: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36789,40 +61483,64 @@ function NoFragmentCyclesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.NoUndefinedVariablesRule = NoUndefinedVariablesRule; +exports.ProvidedRequiredArgumentsOnDirectivesRule = + ProvidedRequiredArgumentsOnDirectivesRule; +exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; + +var _inspect = __nccwpck_require__(85856); -var _GraphQLError = __nccwpck_require__(442); +var _keyMap = __nccwpck_require__(22660); + +var _GraphQLError = __nccwpck_require__(93192); + +var _kinds = __nccwpck_require__(36096); + +var _printer = __nccwpck_require__(54697); + +var _definition = __nccwpck_require__(57741); + +var _directives = __nccwpck_require__(50828); /** - * No undefined variables - * - * A GraphQL operation is only valid if all variables encountered, both directly - * and via fragment spreads, are defined by that operation. + * Provided required arguments * - * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. */ -function NoUndefinedVariablesRule(context) { - let variableNameDefined = Object.create(null); +function ProvidedRequiredArgumentsRule(context) { return { - OperationDefinition: { - enter() { - variableNameDefined = Object.create(null); - }, + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + var _fieldNode$arguments; - leave(operation) { - const usages = context.getRecursiveVariableUsages(operation); + const fieldDef = context.getFieldDef(); - for (const { node } of usages) { - const varName = node.name.value; + if (!fieldDef) { + return false; + } - if (variableNameDefined[varName] !== true) { + const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) === null || + _fieldNode$arguments === void 0 + ? void 0 + : _fieldNode$arguments.map((arg) => arg.name.value), + ); + + for (const argDef of fieldDef.args) { + if ( + !providedArgs.has(argDef.name) && + (0, _definition.isRequiredArgument)(argDef) + ) { + const argTypeStr = (0, _inspect.inspect)(argDef.type); context.reportError( new _GraphQLError.GraphQLError( - operation.name - ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` - : `Variable "$${varName}" is not defined.`, + `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, { - nodes: [node, operation], + nodes: fieldNode, }, ), ); @@ -36830,17 +61548,103 @@ function NoUndefinedVariablesRule(context) { } }, }, + }; +} +/** + * @internal + */ - VariableDefinition(node) { - variableNameDefined[node.variable.name.value] = true; +function ProvidedRequiredArgumentsOnDirectivesRule(context) { + var _schema$getDirectives; + + const requiredArgsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = + (_schema$getDirectives = + schema === null || schema === void 0 + ? void 0 + : schema.getDirectives()) !== null && _schema$getDirectives !== void 0 + ? _schema$getDirectives + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + requiredArgsMap[directive.name] = (0, _keyMap.keyMap)( + directive.args.filter(_definition.isRequiredArgument), + (arg) => arg.name, + ); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + requiredArgsMap[def.name.value] = (0, _keyMap.keyMap)( + argNodes.filter(isRequiredArgumentNode), + (arg) => arg.name.value, + ); + } + } + + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap[directiveName]; + + if (requiredArgs) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + + for (const [argName, argDef] of Object.entries(requiredArgs)) { + if (!argNodeMap.has(argName)) { + const argType = (0, _definition.isType)(argDef.type) + ? (0, _inspect.inspect)(argDef.type) + : (0, _printer.print)(argDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, + { + nodes: directiveNode, + }, + ), + ); + } + } + } + }, }, }; } +function isRequiredArgumentNode(arg) { + return ( + arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null + ); +} + /***/ }), -/***/ 71887: +/***/ 1312: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36849,59 +61653,53 @@ function NoUndefinedVariablesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule; +exports.ScalarLeafsRule = ScalarLeafsRule; + +var _inspect = __nccwpck_require__(85856); -var _GraphQLError = __nccwpck_require__(442); +var _GraphQLError = __nccwpck_require__(93192); + +var _definition = __nccwpck_require__(57741); /** - * No unused fragments - * - * A GraphQL document is only valid if all fragment definitions are spread - * within operations, or spread within other fragments spread within operations. + * Scalar leafs * - * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. */ -function NoUnusedFragmentsRule(context) { - const operationDefs = []; - const fragmentDefs = []; +function ScalarLeafsRule(context) { return { - OperationDefinition(node) { - operationDefs.push(node); - return false; - }, - - FragmentDefinition(node) { - fragmentDefs.push(node); - return false; - }, - - Document: { - leave() { - const fragmentNameUsed = Object.create(null); - - for (const operation of operationDefs) { - for (const fragment of context.getRecursivelyReferencedFragments( - operation, - )) { - fragmentNameUsed[fragment.name.value] = true; - } - } - - for (const fragmentDef of fragmentDefs) { - const fragName = fragmentDef.name.value; + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; - if (fragmentNameUsed[fragName] !== true) { + if (type) { + if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); context.reportError( new _GraphQLError.GraphQLError( - `Fragment "${fragName}" is never used.`, + `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, { - nodes: fragmentDef, + nodes: selectionSet, }, ), ); } + } else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, + { + nodes: node, + }, + ), + ); } - }, + } }, }; } @@ -36909,7 +61707,7 @@ function NoUnusedFragmentsRule(context) { /***/ }), -/***/ 4014: +/***/ 38681: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36918,55 +61716,84 @@ function NoUnusedFragmentsRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.NoUnusedVariablesRule = NoUnusedVariablesRule; +exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; + +var _GraphQLError = __nccwpck_require__(93192); -var _GraphQLError = __nccwpck_require__(442); +var _kinds = __nccwpck_require__(36096); + +var _collectFields = __nccwpck_require__(3027); /** - * No unused variables + * Subscriptions must only include a non-introspection field. * - * A GraphQL operation is only valid if all variables defined by an operation - * are used, either directly or within a spread fragment. + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. * - * See https://spec.graphql.org/draft/#sec-All-Variables-Used + * See https://spec.graphql.org/draft/#sec-Single-root-field */ -function NoUnusedVariablesRule(context) { - let variableDefs = []; +function SingleFieldSubscriptionsRule(context) { return { - OperationDefinition: { - enter() { - variableDefs = []; - }, + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); - leave(operation) { - const variableNameUsed = Object.create(null); - const usages = context.getRecursiveVariableUsages(operation); + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); - for (const { node } of usages) { - variableNameUsed[node.name.value] = true; - } + for (const definition of document.definitions) { + if (definition.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = definition; + } + } - for (const variableDef of variableDefs) { - const variableName = variableDef.variable.name.value; + const fields = (0, _collectFields.collectFields)( + schema, + fragments, + variableValues, + subscriptionType, + node.selectionSet, + ); - if (variableNameUsed[variableName] !== true) { + if (fields.size > 1) { + const fieldSelectionLists = [...fields.values()]; + const extraFieldSelectionLists = fieldSelectionLists.slice(1); + const extraFieldSelections = extraFieldSelectionLists.flat(); context.reportError( new _GraphQLError.GraphQLError( - operation.name - ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` - : `Variable "$${variableName}" is never used.`, + operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', { - nodes: variableDef, + nodes: extraFieldSelections, }, ), ); } - } - }, - }, - VariableDefinition(def) { - variableDefs.push(def); + for (const fieldNodes of fields.values()) { + const field = fieldNodes[0]; + const fieldName = field.name.value; + + if (fieldName.startsWith('__')) { + context.reportError( + new _GraphQLError.GraphQLError( + operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', + { + nodes: fieldNodes, + }, + ), + ); + } + } + } + } }, }; } @@ -36974,7 +61801,7 @@ function NoUnusedVariablesRule(context) { /***/ }), -/***/ 95679: +/***/ 16146: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -36983,813 +61810,409 @@ function NoUnusedVariablesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.OverlappingFieldsCanBeMergedRule = OverlappingFieldsCanBeMergedRule; - -var _inspect = __nccwpck_require__(70715); - -var _GraphQLError = __nccwpck_require__(442); - -var _kinds = __nccwpck_require__(36578); - -var _printer = __nccwpck_require__(46157); - -var _definition = __nccwpck_require__(82341); - -var _sortValueNode = __nccwpck_require__(20104); +exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule; -var _typeFromAST = __nccwpck_require__(32901); +var _groupBy = __nccwpck_require__(7890); -function reasonMessage(reason) { - if (Array.isArray(reason)) { - return reason - .map( - ([responseName, subReason]) => - `subfields "${responseName}" conflict because ` + - reasonMessage(subReason), - ) - .join(' and '); - } +var _GraphQLError = __nccwpck_require__(93192); - return reason; -} /** - * Overlapping fields can be merged - * - * A selection set is only valid if all fields (including spreading any - * fragments) either correspond to distinct response names or can be merged - * without ambiguity. + * Unique argument definition names * - * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. */ - -function OverlappingFieldsCanBeMergedRule(context) { - // A memoization for when two fragments are compared "between" each other for - // conflicts. Two fragments may be compared many times, so memoizing this can - // dramatically improve the performance of this validator. - const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given - // selection set. Selection sets may be asked for this information multiple - // times, so this improves the performance of this validator. - - const cachedFieldsAndFragmentNames = new Map(); +function UniqueArgumentDefinitionNamesRule(context) { return { - SelectionSet(selectionSet) { - const conflicts = findConflictsWithinSelectionSet( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - context.getParentType(), - selectionSet, - ); - - for (const [[responseName, reason], fields1, fields2] of conflicts) { - const reasonMsg = reasonMessage(reason); - context.reportError( - new _GraphQLError.GraphQLError( - `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, - { - nodes: fields1.concat(fields2), - }, - ), - ); - } - }, - }; -} - -/** - * Algorithm: - * - * Conflicts occur when two fields exist in a query which will produce the same - * response name, but represent differing values, thus creating a conflict. - * The algorithm below finds all conflicts via making a series of comparisons - * between fields. In order to compare as few fields as possible, this makes - * a series of comparisons "within" sets of fields and "between" sets of fields. - * - * Given any selection set, a collection produces both a set of fields by - * also including all inline fragments, as well as a list of fragments - * referenced by fragment spreads. - * - * A) Each selection set represented in the document first compares "within" its - * collected set of fields, finding any conflicts between every pair of - * overlapping fields. - * Note: This is the *only time* that a the fields "within" a set are compared - * to each other. After this only fields "between" sets are compared. - * - * B) Also, if any fragment is referenced in a selection set, then a - * comparison is made "between" the original set of fields and the - * referenced fragment. - * - * C) Also, if multiple fragments are referenced, then comparisons - * are made "between" each referenced fragment. - * - * D) When comparing "between" a set of fields and a referenced fragment, first - * a comparison is made between each field in the original set of fields and - * each field in the the referenced set of fields. - * - * E) Also, if any fragment is referenced in the referenced selection set, - * then a comparison is made "between" the original set of fields and the - * referenced fragment (recursively referring to step D). - * - * F) When comparing "between" two fragments, first a comparison is made between - * each field in the first referenced set of fields and each field in the the - * second referenced set of fields. - * - * G) Also, any fragments referenced by the first must be compared to the - * second, and any fragments referenced by the second must be compared to the - * first (recursively referring to step F). - * - * H) When comparing two fields, if both have selection sets, then a comparison - * is made "between" both selection sets, first comparing the set of fields in - * the first selection set with the set of fields in the second. - * - * I) Also, if any fragment is referenced in either selection set, then a - * comparison is made "between" the other set of fields and the - * referenced fragment. - * - * J) Also, if two fragments are referenced in both selection sets, then a - * comparison is made "between" the two fragments. - * - */ -// Find all conflicts found "within" a selection set, including those found -// via spreading in fragments. Called when visiting each SelectionSet in the -// GraphQL Document. -function findConflictsWithinSelectionSet( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - parentType, - selectionSet, -) { - const conflicts = []; - const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType, - selectionSet, - ); // (A) Find find all conflicts "within" the fields of this selection set. - // Note: this is the *only place* `collectConflictsWithin` is called. - - collectConflictsWithin( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - fieldMap, - ); - - if (fragmentNames.length !== 0) { - // (B) Then collect conflicts between these fields and those represented by - // each spread fragment name found. - for (let i = 0; i < fragmentNames.length; i++) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - false, - fieldMap, - fragmentNames[i], - ); // (C) Then compare this fragment with all other fragments found in this - // selection set to collect conflicts between fragments spread together. - // This compares each item in the list of fragment names to every other - // item in that same list (except for itself). - - for (let j = i + 1; j < fragmentNames.length; j++) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - false, - fragmentNames[i], - fragmentNames[j], - ); - } - } - } - - return conflicts; -} // Collect all conflicts found between a set of fields and a fragment reference -// including via spreading in any nested fragments. - -function collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap, - fragmentName, -) { - const fragment = context.getFragment(fragmentName); - - if (!fragment) { - return; - } - - const [fieldMap2, referencedFragmentNames] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment, - ); // Do not compare a fragment's fieldMap to itself. - - if (fieldMap === fieldMap2) { - return; - } // (D) First collect any conflicts between the provided collection of fields - // and the collection of fields represented by the given fragment. - - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap, - fieldMap2, - ); // (E) Then collect any conflicts between the provided collection of fields - // and any fragment names found in the given fragment. - - for (const referencedFragmentName of referencedFragmentNames) { - // Memoize so two fragments are not compared for conflicts more than once. - if ( - comparedFragmentPairs.has( - referencedFragmentName, - fragmentName, - areMutuallyExclusive, - ) - ) { - continue; - } - - comparedFragmentPairs.add( - referencedFragmentName, - fragmentName, - areMutuallyExclusive, - ); - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap, - referencedFragmentName, - ); - } -} // Collect all conflicts found between two fragments, including via spreading in -// any nested fragments. - -function collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fragmentName1, - fragmentName2, -) { - // No need to compare a fragment to itself. - if (fragmentName1 === fragmentName2) { - return; - } // Memoize so two fragments are not compared for conflicts more than once. - - if ( - comparedFragmentPairs.has( - fragmentName1, - fragmentName2, - areMutuallyExclusive, - ) - ) { - return; - } - - comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); - const fragment1 = context.getFragment(fragmentName1); - const fragment2 = context.getFragment(fragmentName2); - - if (!fragment1 || !fragment2) { - return; - } - - const [fieldMap1, referencedFragmentNames1] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment1, - ); - const [fieldMap2, referencedFragmentNames2] = - getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment2, - ); // (F) First, collect all conflicts between these two collections of fields - // (not including any nested fragments). - - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fieldMap2, - ); // (G) Then collect conflicts between the first fragment and any nested - // fragments spread in the second fragment. + DirectiveDefinition(directiveNode) { + var _directiveNode$argume; - for (const referencedFragmentName2 of referencedFragmentNames2) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fragmentName1, - referencedFragmentName2, - ); - } // (G) Then collect conflicts between the second fragment and any nested - // fragments spread in the first fragment. + // FIXME: https://github.com/graphql/graphql-js/issues/2203 - for (const referencedFragmentName1 of referencedFragmentNames1) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - referencedFragmentName1, - fragmentName2, - ); - } -} // Find all conflicts found between two selection sets, including those found -// via spreading in fragments. Called when determining if conflicts exist -// between the sub-fields of two overlapping fields. + /* c8 ignore next */ + const argumentNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, -function findConflictsBetweenSubSelectionSets( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - parentType1, - selectionSet1, - parentType2, - selectionSet2, -) { - const conflicts = []; - const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType1, - selectionSet1, - ); - const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType2, - selectionSet2, - ); // (H) First, collect all conflicts between these two collections of field. + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; - collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fieldMap2, - ); // (I) Then collect conflicts between the first collection of fields and - // those referenced by each fragment name associated with the second. + function checkArgUniquenessPerField(typeNode) { + var _typeNode$fields; - for (const fragmentName2 of fragmentNames2) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap1, - fragmentName2, - ); - } // (I) Then collect conflicts between the second collection of fields and - // those referenced by each fragment name associated with the first. + const typeName = typeNode.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 - for (const fragmentName1 of fragmentNames1) { - collectConflictsBetweenFieldsAndFragment( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fieldMap2, - fragmentName1, - ); - } // (J) Also collect conflicts between any fragment names by the first and - // fragment names by the second. This compares each item in the first set of - // names to each item in the second set of names. + /* c8 ignore next */ - for (const fragmentName1 of fragmentNames1) { - for (const fragmentName2 of fragmentNames2) { - collectConflictsBetweenFragments( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - fragmentName1, - fragmentName2, - ); - } - } + const fieldNodes = + (_typeNode$fields = typeNode.fields) !== null && + _typeNode$fields !== void 0 + ? _typeNode$fields + : []; - return conflicts; -} // Collect all Conflicts "within" one collection of fields. + for (const fieldDef of fieldNodes) { + var _fieldDef$arguments; -function collectConflictsWithin( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - fieldMap, -) { - // A field map is a keyed collection, where each key represents a response - // name and the value at that key is a list of all fields which provide that - // response name. For every response name, if there are multiple fields, they - // must be compared to find a potential conflict. - for (const [responseName, fields] of Object.entries(fieldMap)) { - // This compares every field in the list to every other field in this list - // (except to itself). If the list only has one item, nothing needs to - // be compared. - if (fields.length > 1) { - for (let i = 0; i < fields.length; i++) { - for (let j = i + 1; j < fields.length; j++) { - const conflict = findConflict( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - false, // within one collection is never mutually exclusive - responseName, - fields[i], - fields[j], - ); + const fieldName = fieldDef.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 - if (conflict) { - conflicts.push(conflict); - } - } - } + /* c8 ignore next */ + + const argumentNodes = + (_fieldDef$arguments = fieldDef.arguments) !== null && + _fieldDef$arguments !== void 0 + ? _fieldDef$arguments + : []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); } - } -} // Collect all Conflicts between two collections of fields. This is similar to, -// but different from the `collectConflictsWithin` function above. This check -// assumes that `collectConflictsWithin` has already been called on each -// provided collection of fields. This is true because this validator traverses -// each individual selection set. -function collectConflictsBetween( - context, - conflicts, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - parentFieldsAreMutuallyExclusive, - fieldMap1, - fieldMap2, -) { - // A field map is a keyed collection, where each key represents a response - // name and the value at that key is a list of all fields which provide that - // response name. For any response name which appears in both provided field - // maps, each field from the first field map must be compared to every field - // in the second field map to find potential conflicts. - for (const [responseName, fields1] of Object.entries(fieldMap1)) { - const fields2 = fieldMap2[responseName]; + return false; + } - if (fields2) { - for (const field1 of fields1) { - for (const field2 of fields2) { - const conflict = findConflict( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - parentFieldsAreMutuallyExclusive, - responseName, - field1, - field2, - ); + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, + ); - if (conflict) { - conflicts.push(conflict); - } - } + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `Argument "${parentName}(${argName}:)" can only be defined once.`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); } } + + return false; } -} // Determines if there is a conflict between two particular fields, including -// comparing their sub-fields. +} -function findConflict( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - parentFieldsAreMutuallyExclusive, - responseName, - field1, - field2, -) { - const [parentType1, node1, def1] = field1; - const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same - // time, due to the parent types, then it is safe to permit them to diverge - // in aliased field or arguments used as they will not present any ambiguity - // by differing. - // It is known that two parent types could never overlap if they are - // different Object types. Interface or Union types might overlap - if not - // in the current state of the schema, then perhaps in some future version, - // thus may not safely diverge. - const areMutuallyExclusive = - parentFieldsAreMutuallyExclusive || - (parentType1 !== parentType2 && - (0, _definition.isObjectType)(parentType1) && - (0, _definition.isObjectType)(parentType2)); +/***/ }), - if (!areMutuallyExclusive) { - // Two aliases must refer to the same field. - const name1 = node1.name.value; - const name2 = node2.name.value; +/***/ 19407: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - if (name1 !== name2) { - return [ - [responseName, `"${name1}" and "${name2}" are different fields`], - [node1], - [node2], - ]; - } // Two field calls must have the same arguments. +"use strict"; - if (stringifyArguments(node1) !== stringifyArguments(node2)) { - return [ - [responseName, 'they have differing arguments'], - [node1], - [node2], - ]; - } - } // The return type for each field. - const type1 = def1 === null || def1 === void 0 ? void 0 : def1.type; - const type2 = def2 === null || def2 === void 0 ? void 0 : def2.type; +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule; - if (type1 && type2 && doTypesConflict(type1, type2)) { - return [ - [ - responseName, - `they return conflicting types "${(0, _inspect.inspect)( - type1, - )}" and "${(0, _inspect.inspect)(type2)}"`, - ], - [node1], - [node2], - ]; - } // Collect and compare sub-fields. Use the same "visited fragment names" list - // for both collections so fields in a fragment reference are never - // compared to themselves. +var _groupBy = __nccwpck_require__(7890); - const selectionSet1 = node1.selectionSet; - const selectionSet2 = node2.selectionSet; +var _GraphQLError = __nccwpck_require__(93192); - if (selectionSet1 && selectionSet2) { - const conflicts = findConflictsBetweenSubSelectionSets( - context, - cachedFieldsAndFragmentNames, - comparedFragmentPairs, - areMutuallyExclusive, - (0, _definition.getNamedType)(type1), - selectionSet1, - (0, _definition.getNamedType)(type2), - selectionSet2, +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + + function checkArgUniqueness(parentNode) { + var _parentNode$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_parentNode$arguments = parentNode.arguments) !== null && + _parentNode$arguments !== void 0 + ? _parentNode$arguments + : []; + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, ); - return subfieldConflicts(conflicts, responseName, node1, node2); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one argument named "${argName}".`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } } } -function stringifyArguments(fieldNode) { - var _fieldNode$arguments; - // FIXME https://github.com/graphql/graphql-js/issues/2203 - const args = - /* c8 ignore next */ - (_fieldNode$arguments = fieldNode.arguments) !== null && - _fieldNode$arguments !== void 0 - ? _fieldNode$arguments - : []; - const inputObjectWithArgs = { - kind: _kinds.Kind.OBJECT, - fields: args.map((argNode) => ({ - kind: _kinds.Kind.OBJECT_FIELD, - name: argNode.name, - value: argNode.value, - })), +/***/ }), + +/***/ 6518: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule; + +var _GraphQLError = __nccwpck_require__(93192); + +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = Object.create(null); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + + if ( + schema !== null && + schema !== void 0 && + schema.getDirective(directiveName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownDirectiveNames[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one directive named "@${directiveName}".`, + { + nodes: [knownDirectiveNames[directiveName], node.name], + }, + ), + ); + } else { + knownDirectiveNames[directiveName] = node.name; + } + + return false; + }, }; - return (0, _printer.print)( - (0, _sortValueNode.sortValueNode)(inputObjectWithArgs), - ); -} // Two types conflict if both types could not apply to a value simultaneously. -// Composite types are ignored as their individual field types will be compared -// later recursively. However List and Non-Null types must match. +} -function doTypesConflict(type1, type2) { - if ((0, _definition.isListType)(type1)) { - return (0, _definition.isListType)(type2) - ? doTypesConflict(type1.ofType, type2.ofType) - : true; - } - if ((0, _definition.isListType)(type2)) { - return true; - } +/***/ }), - if ((0, _definition.isNonNullType)(type1)) { - return (0, _definition.isNonNullType)(type2) - ? doTypesConflict(type1.ofType, type2.ofType) - : true; - } +/***/ 9694: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - if ((0, _definition.isNonNullType)(type2)) { - return true; - } +"use strict"; - if ( - (0, _definition.isLeafType)(type1) || - (0, _definition.isLeafType)(type2) - ) { - return type1 !== type2; - } - return false; -} // Given a selection set, return the collection of fields (a mapping of response -// name to field nodes and definitions) as well as a list of fragment names -// referenced via fragment spreads. +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule; -function getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - parentType, - selectionSet, -) { - const cached = cachedFieldsAndFragmentNames.get(selectionSet); +var _GraphQLError = __nccwpck_require__(93192); - if (cached) { - return cached; - } +var _kinds = __nccwpck_require__(36096); - const nodeAndDefs = Object.create(null); - const fragmentNames = Object.create(null); +var _predicates = __nccwpck_require__(19007); - _collectFieldsAndFragmentNames( - context, - parentType, - selectionSet, - nodeAndDefs, - fragmentNames, - ); +var _directives = __nccwpck_require__(50828); - const result = [nodeAndDefs, Object.keys(fragmentNames)]; - cachedFieldsAndFragmentNames.set(selectionSet, result); - return result; -} // Given a reference to a fragment, return the represented collection of fields -// as well as a list of nested fragment names referenced via fragment spreads. +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; -function getReferencedFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragment, -) { - // Short-circuit building a type from the node if possible. - const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); + for (const directive of definedDirectives) { + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; + } - if (cached) { - return cached; + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap[def.name.value] = !def.repeatable; + } } - const fragmentType = (0, _typeFromAST.typeFromAST)( - context.getSchema(), - fragment.typeCondition, - ); - return getFieldsAndFragmentNames( - context, - cachedFieldsAndFragmentNames, - fragmentType, - fragment.selectionSet, - ); -} + const schemaDirectives = Object.create(null); + const typeDirectivesMap = Object.create(null); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } -function _collectFieldsAndFragmentNames( - context, - parentType, - selectionSet, - nodeAndDefs, - fragmentNames, -) { - for (const selection of selectionSet.selections) { - switch (selection.kind) { - case _kinds.Kind.FIELD: { - const fieldName = selection.name.value; - let fieldDef; + let seenDirectives; - if ( - (0, _definition.isObjectType)(parentType) || - (0, _definition.isInterfaceType)(parentType) - ) { - fieldDef = parentType.getFields()[fieldName]; + if ( + node.kind === _kinds.Kind.SCHEMA_DEFINITION || + node.kind === _kinds.Kind.SCHEMA_EXTENSION + ) { + seenDirectives = schemaDirectives; + } else if ( + (0, _predicates.isTypeDefinitionNode)(node) || + (0, _predicates.isTypeExtensionNode)(node) + ) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap[typeName]; + + if (seenDirectives === undefined) { + typeDirectivesMap[typeName] = seenDirectives = Object.create(null); } + } else { + seenDirectives = Object.create(null); + } - const responseName = selection.alias - ? selection.alias.value - : fieldName; + for (const directive of node.directives) { + const directiveName = directive.name.value; - if (!nodeAndDefs[responseName]) { - nodeAndDefs[responseName] = []; + if (uniqueDirectiveMap[directiveName]) { + if (seenDirectives[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `The directive "@${directiveName}" can only be used once at this location.`, + { + nodes: [seenDirectives[directiveName], directive], + }, + ), + ); + } else { + seenDirectives[directiveName] = directive; + } } - - nodeAndDefs[responseName].push([parentType, selection, fieldDef]); - break; } + }, + }; +} - case _kinds.Kind.FRAGMENT_SPREAD: - fragmentNames[selection.name.value] = true; - break; - case _kinds.Kind.INLINE_FRAGMENT: { - const typeCondition = selection.typeCondition; - const inlineFragmentType = typeCondition - ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) - : parentType; +/***/ }), - _collectFieldsAndFragmentNames( - context, - inlineFragmentType, - selection.selectionSet, - nodeAndDefs, - fragmentNames, - ); +/***/ 57266: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - break; - } - } - } -} // Given a series of Conflicts which occurred between two sub-fields, generate -// a single Conflict. +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule; + +var _GraphQLError = __nccwpck_require__(93192); + +var _definition = __nccwpck_require__(57741); -function subfieldConflicts(conflicts, responseName, node1, node2) { - if (conflicts.length > 0) { - return [ - [responseName, conflicts.map(([reason]) => reason)], - [node1, ...conflicts.map(([, fields1]) => fields1).flat()], - [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], - ]; - } -} /** - * A way to keep track of pairs of things when the ordering of the pair does not matter. + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. */ +function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = Object.create(null); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; -class PairSet { - constructor() { - this._data = new Map(); - } - - has(a, b, areMutuallyExclusive) { - var _this$_data$get; + function checkValueUniqueness(node) { + var _node$values; - const [key1, key2] = a < b ? [a, b] : [b, a]; - const result = - (_this$_data$get = this._data.get(key1)) === null || - _this$_data$get === void 0 - ? void 0 - : _this$_data$get.get(key2); + const typeName = node.name.value; - if (result === undefined) { - return false; - } // areMutuallyExclusive being false is a superset of being true, hence if - // we want to know if this PairSet "has" these two with no exclusivity, - // we have to ensure it was added as such. + if (!knownValueNames[typeName]) { + knownValueNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 - return areMutuallyExclusive ? true : areMutuallyExclusive === result; - } + /* c8 ignore next */ - add(a, b, areMutuallyExclusive) { - const [key1, key2] = a < b ? [a, b] : [b, a]; + const valueNodes = + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + const valueNames = knownValueNames[typeName]; - const map = this._data.get(key1); + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; - if (map === undefined) { - this._data.set(key1, new Map([[key2, areMutuallyExclusive]])); - } else { - map.set(key2, areMutuallyExclusive); + if ( + (0, _definition.isEnumType)(existingType) && + existingType.getValue(valueName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: valueDef.name, + }, + ), + ); + } else if (valueNames[valueName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" can only be defined once.`, + { + nodes: [valueNames[valueName], valueDef.name], + }, + ), + ); + } else { + valueNames[valueName] = valueDef.name; + } } + + return false; } } /***/ }), -/***/ 2585: +/***/ 20746: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -37798,101 +62221,93 @@ class PairSet { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.PossibleFragmentSpreadsRule = PossibleFragmentSpreadsRule; - -var _inspect = __nccwpck_require__(70715); - -var _GraphQLError = __nccwpck_require__(442); - -var _definition = __nccwpck_require__(82341); +exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule; -var _typeComparators = __nccwpck_require__(72159); +var _GraphQLError = __nccwpck_require__(93192); -var _typeFromAST = __nccwpck_require__(32901); +var _definition = __nccwpck_require__(57741); /** - * Possible fragment spread + * Unique field definition names * - * A fragment spread is only valid if the type condition could ever possibly - * be true: if there is a non-empty intersection of the possible parent types, - * and possible types which pass the type condition. + * A GraphQL complex type is only valid if all its fields are uniquely named. */ -function PossibleFragmentSpreadsRule(context) { +function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = Object.create(null); return { - InlineFragment(node) { - const fragType = context.getType(); - const parentType = context.getParentType(); + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; - if ( - (0, _definition.isCompositeType)(fragType) && - (0, _definition.isCompositeType)(parentType) && - !(0, _typeComparators.doTypesOverlap)( - context.getSchema(), - fragType, - parentType, - ) - ) { - const parentTypeStr = (0, _inspect.inspect)(parentType); - const fragTypeStr = (0, _inspect.inspect)(fragType); + function checkFieldUniqueness(node) { + var _node$fields; + + const typeName = node.name.value; + + if (!knownFieldNames[typeName]) { + knownFieldNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + const fieldNames = knownFieldNames[typeName]; + + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + + if (hasField(existingTypeMap[typeName], fieldName)) { context.reportError( new _GraphQLError.GraphQLError( - `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, { - nodes: node, + nodes: fieldDef.name, }, ), ); - } - }, - - FragmentSpread(node) { - const fragName = node.name.value; - const fragType = getFragmentType(context, fragName); - const parentType = context.getParentType(); - - if ( - fragType && - parentType && - !(0, _typeComparators.doTypesOverlap)( - context.getSchema(), - fragType, - parentType, - ) - ) { - const parentTypeStr = (0, _inspect.inspect)(parentType); - const fragTypeStr = (0, _inspect.inspect)(fragType); + } else if (fieldNames[fieldName]) { context.reportError( new _GraphQLError.GraphQLError( - `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + `Field "${typeName}.${fieldName}" can only be defined once.`, { - nodes: node, + nodes: [fieldNames[fieldName], fieldDef.name], }, ), ); + } else { + fieldNames[fieldName] = fieldDef.name; } - }, - }; -} - -function getFragmentType(context, name) { - const frag = context.getFragment(name); + } - if (frag) { - const type = (0, _typeFromAST.typeFromAST)( - context.getSchema(), - frag.typeCondition, - ); + return false; + } +} - if ((0, _definition.isCompositeType)(type)) { - return type; - } +function hasField(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) || + (0, _definition.isInputObjectType)(type) + ) { + return type.getFields()[fieldName] != null; } + + return false; } /***/ }), -/***/ 10969: +/***/ 8644: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -37901,177 +62316,109 @@ function getFragmentType(context, name) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.PossibleTypeExtensionsRule = PossibleTypeExtensionsRule; - -var _didYouMean = __nccwpck_require__(28052); - -var _inspect = __nccwpck_require__(70715); - -var _invariant = __nccwpck_require__(28864); - -var _suggestionList = __nccwpck_require__(69977); - -var _GraphQLError = __nccwpck_require__(442); - -var _kinds = __nccwpck_require__(36578); - -var _predicates = __nccwpck_require__(24854); +exports.UniqueFragmentNamesRule = UniqueFragmentNamesRule; -var _definition = __nccwpck_require__(82341); +var _GraphQLError = __nccwpck_require__(93192); /** - * Possible type extension + * Unique fragment names * - * A type extension is only valid if the type is defined and has the same kind. + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness */ -function PossibleTypeExtensionsRule(context) { - const schema = context.getSchema(); - const definedTypes = Object.create(null); - - for (const def of context.getDocument().definitions) { - if ((0, _predicates.isTypeDefinitionNode)(def)) { - definedTypes[def.name.value] = def; - } - } - +function UniqueFragmentNamesRule(context) { + const knownFragmentNames = Object.create(null); return { - ScalarTypeExtension: checkExtension, - ObjectTypeExtension: checkExtension, - InterfaceTypeExtension: checkExtension, - UnionTypeExtension: checkExtension, - EnumTypeExtension: checkExtension, - InputObjectTypeExtension: checkExtension, - }; - - function checkExtension(node) { - const typeName = node.name.value; - const defNode = definedTypes[typeName]; - const existingType = - schema === null || schema === void 0 ? void 0 : schema.getType(typeName); - let expectedKind; + OperationDefinition: () => false, - if (defNode) { - expectedKind = defKindToExtKind[defNode.kind]; - } else if (existingType) { - expectedKind = typeToExtKind(existingType); - } + FragmentDefinition(node) { + const fragmentName = node.name.value; - if (expectedKind) { - if (expectedKind !== node.kind) { - const kindStr = extensionKindToTypeName(node.kind); + if (knownFragmentNames[fragmentName]) { context.reportError( new _GraphQLError.GraphQLError( - `Cannot extend non-${kindStr} type "${typeName}".`, + `There can be only one fragment named "${fragmentName}".`, { - nodes: defNode ? [defNode, node] : node, + nodes: [knownFragmentNames[fragmentName], node.name], }, ), ); + } else { + knownFragmentNames[fragmentName] = node.name; } - } else { - const allTypeNames = Object.keys({ - ...definedTypes, - ...(schema === null || schema === void 0 - ? void 0 - : schema.getTypeMap()), - }); - const suggestedTypes = (0, _suggestionList.suggestionList)( - typeName, - allTypeNames, - ); - context.reportError( - new _GraphQLError.GraphQLError( - `Cannot extend type "${typeName}" because it is not defined.` + - (0, _didYouMean.didYouMean)(suggestedTypes), - { - nodes: node.name, - }, - ), - ); - } - } -} - -const defKindToExtKind = { - [_kinds.Kind.SCALAR_TYPE_DEFINITION]: _kinds.Kind.SCALAR_TYPE_EXTENSION, - [_kinds.Kind.OBJECT_TYPE_DEFINITION]: _kinds.Kind.OBJECT_TYPE_EXTENSION, - [_kinds.Kind.INTERFACE_TYPE_DEFINITION]: _kinds.Kind.INTERFACE_TYPE_EXTENSION, - [_kinds.Kind.UNION_TYPE_DEFINITION]: _kinds.Kind.UNION_TYPE_EXTENSION, - [_kinds.Kind.ENUM_TYPE_DEFINITION]: _kinds.Kind.ENUM_TYPE_EXTENSION, - [_kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION]: - _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION, -}; - -function typeToExtKind(type) { - if ((0, _definition.isScalarType)(type)) { - return _kinds.Kind.SCALAR_TYPE_EXTENSION; - } - - if ((0, _definition.isObjectType)(type)) { - return _kinds.Kind.OBJECT_TYPE_EXTENSION; - } - if ((0, _definition.isInterfaceType)(type)) { - return _kinds.Kind.INTERFACE_TYPE_EXTENSION; - } + return false; + }, + }; +} - if ((0, _definition.isUnionType)(type)) { - return _kinds.Kind.UNION_TYPE_EXTENSION; - } - if ((0, _definition.isEnumType)(type)) { - return _kinds.Kind.ENUM_TYPE_EXTENSION; - } +/***/ }), - if ((0, _definition.isInputObjectType)(type)) { - return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION; - } - /* c8 ignore next 3 */ - // Not reachable. All possible types have been considered +/***/ 77231: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - false || - (0, _invariant.invariant)( - false, - 'Unexpected type: ' + (0, _inspect.inspect)(type), - ); -} +"use strict"; -function extensionKindToTypeName(kind) { - switch (kind) { - case _kinds.Kind.SCALAR_TYPE_EXTENSION: - return 'scalar'; - case _kinds.Kind.OBJECT_TYPE_EXTENSION: - return 'object'; +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule; - case _kinds.Kind.INTERFACE_TYPE_EXTENSION: - return 'interface'; +var _invariant = __nccwpck_require__(31338); - case _kinds.Kind.UNION_TYPE_EXTENSION: - return 'union'; +var _GraphQLError = __nccwpck_require__(93192); - case _kinds.Kind.ENUM_TYPE_EXTENSION: - return 'enum'; +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = Object.create(null); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = Object.create(null); + }, - case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: - return 'input object'; - // Not reachable. All possible types have been considered + leave() { + const prevKnownNames = knownNameStack.pop(); + prevKnownNames || (0, _invariant.invariant)(false); + knownNames = prevKnownNames; + }, + }, - /* c8 ignore next */ + ObjectField(node) { + const fieldName = node.name.value; - default: - false || - (0, _invariant.invariant)( - false, - 'Unexpected kind: ' + (0, _inspect.inspect)(kind), + if (knownNames[fieldName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one input field named "${fieldName}".`, + { + nodes: [knownNames[fieldName], node.name], + }, + ), ); - } + } else { + knownNames[fieldName] = node.name; + } + }, + }; } /***/ }), -/***/ 12849: +/***/ 63870: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38080,168 +62427,196 @@ function extensionKindToTypeName(kind) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.ProvidedRequiredArgumentsOnDirectivesRule = - ProvidedRequiredArgumentsOnDirectivesRule; -exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; - -var _inspect = __nccwpck_require__(70715); - -var _keyMap = __nccwpck_require__(65169); - -var _GraphQLError = __nccwpck_require__(442); - -var _kinds = __nccwpck_require__(36578); - -var _printer = __nccwpck_require__(46157); - -var _definition = __nccwpck_require__(82341); +exports.UniqueOperationNamesRule = UniqueOperationNamesRule; -var _directives = __nccwpck_require__(27602); +var _GraphQLError = __nccwpck_require__(93192); /** - * Provided required arguments + * Unique operation names * - * A field or directive is only valid if all required (non-null without a - * default value) field arguments have been provided. + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness */ -function ProvidedRequiredArgumentsRule(context) { +function UniqueOperationNamesRule(context) { + const knownOperationNames = Object.create(null); return { - // eslint-disable-next-line new-cap - ...ProvidedRequiredArgumentsOnDirectivesRule(context), - Field: { - // Validate on leave to allow for deeper errors to appear first. - leave(fieldNode) { - var _fieldNode$arguments; - - const fieldDef = context.getFieldDef(); + OperationDefinition(node) { + const operationName = node.name; - if (!fieldDef) { - return false; + if (operationName) { + if (knownOperationNames[operationName.value]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one operation named "${operationName.value}".`, + { + nodes: [ + knownOperationNames[operationName.value], + operationName, + ], + }, + ), + ); + } else { + knownOperationNames[operationName.value] = operationName; } + } - const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 - /* c8 ignore next */ - (_fieldNode$arguments = fieldNode.arguments) === null || - _fieldNode$arguments === void 0 - ? void 0 - : _fieldNode$arguments.map((arg) => arg.name.value), - ); - - for (const argDef of fieldDef.args) { - if ( - !providedArgs.has(argDef.name) && - (0, _definition.isRequiredArgument)(argDef) - ) { - const argTypeStr = (0, _inspect.inspect)(argDef.type); - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, - { - nodes: fieldNode, - }, - ), - ); - } - } - }, + return false; }, + + FragmentDefinition: () => false, }; } + + +/***/ }), + +/***/ 79072: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueOperationTypesRule = UniqueOperationTypesRule; + +var _GraphQLError = __nccwpck_require__(93192); + /** - * @internal + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. */ +function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = Object.create(null); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; -function ProvidedRequiredArgumentsOnDirectivesRule(context) { - var _schema$getDirectives; + function checkOperationTypes(node) { + var _node$operationTypes; - const requiredArgsMap = Object.create(null); - const schema = context.getSchema(); - const definedDirectives = - (_schema$getDirectives = - schema === null || schema === void 0 - ? void 0 - : schema.getDirectives()) !== null && _schema$getDirectives !== void 0 - ? _schema$getDirectives - : _directives.specifiedDirectives; + // See: https://github.com/graphql/graphql-js/issues/2203 - for (const directive of definedDirectives) { - requiredArgsMap[directive.name] = (0, _keyMap.keyMap)( - directive.args.filter(_definition.isRequiredArgument), - (arg) => arg.name, - ); - } + /* c8 ignore next */ + const operationTypesNodes = + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes[operation]; + + if (existingOperationTypes[operation]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type for ${operation} already defined in the schema. It cannot be redefined.`, + { + nodes: operationType, + }, + ), + ); + } else if (alreadyDefinedOperationType) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one ${operation} type in schema.`, + { + nodes: [alreadyDefinedOperationType, operationType], + }, + ), + ); + } else { + definedOperationTypes[operation] = operationType; + } + } - const astDefinitions = context.getDocument().definitions; + return false; + } +} - for (const def of astDefinitions) { - if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - var _def$arguments; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 +/***/ }), - /* c8 ignore next */ - const argNodes = - (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 - ? _def$arguments - : []; - requiredArgsMap[def.name.value] = (0, _keyMap.keyMap)( - argNodes.filter(isRequiredArgumentNode), - (arg) => arg.name.value, - ); - } - } +/***/ 42372: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - return { - Directive: { - // Validate on leave to allow for deeper errors to appear first. - leave(directiveNode) { - const directiveName = directiveNode.name.value; - const requiredArgs = requiredArgsMap[directiveName]; +"use strict"; - if (requiredArgs) { - var _directiveNode$argume; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueTypeNamesRule = UniqueTypeNamesRule; - /* c8 ignore next */ - const argNodes = - (_directiveNode$argume = directiveNode.arguments) !== null && - _directiveNode$argume !== void 0 - ? _directiveNode$argume - : []; - const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); +var _GraphQLError = __nccwpck_require__(93192); - for (const [argName, argDef] of Object.entries(requiredArgs)) { - if (!argNodeMap.has(argName)) { - const argType = (0, _definition.isType)(argDef.type) - ? (0, _inspect.inspect)(argDef.type) - : (0, _printer.print)(argDef.type); - context.reportError( - new _GraphQLError.GraphQLError( - `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, - { - nodes: directiveNode, - }, - ), - ); - } - } - } - }, - }, +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +function UniqueTypeNamesRule(context) { + const knownTypeNames = Object.create(null); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, }; -} -function isRequiredArgumentNode(arg) { - return ( - arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null - ); + function checkTypeName(node) { + const typeName = node.name.value; + + if (schema !== null && schema !== void 0 && schema.getType(typeName)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownTypeNames[typeName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one type named "${typeName}".`, + { + nodes: [knownTypeNames[typeName], node.name], + }, + ), + ); + } else { + knownTypeNames[typeName] = node.name; + } + + return false; + } } /***/ }), -/***/ 14200: +/***/ 10351: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38250,48 +62625,42 @@ function isRequiredArgumentNode(arg) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.ScalarLeafsRule = ScalarLeafsRule; - -var _inspect = __nccwpck_require__(70715); +exports.UniqueVariableNamesRule = UniqueVariableNamesRule; -var _GraphQLError = __nccwpck_require__(442); +var _groupBy = __nccwpck_require__(7890); -var _definition = __nccwpck_require__(82341); +var _GraphQLError = __nccwpck_require__(93192); /** - * Scalar leafs + * Unique variable names * - * A GraphQL document is valid only if all leaf fields (fields without - * sub selections) are of scalar or enum types. + * A GraphQL operation is only valid if all its variables are uniquely named. */ -function ScalarLeafsRule(context) { +function UniqueVariableNamesRule(context) { return { - Field(node) { - const type = context.getType(); - const selectionSet = node.selectionSet; + OperationDefinition(operationNode) { + var _operationNode$variab; - if (type) { - if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) { - if (selectionSet) { - const fieldName = node.name.value; - const typeStr = (0, _inspect.inspect)(type); - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, - { - nodes: selectionSet, - }, - ), - ); - } - } else if (!selectionSet) { - const fieldName = node.name.value; - const typeStr = (0, _inspect.inspect)(type); + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const variableDefinitions = + (_operationNode$variab = operationNode.variableDefinitions) !== null && + _operationNode$variab !== void 0 + ? _operationNode$variab + : []; + const seenVariableDefinitions = (0, _groupBy.groupBy)( + variableDefinitions, + (node) => node.variable.name.value, + ); + + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { context.reportError( new _GraphQLError.GraphQLError( - `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, + `There can be only one variable named "$${variableName}".`, { - nodes: node, + nodes: variableNodes.map((node) => node.variable.name), }, ), ); @@ -38304,7 +62673,7 @@ function ScalarLeafsRule(context) { /***/ }), -/***/ 68608: +/***/ 29362: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38313,92 +62682,198 @@ function ScalarLeafsRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; +exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; + +var _didYouMean = __nccwpck_require__(4475); + +var _inspect = __nccwpck_require__(85856); -var _GraphQLError = __nccwpck_require__(442); +var _keyMap = __nccwpck_require__(22660); -var _kinds = __nccwpck_require__(36578); +var _suggestionList = __nccwpck_require__(11642); -var _collectFields = __nccwpck_require__(28951); +var _GraphQLError = __nccwpck_require__(93192); + +var _printer = __nccwpck_require__(54697); + +var _definition = __nccwpck_require__(57741); /** - * Subscriptions must only include a non-introspection field. + * Value literals of correct type * - * A GraphQL subscription is valid only if it contains a single root field and - * that root field is not an introspection field. + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. * - * See https://spec.graphql.org/draft/#sec-Single-root-field + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type */ -function SingleFieldSubscriptionsRule(context) { +function ValuesOfCorrectTypeRule(context) { return { - OperationDefinition(node) { - if (node.operation === 'subscription') { - const schema = context.getSchema(); - const subscriptionType = schema.getSubscriptionType(); + ListValue(node) { + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + const type = (0, _definition.getNullableType)( + context.getParentInputType(), + ); - if (subscriptionType) { - const operationName = node.name ? node.name.value : null; - const variableValues = Object.create(null); - const document = context.getDocument(); - const fragments = Object.create(null); + if (!(0, _definition.isListType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } + }, - for (const definition of document.definitions) { - if (definition.kind === _kinds.Kind.FRAGMENT_DEFINITION) { - fragments[definition.name.value] = definition; - } - } + ObjectValue(node) { + const type = (0, _definition.getNamedType)(context.getInputType()); - const fields = (0, _collectFields.collectFields)( - schema, - fragments, - variableValues, - subscriptionType, - node.selectionSet, - ); + if (!(0, _definition.isInputObjectType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } // Ensure every required field exists. - if (fields.size > 1) { - const fieldSelectionLists = [...fields.values()]; - const extraFieldSelectionLists = fieldSelectionLists.slice(1); - const extraFieldSelections = extraFieldSelectionLists.flat(); - context.reportError( - new _GraphQLError.GraphQLError( - operationName != null - ? `Subscription "${operationName}" must select only one top level field.` - : 'Anonymous Subscription must select only one top level field.', - { - nodes: extraFieldSelections, - }, - ), - ); - } + const fieldNodeMap = (0, _keyMap.keyMap)( + node.fields, + (field) => field.name.value, + ); - for (const fieldNodes of fields.values()) { - const field = fieldNodes[0]; - const fieldName = field.name.value; + for (const fieldDef of Object.values(type.getFields())) { + const fieldNode = fieldNodeMap[fieldDef.name]; - if (fieldName.startsWith('__')) { - context.reportError( - new _GraphQLError.GraphQLError( - operationName != null - ? `Subscription "${operationName}" must not select an introspection top level field.` - : 'Anonymous Subscription must not select an introspection top level field.', - { - nodes: fieldNodes, - }, - ), - ); - } - } + if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) { + const typeStr = (0, _inspect.inspect)(fieldDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, + { + nodes: node, + }, + ), + ); } } }, + + ObjectField(node) { + const parentType = (0, _definition.getNamedType)( + context.getParentInputType(), + ); + const fieldType = context.getInputType(); + + if (!fieldType && (0, _definition.isInputObjectType)(parentType)) { + const suggestions = (0, _suggestionList.suggestionList)( + node.name.value, + Object.keys(parentType.getFields()), + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${node.name.value}" is not defined by type "${parentType.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: node, + }, + ), + ); + } + }, + + NullValue(node) { + const type = context.getInputType(); + + if ((0, _definition.isNonNullType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${(0, _inspect.inspect)( + type, + )}", found ${(0, _printer.print)(node)}.`, + { + nodes: node, + }, + ), + ); + } + }, + + EnumValue: (node) => isValidValueNode(context, node), + IntValue: (node) => isValidValueNode(context, node), + FloatValue: (node) => isValidValueNode(context, node), + StringValue: (node) => isValidValueNode(context, node), + BooleanValue: (node) => isValidValueNode(context, node), }; } +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ + +function isValidValueNode(context, node) { + // Report any error at the full type expected by the location. + const locationType = context.getInputType(); + + if (!locationType) { + return; + } + + const type = (0, _definition.getNamedType)(locationType); + + if (!(0, _definition.isLeafType)(type)) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + return; + } // Scalars and Enums determine if a literal value is valid via parseLiteral(), + // which may throw or return an invalid value to indicate failure. + + try { + const parseResult = type.parseLiteral( + node, + undefined, + /* variables */ + ); + + if (parseResult === undefined) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + } + } catch (error) { + const typeStr = (0, _inspect.inspect)(locationType); + + if (error instanceof _GraphQLError.GraphQLError) { + context.reportError(error); + } else { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}; ` + error.message, + { + nodes: node, + originalError: error, + }, + ), + ); + } + } +} /***/ }), -/***/ 85496: +/***/ 50655: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38407,98 +62882,176 @@ function SingleFieldSubscriptionsRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule; +exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule; -var _groupBy = __nccwpck_require__(12597); +var _GraphQLError = __nccwpck_require__(93192); -var _GraphQLError = __nccwpck_require__(442); +var _printer = __nccwpck_require__(54697); + +var _definition = __nccwpck_require__(57741); + +var _typeFromAST = __nccwpck_require__(20207); /** - * Unique argument definition names + * Variables are input types * - * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. - * A GraphQL Directive is only valid if all its arguments are uniquely named. + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types */ -function UniqueArgumentDefinitionNamesRule(context) { +function VariablesAreInputTypesRule(context) { return { - DirectiveDefinition(directiveNode) { - var _directiveNode$argume; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + VariableDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.type, + ); - /* c8 ignore next */ - const argumentNodes = - (_directiveNode$argume = directiveNode.arguments) !== null && - _directiveNode$argume !== void 0 - ? _directiveNode$argume - : []; - return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + if (type !== undefined && !(0, _definition.isInputType)(type)) { + const variableName = node.variable.name.value; + const typeName = (0, _printer.print)(node.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${variableName}" cannot be non-input type "${typeName}".`, + { + nodes: node.type, + }, + ), + ); + } }, - - InterfaceTypeDefinition: checkArgUniquenessPerField, - InterfaceTypeExtension: checkArgUniquenessPerField, - ObjectTypeDefinition: checkArgUniquenessPerField, - ObjectTypeExtension: checkArgUniquenessPerField, }; +} - function checkArgUniquenessPerField(typeNode) { - var _typeNode$fields; - const typeName = typeNode.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 +/***/ }), - /* c8 ignore next */ +/***/ 93729: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - const fieldNodes = - (_typeNode$fields = typeNode.fields) !== null && - _typeNode$fields !== void 0 - ? _typeNode$fields - : []; +"use strict"; - for (const fieldDef of fieldNodes) { - var _fieldDef$arguments; - const fieldName = fieldDef.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; - /* c8 ignore next */ +var _inspect = __nccwpck_require__(85856); - const argumentNodes = - (_fieldDef$arguments = fieldDef.arguments) !== null && - _fieldDef$arguments !== void 0 - ? _fieldDef$arguments - : []; - checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); - } +var _GraphQLError = __nccwpck_require__(93192); + +var _kinds = __nccwpck_require__(36096); + +var _definition = __nccwpck_require__(57741); + +var _typeComparators = __nccwpck_require__(33981); + +var _typeFromAST = __nccwpck_require__(20207); + +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +function VariablesInAllowedPositionRule(context) { + let varDefMap = Object.create(null); + return { + OperationDefinition: { + enter() { + varDefMap = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node, type, defaultValue } of usages) { + const varName = node.name.value; + const varDef = varDefMap[varName]; + + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type); + + if ( + varType && + !allowedVariableUsage( + schema, + varType, + varDef.defaultValue, + type, + defaultValue, + ) + ) { + const varTypeStr = (0, _inspect.inspect)(varType); + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, + { + nodes: [varDef, node], + }, + ), + ); + } + } + } + }, + }, - return false; - } + VariableDefinition(node) { + varDefMap[node.variable.name.value] = node; + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * which includes considering if default values exist for either the variable + * or the location at which it is located. + */ - function checkArgUniqueness(parentName, argumentNodes) { - const seenArgs = (0, _groupBy.groupBy)( - argumentNodes, - (arg) => arg.name.value, - ); +function allowedVariableUsage( + schema, + varType, + varDefaultValue, + locationType, + locationDefaultValue, +) { + if ( + (0, _definition.isNonNullType)(locationType) && + !(0, _definition.isNonNullType)(varType) + ) { + const hasNonNullVariableDefaultValue = + varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; - for (const [argName, argNodes] of seenArgs) { - if (argNodes.length > 1) { - context.reportError( - new _GraphQLError.GraphQLError( - `Argument "${parentName}(${argName}:)" can only be defined once.`, - { - nodes: argNodes.map((node) => node.name), - }, - ), - ); - } + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; } - return false; + const nullableLocationType = locationType.ofType; + return (0, _typeComparators.isTypeSubTypeOf)( + schema, + varType, + nullableLocationType, + ); } + + return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType); } /***/ }), -/***/ 25105: +/***/ 26104: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38507,115 +63060,129 @@ function UniqueArgumentDefinitionNamesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule; +exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule; + +var _invariant = __nccwpck_require__(31338); -var _groupBy = __nccwpck_require__(12597); +var _GraphQLError = __nccwpck_require__(93192); -var _GraphQLError = __nccwpck_require__(442); +var _definition = __nccwpck_require__(57741); /** - * Unique argument names + * No deprecated * - * A GraphQL field or directive is only valid if all supplied arguments are - * uniquely named. + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. * - * See https://spec.graphql.org/draft/#sec-Argument-Names + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. */ -function UniqueArgumentNamesRule(context) { +function NoDeprecatedCustomRule(context) { return { - Field: checkArgUniqueness, - Directive: checkArgUniqueness, - }; - - function checkArgUniqueness(parentNode) { - var _parentNode$arguments; - - // FIXME: https://github.com/graphql/graphql-js/issues/2203 - - /* c8 ignore next */ - const argumentNodes = - (_parentNode$arguments = parentNode.arguments) !== null && - _parentNode$arguments !== void 0 - ? _parentNode$arguments - : []; - const seenArgs = (0, _groupBy.groupBy)( - argumentNodes, - (arg) => arg.name.value, - ); + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = + fieldDef === null || fieldDef === void 0 + ? void 0 + : fieldDef.deprecationReason; - for (const [argName, argNodes] of seenArgs) { - if (argNodes.length > 1) { + if (fieldDef && deprecationReason != null) { + const parentType = context.getParentType(); + parentType != null || (0, _invariant.invariant)(false); context.reportError( new _GraphQLError.GraphQLError( - `There can be only one argument named "${argName}".`, + `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, { - nodes: argNodes.map((node) => node.name), + nodes: node, }, ), ); } - } - } -} - + }, -/***/ }), + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = + argDef === null || argDef === void 0 + ? void 0 + : argDef.deprecationReason; -/***/ 6964: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (argDef && deprecationReason != null) { + const directiveDef = context.getDirective(); -"use strict"; + if (directiveDef != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } else { + const parentType = context.getParentType(); + const fieldDef = context.getFieldDef(); + (parentType != null && fieldDef != null) || + (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + ObjectField(node) { + const inputObjectDef = (0, _definition.getNamedType)( + context.getParentInputType(), + ); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule; + if ((0, _definition.isInputObjectType)(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = + inputFieldDef === null || inputFieldDef === void 0 + ? void 0 + : inputFieldDef.deprecationReason; -var _GraphQLError = __nccwpck_require__(442); + if (deprecationReason != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, -/** - * Unique directive names - * - * A GraphQL document is only valid if all defined directives have unique names. - */ -function UniqueDirectiveNamesRule(context) { - const knownDirectiveNames = Object.create(null); - const schema = context.getSchema(); - return { - DirectiveDefinition(node) { - const directiveName = node.name.value; + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = + enumValueDef === null || enumValueDef === void 0 + ? void 0 + : enumValueDef.deprecationReason; - if ( - schema !== null && - schema !== void 0 && - schema.getDirective(directiveName) - ) { - context.reportError( - new _GraphQLError.GraphQLError( - `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, - { - nodes: node.name, - }, - ), + if (enumValueDef && deprecationReason != null) { + const enumTypeDef = (0, _definition.getNamedType)( + context.getInputType(), ); - return; - } - - if (knownDirectiveNames[directiveName]) { + enumTypeDef != null || (0, _invariant.invariant)(false); context.reportError( new _GraphQLError.GraphQLError( - `There can be only one directive named "@${directiveName}".`, + `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, { - nodes: [knownDirectiveNames[directiveName], node.name], + nodes: node, }, ), ); - } else { - knownDirectiveNames[directiveName] = node.name; } - - return false; }, }; } @@ -38623,7 +63190,7 @@ function UniqueDirectiveNamesRule(context) { /***/ }), -/***/ 73540: +/***/ 23310: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38632,92 +63199,38 @@ function UniqueDirectiveNamesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule; - -var _GraphQLError = __nccwpck_require__(442); +exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule; -var _kinds = __nccwpck_require__(36578); +var _GraphQLError = __nccwpck_require__(93192); -var _predicates = __nccwpck_require__(24854); +var _definition = __nccwpck_require__(57741); -var _directives = __nccwpck_require__(27602); +var _introspection = __nccwpck_require__(8077); /** - * Unique directive names per location + * Prohibit introspection queries * - * A GraphQL document is only valid if all non-repeatable directives at - * a given location are uniquely named. + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. * - * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. */ -function UniqueDirectivesPerLocationRule(context) { - const uniqueDirectiveMap = Object.create(null); - const schema = context.getSchema(); - const definedDirectives = schema - ? schema.getDirectives() - : _directives.specifiedDirectives; - - for (const directive of definedDirectives) { - uniqueDirectiveMap[directive.name] = !directive.isRepeatable; - } - - const astDefinitions = context.getDocument().definitions; - - for (const def of astDefinitions) { - if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - uniqueDirectiveMap[def.name.value] = !def.repeatable; - } - } - - const schemaDirectives = Object.create(null); - const typeDirectivesMap = Object.create(null); +function NoSchemaIntrospectionCustomRule(context) { return { - // Many different AST nodes may contain directives. Rather than listing - // them all, just listen for entering any node, and check to see if it - // defines any directives. - enter(node) { - if (!('directives' in node) || !node.directives) { - return; - } - - let seenDirectives; - - if ( - node.kind === _kinds.Kind.SCHEMA_DEFINITION || - node.kind === _kinds.Kind.SCHEMA_EXTENSION - ) { - seenDirectives = schemaDirectives; - } else if ( - (0, _predicates.isTypeDefinitionNode)(node) || - (0, _predicates.isTypeExtensionNode)(node) - ) { - const typeName = node.name.value; - seenDirectives = typeDirectivesMap[typeName]; - - if (seenDirectives === undefined) { - typeDirectivesMap[typeName] = seenDirectives = Object.create(null); - } - } else { - seenDirectives = Object.create(null); - } - - for (const directive of node.directives) { - const directiveName = directive.name.value; + Field(node) { + const type = (0, _definition.getNamedType)(context.getType()); - if (uniqueDirectiveMap[directiveName]) { - if (seenDirectives[directiveName]) { - context.reportError( - new _GraphQLError.GraphQLError( - `The directive "@${directiveName}" can only be used once at this location.`, - { - nodes: [seenDirectives[directiveName], directive], - }, - ), - ); - } else { - seenDirectives[directiveName] = directive; - } - } + if (type && (0, _introspection.isIntrospectionType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, + { + nodes: node, + }, + ), + ); } }, }; @@ -38726,7 +63239,7 @@ function UniqueDirectivesPerLocationRule(context) { /***/ }), -/***/ 51589: +/***/ 22133: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38735,176 +63248,166 @@ function UniqueDirectivesPerLocationRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule; +exports.specifiedSDLRules = exports.specifiedRules = void 0; -var _GraphQLError = __nccwpck_require__(442); +var _ExecutableDefinitionsRule = __nccwpck_require__(75435); -var _definition = __nccwpck_require__(82341); +var _FieldsOnCorrectTypeRule = __nccwpck_require__(76404); -/** - * Unique enum value names - * - * A GraphQL enum type is only valid if all its values are uniquely named. - */ -function UniqueEnumValueNamesRule(context) { - const schema = context.getSchema(); - const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownValueNames = Object.create(null); - return { - EnumTypeDefinition: checkValueUniqueness, - EnumTypeExtension: checkValueUniqueness, - }; +var _FragmentsOnCompositeTypesRule = __nccwpck_require__(58070); - function checkValueUniqueness(node) { - var _node$values; +var _KnownArgumentNamesRule = __nccwpck_require__(48902); - const typeName = node.name.value; +var _KnownDirectivesRule = __nccwpck_require__(33957); - if (!knownValueNames[typeName]) { - knownValueNames[typeName] = Object.create(null); - } // FIXME: https://github.com/graphql/graphql-js/issues/2203 +var _KnownFragmentNamesRule = __nccwpck_require__(77080); - /* c8 ignore next */ +var _KnownTypeNamesRule = __nccwpck_require__(90986); - const valueNodes = - (_node$values = node.values) !== null && _node$values !== void 0 - ? _node$values - : []; - const valueNames = knownValueNames[typeName]; +var _LoneAnonymousOperationRule = __nccwpck_require__(41561); - for (const valueDef of valueNodes) { - const valueName = valueDef.name.value; - const existingType = existingTypeMap[typeName]; +var _LoneSchemaDefinitionRule = __nccwpck_require__(94081); - if ( - (0, _definition.isEnumType)(existingType) && - existingType.getValue(valueName) - ) { - context.reportError( - new _GraphQLError.GraphQLError( - `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, - { - nodes: valueDef.name, - }, - ), - ); - } else if (valueNames[valueName]) { - context.reportError( - new _GraphQLError.GraphQLError( - `Enum value "${typeName}.${valueName}" can only be defined once.`, - { - nodes: [valueNames[valueName], valueDef.name], - }, - ), - ); - } else { - valueNames[valueName] = valueDef.name; - } - } +var _NoFragmentCyclesRule = __nccwpck_require__(31379); - return false; - } -} +var _NoUndefinedVariablesRule = __nccwpck_require__(79299); +var _NoUnusedFragmentsRule = __nccwpck_require__(67081); -/***/ }), +var _NoUnusedVariablesRule = __nccwpck_require__(30410); -/***/ 82965: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(10742); -"use strict"; +var _PossibleFragmentSpreadsRule = __nccwpck_require__(30727); +var _PossibleTypeExtensionsRule = __nccwpck_require__(43548); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule; +var _ProvidedRequiredArgumentsRule = __nccwpck_require__(96066); -var _GraphQLError = __nccwpck_require__(442); +var _ScalarLeafsRule = __nccwpck_require__(1312); -var _definition = __nccwpck_require__(82341); +var _SingleFieldSubscriptionsRule = __nccwpck_require__(38681); -/** - * Unique field definition names - * - * A GraphQL complex type is only valid if all its fields are uniquely named. - */ -function UniqueFieldDefinitionNamesRule(context) { - const schema = context.getSchema(); - const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownFieldNames = Object.create(null); - return { - InputObjectTypeDefinition: checkFieldUniqueness, - InputObjectTypeExtension: checkFieldUniqueness, - InterfaceTypeDefinition: checkFieldUniqueness, - InterfaceTypeExtension: checkFieldUniqueness, - ObjectTypeDefinition: checkFieldUniqueness, - ObjectTypeExtension: checkFieldUniqueness, - }; +var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(16146); - function checkFieldUniqueness(node) { - var _node$fields; +var _UniqueArgumentNamesRule = __nccwpck_require__(19407); - const typeName = node.name.value; +var _UniqueDirectiveNamesRule = __nccwpck_require__(6518); - if (!knownFieldNames[typeName]) { - knownFieldNames[typeName] = Object.create(null); - } // FIXME: https://github.com/graphql/graphql-js/issues/2203 +var _UniqueDirectivesPerLocationRule = __nccwpck_require__(9694); - /* c8 ignore next */ +var _UniqueEnumValueNamesRule = __nccwpck_require__(57266); - const fieldNodes = - (_node$fields = node.fields) !== null && _node$fields !== void 0 - ? _node$fields - : []; - const fieldNames = knownFieldNames[typeName]; +var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(20746); - for (const fieldDef of fieldNodes) { - const fieldName = fieldDef.name.value; +var _UniqueFragmentNamesRule = __nccwpck_require__(8644); - if (hasField(existingTypeMap[typeName], fieldName)) { - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, - { - nodes: fieldDef.name, - }, - ), - ); - } else if (fieldNames[fieldName]) { - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${typeName}.${fieldName}" can only be defined once.`, - { - nodes: [fieldNames[fieldName], fieldDef.name], - }, - ), - ); - } else { - fieldNames[fieldName] = fieldDef.name; - } - } +var _UniqueInputFieldNamesRule = __nccwpck_require__(77231); - return false; - } -} +var _UniqueOperationNamesRule = __nccwpck_require__(63870); -function hasField(type, fieldName) { - if ( - (0, _definition.isObjectType)(type) || - (0, _definition.isInterfaceType)(type) || - (0, _definition.isInputObjectType)(type) - ) { - return type.getFields()[fieldName] != null; - } +var _UniqueOperationTypesRule = __nccwpck_require__(79072); - return false; -} +var _UniqueTypeNamesRule = __nccwpck_require__(42372); + +var _UniqueVariableNamesRule = __nccwpck_require__(10351); + +var _ValuesOfCorrectTypeRule = __nccwpck_require__(29362); + +var _VariablesAreInputTypesRule = __nccwpck_require__(50655); + +var _VariablesInAllowedPositionRule = __nccwpck_require__(93729); + +// Spec Section: "Executable Definitions" +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +// Spec Section: "Fragments on Composite Types" +// Spec Section: "Argument Names" +// Spec Section: "Directives Are Defined" +// Spec Section: "Fragment spread target defined" +// Spec Section: "Fragment Spread Type Existence" +// Spec Section: "Lone Anonymous Operation" +// SDL-specific validation rules +// Spec Section: "Fragments must not form cycles" +// Spec Section: "All Variable Used Defined" +// Spec Section: "Fragments must be used" +// Spec Section: "All Variables Used" +// Spec Section: "Field Selection Merging" +// Spec Section: "Fragment spread is possible" +// Spec Section: "Argument Optionality" +// Spec Section: "Leaf Field Selections" +// Spec Section: "Subscriptions with Single Root Field" +// Spec Section: "Argument Uniqueness" +// Spec Section: "Directives Are Unique Per Location" +// Spec Section: "Fragment Name Uniqueness" +// Spec Section: "Input Object Field Uniqueness" +// Spec Section: "Operation Name Uniqueness" +// Spec Section: "Variable Uniqueness" +// Spec Section: "Value Type Correctness" +// Spec Section: "Variables are Input Types" +// Spec Section: "All Variable Usages Are Allowed" + +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +const specifiedRules = Object.freeze([ + _ExecutableDefinitionsRule.ExecutableDefinitionsRule, + _UniqueOperationNamesRule.UniqueOperationNamesRule, + _LoneAnonymousOperationRule.LoneAnonymousOperationRule, + _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule, + _VariablesAreInputTypesRule.VariablesAreInputTypesRule, + _ScalarLeafsRule.ScalarLeafsRule, + _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule, + _UniqueFragmentNamesRule.UniqueFragmentNamesRule, + _KnownFragmentNamesRule.KnownFragmentNamesRule, + _NoUnusedFragmentsRule.NoUnusedFragmentsRule, + _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule, + _NoFragmentCyclesRule.NoFragmentCyclesRule, + _UniqueVariableNamesRule.UniqueVariableNamesRule, + _NoUndefinedVariablesRule.NoUndefinedVariablesRule, + _NoUnusedVariablesRule.NoUnusedVariablesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _KnownArgumentNamesRule.KnownArgumentNamesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule, + _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule, + _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, +]); +/** + * @internal + */ + +exports.specifiedRules = specifiedRules; +const specifiedSDLRules = Object.freeze([ + _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule, + _UniqueOperationTypesRule.UniqueOperationTypesRule, + _UniqueTypeNamesRule.UniqueTypeNamesRule, + _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule, + _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule, + _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule, + _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule, + _KnownArgumentNamesRule.KnownArgumentNamesOnDirectivesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsOnDirectivesRule, +]); +exports.specifiedSDLRules = specifiedSDLRules; /***/ }), -/***/ 66550: +/***/ 16405: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -38913,164 +63416,158 @@ function hasField(type, fieldName) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueFragmentNamesRule = UniqueFragmentNamesRule; - -var _GraphQLError = __nccwpck_require__(442); - -/** - * Unique fragment names - * - * A GraphQL document is only valid if all defined fragments have unique names. - * - * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness - */ -function UniqueFragmentNamesRule(context) { - const knownFragmentNames = Object.create(null); - return { - OperationDefinition: () => false, - - FragmentDefinition(node) { - const fragmentName = node.name.value; - - if (knownFragmentNames[fragmentName]) { - context.reportError( - new _GraphQLError.GraphQLError( - `There can be only one fragment named "${fragmentName}".`, - { - nodes: [knownFragmentNames[fragmentName], node.name], - }, - ), - ); - } else { - knownFragmentNames[fragmentName] = node.name; - } - - return false; - }, - }; -} - +exports.assertValidSDL = assertValidSDL; +exports.assertValidSDLExtension = assertValidSDLExtension; +exports.validate = validate; +exports.validateSDL = validateSDL; -/***/ }), +var _devAssert = __nccwpck_require__(88054); -/***/ 58417: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +var _GraphQLError = __nccwpck_require__(93192); -"use strict"; +var _visitor = __nccwpck_require__(69826); +var _validate = __nccwpck_require__(51662); -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule; +var _TypeInfo = __nccwpck_require__(63981); -var _invariant = __nccwpck_require__(28864); +var _specifiedRules = __nccwpck_require__(22133); -var _GraphQLError = __nccwpck_require__(442); +var _ValidationContext = __nccwpck_require__(62003); /** - * Unique input field names + * Implements the "Validation" section of the spec. * - * A GraphQL input object value is only valid if all supplied fields are - * uniquely named. + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. * - * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. */ -function UniqueInputFieldNamesRule(context) { - const knownNameStack = []; - let knownNames = Object.create(null); - return { - ObjectValue: { - enter() { - knownNameStack.push(knownNames); - knownNames = Object.create(null); - }, - - leave() { - const prevKnownNames = knownNameStack.pop(); - prevKnownNames || (0, _invariant.invariant)(false); - knownNames = prevKnownNames; - }, - }, +function validate( + schema, + documentAST, + rules = _specifiedRules.specifiedRules, + options, + /** @deprecated will be removed in 17.0.0 */ + typeInfo = new _TypeInfo.TypeInfo(schema), +) { + var _options$maxErrors; - ObjectField(node) { - const fieldName = node.name.value; + const maxErrors = + (_options$maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors) !== + null && _options$maxErrors !== void 0 + ? _options$maxErrors + : 100; + documentAST || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. - if (knownNames[fieldName]) { - context.reportError( + (0, _validate.assertValidSchema)(schema); + const abortObj = Object.freeze({}); + const errors = []; + const context = new _ValidationContext.ValidationContext( + schema, + documentAST, + typeInfo, + (error) => { + if (errors.length >= maxErrors) { + errors.push( new _GraphQLError.GraphQLError( - `There can be only one input field named "${fieldName}".`, - { - nodes: [knownNames[fieldName], node.name], - }, + 'Too many validation errors, error limit reached. Validation aborted.', ), - ); - } else { - knownNames[fieldName] = node.name; - } - }, - }; -} + ); // eslint-disable-next-line @typescript-eslint/no-throw-literal + throw abortObj; + } -/***/ }), + errors.push(error); + }, + ); // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. -/***/ 29177: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + const visitor = (0, _visitor.visitInParallel)( + rules.map((rule) => rule(context)), + ); // Visit the whole document with each instance of all provided rules. -"use strict"; + try { + (0, _visitor.visit)( + documentAST, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor), + ); + } catch (e) { + if (e !== abortObj) { + throw e; + } + } + return errors; +} +/** + * @internal + */ -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.UniqueOperationNamesRule = UniqueOperationNamesRule; +function validateSDL( + documentAST, + schemaToExtend, + rules = _specifiedRules.specifiedSDLRules, +) { + const errors = []; + const context = new _ValidationContext.SDLValidationContext( + documentAST, + schemaToExtend, + (error) => { + errors.push(error); + }, + ); + const visitors = rules.map((rule) => rule(context)); + (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ -var _GraphQLError = __nccwpck_require__(442); +function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} /** - * Unique operation names - * - * A GraphQL document is only valid if all defined operations have unique names. + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. * - * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + * @internal */ -function UniqueOperationNamesRule(context) { - const knownOperationNames = Object.create(null); - return { - OperationDefinition(node) { - const operationName = node.name; - - if (operationName) { - if (knownOperationNames[operationName.value]) { - context.reportError( - new _GraphQLError.GraphQLError( - `There can be only one operation named "${operationName.value}".`, - { - nodes: [ - knownOperationNames[operationName.value], - operationName, - ], - }, - ), - ); - } else { - knownOperationNames[operationName.value] = operationName; - } - } - return false; - }, +function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); - FragmentDefinition: () => false, - }; + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } } /***/ }), -/***/ 86273: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 48267: +/***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -39078,1120 +63575,1257 @@ function UniqueOperationNamesRule(context) { Object.defineProperty(exports, "__esModule", ({ value: true, })); -exports.UniqueOperationTypesRule = UniqueOperationTypesRule; - -var _GraphQLError = __nccwpck_require__(442); +exports.versionInfo = exports.version = void 0; +// Note: This file is autogenerated using "resources/gen-version.js" script and +// automatically updated by "npm version" command. /** - * Unique operation types - * - * A GraphQL document is only valid if it has only one type per operation. + * A string containing the version of the GraphQL.js library + */ +const version = '16.8.1'; +/** + * An object containing the components of the GraphQL.js version string */ -function UniqueOperationTypesRule(context) { - const schema = context.getSchema(); - const definedOperationTypes = Object.create(null); - const existingOperationTypes = schema - ? { - query: schema.getQueryType(), - mutation: schema.getMutationType(), - subscription: schema.getSubscriptionType(), - } - : {}; - return { - SchemaDefinition: checkOperationTypes, - SchemaExtension: checkOperationTypes, - }; - - function checkOperationTypes(node) { - var _node$operationTypes; - - // See: https://github.com/graphql/graphql-js/issues/2203 - - /* c8 ignore next */ - const operationTypesNodes = - (_node$operationTypes = node.operationTypes) !== null && - _node$operationTypes !== void 0 - ? _node$operationTypes - : []; - - for (const operationType of operationTypesNodes) { - const operation = operationType.operation; - const alreadyDefinedOperationType = definedOperationTypes[operation]; - - if (existingOperationTypes[operation]) { - context.reportError( - new _GraphQLError.GraphQLError( - `Type for ${operation} already defined in the schema. It cannot be redefined.`, - { - nodes: operationType, - }, - ), - ); - } else if (alreadyDefinedOperationType) { - context.reportError( - new _GraphQLError.GraphQLError( - `There can be only one ${operation} type in schema.`, - { - nodes: [alreadyDefinedOperationType, operationType], - }, - ), - ); - } else { - definedOperationTypes[operation] = operationType; - } - } - return false; - } -} +exports.version = version; +const versionInfo = Object.freeze({ + major: 16, + minor: 8, + patch: 1, + preReleaseTag: null, +}); +exports.versionInfo = versionInfo; /***/ }), -/***/ 45639: +/***/ 4516: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.UniqueTypeNamesRule = UniqueTypeNamesRule; +exports["default"] = defineInspect; -var _GraphQLError = __nccwpck_require__(442); - -/** - * Unique type names - * - * A GraphQL document is only valid if all defined types have unique names. - */ -function UniqueTypeNamesRule(context) { - const knownTypeNames = Object.create(null); - const schema = context.getSchema(); - return { - ScalarTypeDefinition: checkTypeName, - ObjectTypeDefinition: checkTypeName, - InterfaceTypeDefinition: checkTypeName, - UnionTypeDefinition: checkTypeName, - EnumTypeDefinition: checkTypeName, - InputObjectTypeDefinition: checkTypeName, - }; +var _invariant = _interopRequireDefault(__nccwpck_require__(28864)); - function checkTypeName(node) { - const typeName = node.name.value; +var _nodejsCustomInspectSymbol = _interopRequireDefault(__nccwpck_require__(70234)); - if (schema !== null && schema !== void 0 && schema.getType(typeName)) { - context.reportError( - new _GraphQLError.GraphQLError( - `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, - { - nodes: node.name, - }, - ), - ); - return; - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - if (knownTypeNames[typeName]) { - context.reportError( - new _GraphQLError.GraphQLError( - `There can be only one type named "${typeName}".`, - { - nodes: [knownTypeNames[typeName], node.name], - }, - ), - ); - } else { - knownTypeNames[typeName] = node.name; - } +/** + * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON` + */ +function defineInspect(classObject) { + var fn = classObject.prototype.toJSON; + typeof fn === 'function' || (0, _invariant.default)(0); + classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317') - return false; + if (_nodejsCustomInspectSymbol.default) { + classObject.prototype[_nodejsCustomInspectSymbol.default] = fn; } } /***/ }), -/***/ 70991: +/***/ 70715: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.UniqueVariableNamesRule = UniqueVariableNamesRule; +exports["default"] = inspect; -var _groupBy = __nccwpck_require__(12597); +var _nodejsCustomInspectSymbol = _interopRequireDefault(__nccwpck_require__(70234)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _GraphQLError = __nccwpck_require__(442); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +var MAX_ARRAY_LENGTH = 10; +var MAX_RECURSIVE_DEPTH = 2; /** - * Unique variable names - * - * A GraphQL operation is only valid if all its variables are uniquely named. + * Used to print values in error messages. */ -function UniqueVariableNamesRule(context) { - return { - OperationDefinition(operationNode) { - var _operationNode$variab; - // See: https://github.com/graphql/graphql-js/issues/2203 - - /* c8 ignore next */ - const variableDefinitions = - (_operationNode$variab = operationNode.variableDefinitions) !== null && - _operationNode$variab !== void 0 - ? _operationNode$variab - : []; - const seenVariableDefinitions = (0, _groupBy.groupBy)( - variableDefinitions, - (node) => node.variable.name.value, - ); - - for (const [variableName, variableNodes] of seenVariableDefinitions) { - if (variableNodes.length > 1) { - context.reportError( - new _GraphQLError.GraphQLError( - `There can be only one variable named "$${variableName}".`, - { - nodes: variableNodes.map((node) => node.variable.name), - }, - ), - ); - } - } - }, - }; +function inspect(value) { + return formatValue(value, []); } +function formatValue(value, seenValues) { + switch (_typeof(value)) { + case 'string': + return JSON.stringify(value); -/***/ }), - -/***/ 1641: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; - -var _didYouMean = __nccwpck_require__(28052); + case 'function': + return value.name ? "[function ".concat(value.name, "]") : '[function]'; -var _inspect = __nccwpck_require__(70715); + case 'object': + if (value === null) { + return 'null'; + } -var _keyMap = __nccwpck_require__(65169); + return formatObjectValue(value, seenValues); -var _suggestionList = __nccwpck_require__(69977); + default: + return String(value); + } +} -var _GraphQLError = __nccwpck_require__(442); +function formatObjectValue(value, previouslySeenValues) { + if (previouslySeenValues.indexOf(value) !== -1) { + return '[Circular]'; + } -var _printer = __nccwpck_require__(46157); + var seenValues = [].concat(previouslySeenValues, [value]); + var customInspectFn = getCustomFn(value); -var _definition = __nccwpck_require__(82341); + if (customInspectFn !== undefined) { + var customValue = customInspectFn.call(value); // check for infinite recursion -/** - * Value literals of correct type - * - * A GraphQL document is only valid if all value literals are of the type - * expected at their position. - * - * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type - */ -function ValuesOfCorrectTypeRule(context) { - return { - ListValue(node) { - // Note: TypeInfo will traverse into a list's item type, so look to the - // parent input type to check if it is a list. - const type = (0, _definition.getNullableType)( - context.getParentInputType(), - ); + if (customValue !== value) { + return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues); + } + } else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } - if (!(0, _definition.isListType)(type)) { - isValidValueNode(context, node); - return false; // Don't traverse further. - } - }, + return formatObject(value, seenValues); +} - ObjectValue(node) { - const type = (0, _definition.getNamedType)(context.getInputType()); +function formatObject(object, seenValues) { + var keys = Object.keys(object); - if (!(0, _definition.isInputObjectType)(type)) { - isValidValueNode(context, node); - return false; // Don't traverse further. - } // Ensure every required field exists. + if (keys.length === 0) { + return '{}'; + } - const fieldNodeMap = (0, _keyMap.keyMap)( - node.fields, - (field) => field.name.value, - ); + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } - for (const fieldDef of Object.values(type.getFields())) { - const fieldNode = fieldNodeMap[fieldDef.name]; + var properties = keys.map(function (key) { + var value = formatValue(object[key], seenValues); + return key + ': ' + value; + }); + return '{ ' + properties.join(', ') + ' }'; +} - if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) { - const typeStr = (0, _inspect.inspect)(fieldDef.type); - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, - { - nodes: node, - }, - ), - ); - } - } - }, +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } - ObjectField(node) { - const parentType = (0, _definition.getNamedType)( - context.getParentInputType(), - ); - const fieldType = context.getInputType(); + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } - if (!fieldType && (0, _definition.isInputObjectType)(parentType)) { - const suggestions = (0, _suggestionList.suggestionList)( - node.name.value, - Object.keys(parentType.getFields()), - ); - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${node.name.value}" is not defined by type "${parentType.name}".` + - (0, _didYouMean.didYouMean)(suggestions), - { - nodes: node, - }, - ), - ); - } - }, + var len = Math.min(MAX_ARRAY_LENGTH, array.length); + var remaining = array.length - len; + var items = []; - NullValue(node) { - const type = context.getInputType(); + for (var i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } - if ((0, _definition.isNonNullType)(type)) { - context.reportError( - new _GraphQLError.GraphQLError( - `Expected value of type "${(0, _inspect.inspect)( - type, - )}", found ${(0, _printer.print)(node)}.`, - { - nodes: node, - }, - ), - ); - } - }, + if (remaining === 1) { + items.push('... 1 more item'); + } else if (remaining > 1) { + items.push("... ".concat(remaining, " more items")); + } - EnumValue: (node) => isValidValueNode(context, node), - IntValue: (node) => isValidValueNode(context, node), - FloatValue: (node) => isValidValueNode(context, node), - StringValue: (node) => isValidValueNode(context, node), - BooleanValue: (node) => isValidValueNode(context, node), - }; + return '[' + items.join(', ') + ']'; } -/** - * Any value literal may be a valid representation of a Scalar, depending on - * that scalar type. - */ -function isValidValueNode(context, node) { - // Report any error at the full type expected by the location. - const locationType = context.getInputType(); +function getCustomFn(object) { + var customInspectFn = object[String(_nodejsCustomInspectSymbol.default)]; - if (!locationType) { - return; + if (typeof customInspectFn === 'function') { + return customInspectFn; } - const type = (0, _definition.getNamedType)(locationType); - - if (!(0, _definition.isLeafType)(type)) { - const typeStr = (0, _inspect.inspect)(locationType); - context.reportError( - new _GraphQLError.GraphQLError( - `Expected value of type "${typeStr}", found ${(0, _printer.print)( - node, - )}.`, - { - nodes: node, - }, - ), - ); - return; - } // Scalars and Enums determine if a literal value is valid via parseLiteral(), - // which may throw or return an invalid value to indicate failure. + if (typeof object.inspect === 'function') { + return object.inspect; + } +} - try { - const parseResult = type.parseLiteral( - node, - undefined, - /* variables */ - ); +function getObjectTag(object) { + var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, ''); - if (parseResult === undefined) { - const typeStr = (0, _inspect.inspect)(locationType); - context.reportError( - new _GraphQLError.GraphQLError( - `Expected value of type "${typeStr}", found ${(0, _printer.print)( - node, - )}.`, - { - nodes: node, - }, - ), - ); - } - } catch (error) { - const typeStr = (0, _inspect.inspect)(locationType); + if (tag === 'Object' && typeof object.constructor === 'function') { + var name = object.constructor.name; - if (error instanceof _GraphQLError.GraphQLError) { - context.reportError(error); - } else { - context.reportError( - new _GraphQLError.GraphQLError( - `Expected value of type "${typeStr}", found ${(0, _printer.print)( - node, - )}; ` + error.message, - { - nodes: node, - originalError: error, - }, - ), - ); + if (typeof name === 'string' && name !== '') { + return name; } } + + return tag; } /***/ }), -/***/ 78960: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 28864: +/***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule; +exports["default"] = invariant; -var _GraphQLError = __nccwpck_require__(442); +function invariant(condition, message) { + var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js') -var _printer = __nccwpck_require__(46157); + if (!booleanCondition) { + throw new Error(message != null ? message : 'Unexpected invariant triggered.'); + } +} -var _definition = __nccwpck_require__(82341); -var _typeFromAST = __nccwpck_require__(32901); +/***/ }), -/** - * Variables are input types - * - * A GraphQL operation is only valid if all the variables it defines are of - * input types (scalar, enum, or input object). - * - * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types - */ -function VariablesAreInputTypesRule(context) { - return { - VariableDefinition(node) { - const type = (0, _typeFromAST.typeFromAST)( - context.getSchema(), - node.type, - ); +/***/ 70234: +/***/ ((__unused_webpack_module, exports) => { - if (type !== undefined && !(0, _definition.isInputType)(type)) { - const variableName = node.variable.name.value; - const typeName = (0, _printer.print)(node.type); - context.reportError( - new _GraphQLError.GraphQLError( - `Variable "$${variableName}" cannot be non-input type "${typeName}".`, - { - nodes: node.type, - }, - ), - ); - } - }, - }; -} +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317') +var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined; +var _default = nodejsCustomInspectSymbol; +exports["default"] = _default; /***/ }), -/***/ 80499: +/***/ 22744: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; +exports.isNode = isNode; +exports.Token = exports.Location = void 0; -var _inspect = __nccwpck_require__(70715); +var _defineInspect = _interopRequireDefault(__nccwpck_require__(4516)); -var _GraphQLError = __nccwpck_require__(442); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _kinds = __nccwpck_require__(36578); +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +var Location = /*#__PURE__*/function () { + /** + * The character offset at which this Node begins. + */ -var _definition = __nccwpck_require__(82341); + /** + * The character offset at which this Node ends. + */ -var _typeComparators = __nccwpck_require__(72159); + /** + * The Token at which this Node begins. + */ -var _typeFromAST = __nccwpck_require__(32901); + /** + * The Token at which this Node ends. + */ -/** - * Variables in allowed position - * - * Variable usages must be compatible with the arguments they are passed to. - * - * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed - */ -function VariablesInAllowedPositionRule(context) { - let varDefMap = Object.create(null); - return { - OperationDefinition: { - enter() { - varDefMap = Object.create(null); - }, + /** + * The Source document the AST represents. + */ + function Location(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } - leave(operation) { - const usages = context.getRecursiveVariableUsages(operation); + var _proto = Location.prototype; - for (const { node, type, defaultValue } of usages) { - const varName = node.name.value; - const varDef = varDefMap[varName]; + _proto.toJSON = function toJSON() { + return { + start: this.start, + end: this.end + }; + }; - if (varDef && type) { - // A var type is allowed if it is the same or more strict (e.g. is - // a subtype of) than the expected type. It can be more strict if - // the variable type is non-null when the expected type is nullable. - // If both are list types, the variable item type can be more strict - // than the expected item type (contravariant). - const schema = context.getSchema(); - const varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type); + return Location; +}(); // Print a simplified form when appearing in `inspect` and `util.inspect`. - if ( - varType && - !allowedVariableUsage( - schema, - varType, - varDef.defaultValue, - type, - defaultValue, - ) - ) { - const varTypeStr = (0, _inspect.inspect)(varType); - const typeStr = (0, _inspect.inspect)(type); - context.reportError( - new _GraphQLError.GraphQLError( - `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, - { - nodes: [varDef, node], - }, - ), - ); - } - } - } - }, - }, - VariableDefinition(node) { - varDefMap[node.variable.name.value] = node; - }, - }; -} +exports.Location = Location; +(0, _defineInspect.default)(Location); /** - * Returns true if the variable is allowed in the location it was found, - * which includes considering if default values exist for either the variable - * or the location at which it is located. + * Represents a range of characters represented by a lexical token + * within a Source. */ -function allowedVariableUsage( - schema, - varType, - varDefaultValue, - locationType, - locationDefaultValue, -) { - if ( - (0, _definition.isNonNullType)(locationType) && - !(0, _definition.isNonNullType)(varType) - ) { - const hasNonNullVariableDefaultValue = - varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL; - const hasLocationDefaultValue = locationDefaultValue !== undefined; +var Token = /*#__PURE__*/function () { + /** + * The kind of Token. + */ - if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { - return false; - } + /** + * The character offset at which this Node begins. + */ - const nullableLocationType = locationType.ofType; - return (0, _typeComparators.isTypeSubTypeOf)( - schema, - varType, - nullableLocationType, - ); + /** + * The character offset at which this Node ends. + */ + + /** + * The 1-indexed line number on which this Token appears. + */ + + /** + * The 1-indexed column number at which this Token begins. + */ + + /** + * For non-punctuation tokens, represents the interpreted value of the token. + */ + + /** + * Tokens exist as nodes in a double-linked-list amongst all tokens + * including ignored tokens. is always the first node and + * the last. + */ + function Token(kind, start, end, line, column, prev, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; + this.value = value; + this.prev = prev; + this.next = null; } - return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType); + var _proto2 = Token.prototype; + + _proto2.toJSON = function toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column + }; + }; + + return Token; +}(); // Print a simplified form when appearing in `inspect` and `util.inspect`. + + +exports.Token = Token; +(0, _defineInspect.default)(Token); +/** + * @internal + */ + +function isNode(maybeNode) { + return maybeNode != null && typeof maybeNode.kind === 'string'; } +/** + * The list of all possible AST node types. + */ /***/ }), -/***/ 64994: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 25466: +/***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule; - -var _invariant = __nccwpck_require__(28864); - -var _GraphQLError = __nccwpck_require__(442); - -var _definition = __nccwpck_require__(82341); +exports.dedentBlockStringValue = dedentBlockStringValue; +exports.getBlockStringIndentation = getBlockStringIndentation; +exports.printBlockString = printBlockString; /** - * No deprecated + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. * - * A GraphQL document is only valid if all selected fields and all used enum values have not been - * deprecated. + * This implements the GraphQL spec's BlockStringValue() static algorithm. * - * Note: This rule is optional and is not part of the Validation section of the GraphQL - * Specification. The main purpose of this rule is detection of deprecated usages and not - * necessarily to forbid their use when querying a service. + * @internal */ -function NoDeprecatedCustomRule(context) { - return { - Field(node) { - const fieldDef = context.getFieldDef(); - const deprecationReason = - fieldDef === null || fieldDef === void 0 - ? void 0 - : fieldDef.deprecationReason; +function dedentBlockStringValue(rawString) { + // Expand a block string's raw value into independent lines. + var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first. - if (fieldDef && deprecationReason != null) { - const parentType = context.getParentType(); - parentType != null || (0, _invariant.invariant)(false); - context.reportError( - new _GraphQLError.GraphQLError( - `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, - { - nodes: node, - }, - ), - ); - } - }, + var commonIndent = getBlockStringIndentation(rawString); - Argument(node) { - const argDef = context.getArgument(); - const deprecationReason = - argDef === null || argDef === void 0 - ? void 0 - : argDef.deprecationReason; + if (commonIndent !== 0) { + for (var i = 1; i < lines.length; i++) { + lines[i] = lines[i].slice(commonIndent); + } + } // Remove leading and trailing blank lines. - if (argDef && deprecationReason != null) { - const directiveDef = context.getDirective(); - if (directiveDef != null) { - context.reportError( - new _GraphQLError.GraphQLError( - `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, - { - nodes: node, - }, - ), - ); - } else { - const parentType = context.getParentType(); - const fieldDef = context.getFieldDef(); - (parentType != null && fieldDef != null) || - (0, _invariant.invariant)(false); - context.reportError( - new _GraphQLError.GraphQLError( - `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, - { - nodes: node, - }, - ), - ); - } - } - }, + var startLine = 0; - ObjectField(node) { - const inputObjectDef = (0, _definition.getNamedType)( - context.getParentInputType(), - ); + while (startLine < lines.length && isBlank(lines[startLine])) { + ++startLine; + } - if ((0, _definition.isInputObjectType)(inputObjectDef)) { - const inputFieldDef = inputObjectDef.getFields()[node.name.value]; - const deprecationReason = - inputFieldDef === null || inputFieldDef === void 0 - ? void 0 - : inputFieldDef.deprecationReason; + var endLine = lines.length; - if (deprecationReason != null) { - context.reportError( - new _GraphQLError.GraphQLError( - `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, - { - nodes: node, - }, - ), - ); - } - } - }, + while (endLine > startLine && isBlank(lines[endLine - 1])) { + --endLine; + } // Return a string of the lines joined with U+000A. - EnumValue(node) { - const enumValueDef = context.getEnumValue(); - const deprecationReason = - enumValueDef === null || enumValueDef === void 0 - ? void 0 - : enumValueDef.deprecationReason; - if (enumValueDef && deprecationReason != null) { - const enumTypeDef = (0, _definition.getNamedType)( - context.getInputType(), - ); - enumTypeDef != null || (0, _invariant.invariant)(false); - context.reportError( - new _GraphQLError.GraphQLError( - `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, - { - nodes: node, - }, - ), - ); - } - }, - }; + return lines.slice(startLine, endLine).join('\n'); } +function isBlank(str) { + for (var i = 0; i < str.length; ++i) { + if (str[i] !== ' ' && str[i] !== '\t') { + return false; + } + } -/***/ }), + return true; +} +/** + * @internal + */ -/***/ 283: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -"use strict"; +function getBlockStringIndentation(value) { + var _commonIndent; + var isFirstLine = true; + var isEmptyLine = true; + var indent = 0; + var commonIndent = null; -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule; + for (var i = 0; i < value.length; ++i) { + switch (value.charCodeAt(i)) { + case 13: + // \r + if (value.charCodeAt(i + 1) === 10) { + ++i; // skip \r\n as one symbol + } + + // falls through + + case 10: + // \n + isFirstLine = false; + isEmptyLine = true; + indent = 0; + break; + + case 9: // \t -var _GraphQLError = __nccwpck_require__(442); + case 32: + // + ++indent; + break; -var _definition = __nccwpck_require__(82341); + default: + if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) { + commonIndent = indent; + } -var _introspection = __nccwpck_require__(95678); + isEmptyLine = false; + } + } + return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0; +} /** - * Prohibit introspection queries - * - * A GraphQL document is only valid if all fields selected are not fields that - * return an introspection type. + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. * - * Note: This rule is optional and is not part of the Validation section of the - * GraphQL Specification. This rule effectively disables introspection, which - * does not reflect best practices and should only be done if absolutely necessary. + * @internal */ -function NoSchemaIntrospectionCustomRule(context) { - return { - Field(node) { - const type = (0, _definition.getNamedType)(context.getType()); - if (type && (0, _introspection.isIntrospectionType)(type)) { - context.reportError( - new _GraphQLError.GraphQLError( - `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, - { - nodes: node, - }, - ), - ); - } - }, - }; + +function printBlockString(value) { + var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var isSingleLine = value.indexOf('\n') === -1; + var hasLeadingSpace = value[0] === ' ' || value[0] === '\t'; + var hasTrailingQuote = value[value.length - 1] === '"'; + var hasTrailingSlash = value[value.length - 1] === '\\'; + var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines; + var result = ''; // Format a multi-line block quote to account for leading space. + + if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) { + result += '\n' + indentation; + } + + result += indentation ? value.replace(/\n/g, '\n' + indentation) : value; + + if (printAsMultipleLines) { + result += '\n'; + } + + return '"""' + result.replace(/"""/g, '\\"""') + '"""'; } /***/ }), -/***/ 69807: +/***/ 46157: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ - value: true, + value: true })); -exports.specifiedSDLRules = exports.specifiedRules = void 0; - -var _ExecutableDefinitionsRule = __nccwpck_require__(39581); - -var _FieldsOnCorrectTypeRule = __nccwpck_require__(98591); +exports.print = print; -var _FragmentsOnCompositeTypesRule = __nccwpck_require__(39095); +var _visitor = __nccwpck_require__(78625); -var _KnownArgumentNamesRule = __nccwpck_require__(42485); +var _blockString = __nccwpck_require__(25466); -var _KnownDirectivesRule = __nccwpck_require__(14658); +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +function print(ast) { + return (0, _visitor.visit)(ast, { + leave: printDocASTReducer + }); +} -var _KnownFragmentNamesRule = __nccwpck_require__(21458); +var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future -var _KnownTypeNamesRule = __nccwpck_require__(10426); +var printDocASTReducer = { + Name: function Name(node) { + return node.value; + }, + Variable: function Variable(node) { + return '$' + node.name; + }, + // Document + Document: function Document(node) { + return join(node.definitions, '\n\n') + '\n'; + }, + OperationDefinition: function OperationDefinition(node) { + var op = node.operation; + var name = node.name; + var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + var directives = join(node.directives, ' '); + var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use + // the query short form. + + return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' '); + }, + VariableDefinition: function VariableDefinition(_ref) { + var variable = _ref.variable, + type = _ref.type, + defaultValue = _ref.defaultValue, + directives = _ref.directives; + return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' ')); + }, + SelectionSet: function SelectionSet(_ref2) { + var selections = _ref2.selections; + return block(selections); + }, + Field: function Field(_ref3) { + var alias = _ref3.alias, + name = _ref3.name, + args = _ref3.arguments, + directives = _ref3.directives, + selectionSet = _ref3.selectionSet; + var prefix = wrap('', alias, ': ') + name; + var argsLine = prefix + wrap('(', join(args, ', '), ')'); + + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + + return join([argsLine, join(directives, ' '), selectionSet], ' '); + }, + Argument: function Argument(_ref4) { + var name = _ref4.name, + value = _ref4.value; + return name + ': ' + value; + }, + // Fragments + FragmentSpread: function FragmentSpread(_ref5) { + var name = _ref5.name, + directives = _ref5.directives; + return '...' + name + wrap(' ', join(directives, ' ')); + }, + InlineFragment: function InlineFragment(_ref6) { + var typeCondition = _ref6.typeCondition, + directives = _ref6.directives, + selectionSet = _ref6.selectionSet; + return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' '); + }, + FragmentDefinition: function FragmentDefinition(_ref7) { + var name = _ref7.name, + typeCondition = _ref7.typeCondition, + variableDefinitions = _ref7.variableDefinitions, + directives = _ref7.directives, + selectionSet = _ref7.selectionSet; + return (// Note: fragment variable definitions are experimental and may be changed + // or removed in the future. + "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet + ); + }, + // Value + IntValue: function IntValue(_ref8) { + var value = _ref8.value; + return value; + }, + FloatValue: function FloatValue(_ref9) { + var value = _ref9.value; + return value; + }, + StringValue: function StringValue(_ref10, key) { + var value = _ref10.value, + isBlockString = _ref10.block; + return isBlockString ? (0, _blockString.printBlockString)(value, key === 'description' ? '' : ' ') : JSON.stringify(value); + }, + BooleanValue: function BooleanValue(_ref11) { + var value = _ref11.value; + return value ? 'true' : 'false'; + }, + NullValue: function NullValue() { + return 'null'; + }, + EnumValue: function EnumValue(_ref12) { + var value = _ref12.value; + return value; + }, + ListValue: function ListValue(_ref13) { + var values = _ref13.values; + return '[' + join(values, ', ') + ']'; + }, + ObjectValue: function ObjectValue(_ref14) { + var fields = _ref14.fields; + return '{' + join(fields, ', ') + '}'; + }, + ObjectField: function ObjectField(_ref15) { + var name = _ref15.name, + value = _ref15.value; + return name + ': ' + value; + }, + // Directive + Directive: function Directive(_ref16) { + var name = _ref16.name, + args = _ref16.arguments; + return '@' + name + wrap('(', join(args, ', '), ')'); + }, + // Type + NamedType: function NamedType(_ref17) { + var name = _ref17.name; + return name; + }, + ListType: function ListType(_ref18) { + var type = _ref18.type; + return '[' + type + ']'; + }, + NonNullType: function NonNullType(_ref19) { + var type = _ref19.type; + return type + '!'; + }, + // Type System Definitions + SchemaDefinition: addDescription(function (_ref20) { + var directives = _ref20.directives, + operationTypes = _ref20.operationTypes; + return join(['schema', join(directives, ' '), block(operationTypes)], ' '); + }), + OperationTypeDefinition: function OperationTypeDefinition(_ref21) { + var operation = _ref21.operation, + type = _ref21.type; + return operation + ': ' + type; + }, + ScalarTypeDefinition: addDescription(function (_ref22) { + var name = _ref22.name, + directives = _ref22.directives; + return join(['scalar', name, join(directives, ' ')], ' '); + }), + ObjectTypeDefinition: addDescription(function (_ref23) { + var name = _ref23.name, + interfaces = _ref23.interfaces, + directives = _ref23.directives, + fields = _ref23.fields; + return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '); + }), + FieldDefinition: addDescription(function (_ref24) { + var name = _ref24.name, + args = _ref24.arguments, + type = _ref24.type, + directives = _ref24.directives; + return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' ')); + }), + InputValueDefinition: addDescription(function (_ref25) { + var name = _ref25.name, + type = _ref25.type, + defaultValue = _ref25.defaultValue, + directives = _ref25.directives; + return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '); + }), + InterfaceTypeDefinition: addDescription(function (_ref26) { + var name = _ref26.name, + interfaces = _ref26.interfaces, + directives = _ref26.directives, + fields = _ref26.fields; + return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '); + }), + UnionTypeDefinition: addDescription(function (_ref27) { + var name = _ref27.name, + directives = _ref27.directives, + types = _ref27.types; + return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' '); + }), + EnumTypeDefinition: addDescription(function (_ref28) { + var name = _ref28.name, + directives = _ref28.directives, + values = _ref28.values; + return join(['enum', name, join(directives, ' '), block(values)], ' '); + }), + EnumValueDefinition: addDescription(function (_ref29) { + var name = _ref29.name, + directives = _ref29.directives; + return join([name, join(directives, ' ')], ' '); + }), + InputObjectTypeDefinition: addDescription(function (_ref30) { + var name = _ref30.name, + directives = _ref30.directives, + fields = _ref30.fields; + return join(['input', name, join(directives, ' '), block(fields)], ' '); + }), + DirectiveDefinition: addDescription(function (_ref31) { + var name = _ref31.name, + args = _ref31.arguments, + repeatable = _ref31.repeatable, + locations = _ref31.locations; + return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | '); + }), + SchemaExtension: function SchemaExtension(_ref32) { + var directives = _ref32.directives, + operationTypes = _ref32.operationTypes; + return join(['extend schema', join(directives, ' '), block(operationTypes)], ' '); + }, + ScalarTypeExtension: function ScalarTypeExtension(_ref33) { + var name = _ref33.name, + directives = _ref33.directives; + return join(['extend scalar', name, join(directives, ' ')], ' '); + }, + ObjectTypeExtension: function ObjectTypeExtension(_ref34) { + var name = _ref34.name, + interfaces = _ref34.interfaces, + directives = _ref34.directives, + fields = _ref34.fields; + return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '); + }, + InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) { + var name = _ref35.name, + interfaces = _ref35.interfaces, + directives = _ref35.directives, + fields = _ref35.fields; + return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '); + }, + UnionTypeExtension: function UnionTypeExtension(_ref36) { + var name = _ref36.name, + directives = _ref36.directives, + types = _ref36.types; + return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' '); + }, + EnumTypeExtension: function EnumTypeExtension(_ref37) { + var name = _ref37.name, + directives = _ref37.directives, + values = _ref37.values; + return join(['extend enum', name, join(directives, ' '), block(values)], ' '); + }, + InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) { + var name = _ref38.name, + directives = _ref38.directives, + fields = _ref38.fields; + return join(['extend input', name, join(directives, ' '), block(fields)], ' '); + } +}; -var _LoneAnonymousOperationRule = __nccwpck_require__(74917); +function addDescription(cb) { + return function (node) { + return join([node.description, cb(node)], '\n'); + }; +} +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ -var _LoneSchemaDefinitionRule = __nccwpck_require__(25445); -var _NoFragmentCyclesRule = __nccwpck_require__(78050); +function join(maybeArray) { + var _maybeArray$filter$jo; -var _NoUndefinedVariablesRule = __nccwpck_require__(78876); + var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; + return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) { + return x; + }).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : ''; +} +/** + * Given array, print each item on its own line, wrapped in an + * indented "{ }" block. + */ -var _NoUnusedFragmentsRule = __nccwpck_require__(71887); -var _NoUnusedVariablesRule = __nccwpck_require__(4014); +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ -var _OverlappingFieldsCanBeMergedRule = __nccwpck_require__(95679); -var _PossibleFragmentSpreadsRule = __nccwpck_require__(2585); +function wrap(start, maybeString) { + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; + return maybeString != null && maybeString !== '' ? start + maybeString + end : ''; +} -var _PossibleTypeExtensionsRule = __nccwpck_require__(10969); +function indent(str) { + return wrap(' ', str.replace(/\n/g, '\n ')); +} -var _ProvidedRequiredArgumentsRule = __nccwpck_require__(12849); +function isMultiline(str) { + return str.indexOf('\n') !== -1; +} -var _ScalarLeafsRule = __nccwpck_require__(14200); +function hasMultilineItems(maybeArray) { + return maybeArray != null && maybeArray.some(isMultiline); +} -var _SingleFieldSubscriptionsRule = __nccwpck_require__(68608); -var _UniqueArgumentDefinitionNamesRule = __nccwpck_require__(85496); +/***/ }), -var _UniqueArgumentNamesRule = __nccwpck_require__(25105); +/***/ 78625: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -var _UniqueDirectiveNamesRule = __nccwpck_require__(6964); +"use strict"; -var _UniqueDirectivesPerLocationRule = __nccwpck_require__(73540); -var _UniqueEnumValueNamesRule = __nccwpck_require__(51589); +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.visit = visit; +exports.visitInParallel = visitInParallel; +exports.getVisitFn = getVisitFn; +exports.BREAK = exports.QueryDocumentKeys = void 0; -var _UniqueFieldDefinitionNamesRule = __nccwpck_require__(82965); +var _inspect = _interopRequireDefault(__nccwpck_require__(70715)); -var _UniqueFragmentNamesRule = __nccwpck_require__(66550); +var _ast = __nccwpck_require__(22744); -var _UniqueInputFieldNamesRule = __nccwpck_require__(58417); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _UniqueOperationNamesRule = __nccwpck_require__(29177); +var QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentSpread: ['name', 'directives'], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed + // or removed in the future. + 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'], + InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'] +}; +exports.QueryDocumentKeys = QueryDocumentKeys; +var BREAK = Object.freeze({}); +/** + * visit() will walk through an AST using a depth-first traversal, calling + * the visitor's enter function at each node in the traversal, and calling the + * leave function after visiting that node and all of its child nodes. + * + * By returning different values from the enter and leave functions, the + * behavior of the visitor can be altered, including skipping over a sub-tree of + * the AST (by returning false), editing the AST by returning a value or null + * to remove the value, or to stop the whole traversal by returning BREAK. + * + * When using visit() to edit an AST, the original AST will not be modified, and + * a new version of the AST with the changes applied will be returned from the + * visit function. + * + * const editedAST = visit(ast, { + * enter(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: skip visiting this node + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * }, + * leave(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: no action + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * } + * }); + * + * Alternatively to providing enter() and leave() functions, a visitor can + * instead provide functions named the same as the kinds of AST nodes, or + * enter/leave visitors at a named key, leading to four permutations of the + * visitor API: + * + * 1) Named visitors triggered when entering a node of a specific kind. + * + * visit(ast, { + * Kind(node) { + * // enter the "Kind" node + * } + * }) + * + * 2) Named visitors that trigger upon entering and leaving a node of + * a specific kind. + * + * visit(ast, { + * Kind: { + * enter(node) { + * // enter the "Kind" node + * } + * leave(node) { + * // leave the "Kind" node + * } + * } + * }) + * + * 3) Generic visitors that trigger upon entering and leaving any node. + * + * visit(ast, { + * enter(node) { + * // enter any node + * }, + * leave(node) { + * // leave any node + * } + * }) + * + * 4) Parallel visitors for entering and leaving nodes of a specific kind. + * + * visit(ast, { + * enter: { + * Kind(node) { + * // enter the "Kind" node + * } + * }, + * leave: { + * Kind(node) { + * // leave the "Kind" node + * } + * } + * }) + */ -var _UniqueOperationTypesRule = __nccwpck_require__(86273); +exports.BREAK = BREAK; -var _UniqueTypeNamesRule = __nccwpck_require__(45639); +function visit(root, visitor) { + var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys; -var _UniqueVariableNamesRule = __nccwpck_require__(70991); + /* eslint-disable no-undef-init */ + var stack = undefined; + var inArray = Array.isArray(root); + var keys = [root]; + var index = -1; + var edits = []; + var node = undefined; + var key = undefined; + var parent = undefined; + var path = []; + var ancestors = []; + var newRoot = root; + /* eslint-enable no-undef-init */ -var _ValuesOfCorrectTypeRule = __nccwpck_require__(1641); + do { + index++; + var isLeaving = index === keys.length; + var isEdited = isLeaving && edits.length !== 0; -var _VariablesAreInputTypesRule = __nccwpck_require__(78960); + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); -var _VariablesInAllowedPositionRule = __nccwpck_require__(80499); + if (isEdited) { + if (inArray) { + node = node.slice(); + } else { + var clone = {}; -// Spec Section: "Executable Definitions" -// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" -// Spec Section: "Fragments on Composite Types" -// Spec Section: "Argument Names" -// Spec Section: "Directives Are Defined" -// Spec Section: "Fragment spread target defined" -// Spec Section: "Fragment Spread Type Existence" -// Spec Section: "Lone Anonymous Operation" -// SDL-specific validation rules -// Spec Section: "Fragments must not form cycles" -// Spec Section: "All Variable Used Defined" -// Spec Section: "Fragments must be used" -// Spec Section: "All Variables Used" -// Spec Section: "Field Selection Merging" -// Spec Section: "Fragment spread is possible" -// Spec Section: "Argument Optionality" -// Spec Section: "Leaf Field Selections" -// Spec Section: "Subscriptions with Single Root Field" -// Spec Section: "Argument Uniqueness" -// Spec Section: "Directives Are Unique Per Location" -// Spec Section: "Fragment Name Uniqueness" -// Spec Section: "Input Object Field Uniqueness" -// Spec Section: "Operation Name Uniqueness" -// Spec Section: "Variable Uniqueness" -// Spec Section: "Value Type Correctness" -// Spec Section: "Variables are Input Types" -// Spec Section: "All Variable Usages Are Allowed" + for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) { + var k = _Object$keys2[_i2]; + clone[k] = node[k]; + } -/** - * This set includes all validation rules defined by the GraphQL spec. - * - * The order of the rules in this list has been adjusted to lead to the - * most clear output when encountering multiple validation errors. - */ -const specifiedRules = Object.freeze([ - _ExecutableDefinitionsRule.ExecutableDefinitionsRule, - _UniqueOperationNamesRule.UniqueOperationNamesRule, - _LoneAnonymousOperationRule.LoneAnonymousOperationRule, - _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule, - _KnownTypeNamesRule.KnownTypeNamesRule, - _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule, - _VariablesAreInputTypesRule.VariablesAreInputTypesRule, - _ScalarLeafsRule.ScalarLeafsRule, - _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule, - _UniqueFragmentNamesRule.UniqueFragmentNamesRule, - _KnownFragmentNamesRule.KnownFragmentNamesRule, - _NoUnusedFragmentsRule.NoUnusedFragmentsRule, - _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule, - _NoFragmentCyclesRule.NoFragmentCyclesRule, - _UniqueVariableNamesRule.UniqueVariableNamesRule, - _NoUndefinedVariablesRule.NoUndefinedVariablesRule, - _NoUnusedVariablesRule.NoUnusedVariablesRule, - _KnownDirectivesRule.KnownDirectivesRule, - _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, - _KnownArgumentNamesRule.KnownArgumentNamesRule, - _UniqueArgumentNamesRule.UniqueArgumentNamesRule, - _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule, - _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule, - _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule, - _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule, - _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, -]); -/** - * @internal - */ + node = clone; + } -exports.specifiedRules = specifiedRules; -const specifiedSDLRules = Object.freeze([ - _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule, - _UniqueOperationTypesRule.UniqueOperationTypesRule, - _UniqueTypeNamesRule.UniqueTypeNamesRule, - _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule, - _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule, - _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule, - _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule, - _KnownTypeNamesRule.KnownTypeNamesRule, - _KnownDirectivesRule.KnownDirectivesRule, - _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, - _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule, - _KnownArgumentNamesRule.KnownArgumentNamesOnDirectivesRule, - _UniqueArgumentNamesRule.UniqueArgumentNamesRule, - _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, - _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsOnDirectivesRule, -]); -exports.specifiedSDLRules = specifiedSDLRules; + var editOffset = 0; + for (var ii = 0; ii < edits.length; ii++) { + var editKey = edits[ii][0]; + var editValue = edits[ii][1]; -/***/ }), + if (inArray) { + editKey -= editOffset; + } -/***/ 1581: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + if (inArray && editValue === null) { + node.splice(editKey, 1); + editOffset++; + } else { + node[editKey] = editValue; + } + } + } -"use strict"; + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } else { + key = parent ? inArray ? index : keys[index] : undefined; + node = parent ? parent[key] : newRoot; + if (node === null || node === undefined) { + continue; + } -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.assertValidSDL = assertValidSDL; -exports.assertValidSDLExtension = assertValidSDLExtension; -exports.validate = validate; -exports.validateSDL = validateSDL; + if (parent) { + path.push(key); + } + } -var _devAssert = __nccwpck_require__(6205); + var result = void 0; -var _GraphQLError = __nccwpck_require__(442); + if (!Array.isArray(node)) { + if (!(0, _ast.isNode)(node)) { + throw new Error("Invalid AST Node: ".concat((0, _inspect.default)(node), ".")); + } -var _visitor = __nccwpck_require__(78625); + var visitFn = getVisitFn(visitor, node.kind, isLeaving); -var _validate = __nccwpck_require__(21299); + if (visitFn) { + result = visitFn.call(visitor, node, key, parent, path, ancestors); -var _TypeInfo = __nccwpck_require__(86215); + if (result === BREAK) { + break; + } -var _specifiedRules = __nccwpck_require__(69807); + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } else if (result !== undefined) { + edits.push([key, result]); -var _ValidationContext = __nccwpck_require__(9656); + if (!isLeaving) { + if ((0, _ast.isNode)(result)) { + node = result; + } else { + path.pop(); + continue; + } + } + } + } + } -/** - * Implements the "Validation" section of the spec. - * - * Validation runs synchronously, returning an array of encountered errors, or - * an empty array if no errors were encountered and the document is valid. - * - * A list of specific validation rules may be provided. If not provided, the - * default list of rules defined by the GraphQL specification will be used. - * - * Each validation rules is a function which returns a visitor - * (see the language/visitor API). Visitor methods are expected to return - * GraphQLErrors, or Arrays of GraphQLErrors when invalid. - * - * Validate will stop validation after a `maxErrors` limit has been reached. - * Attackers can send pathologically invalid queries to induce a DoS attack, - * so by default `maxErrors` set to 100 errors. - * - * Optionally a custom TypeInfo instance may be provided. If not provided, one - * will be created from the provided schema. - */ -function validate( - schema, - documentAST, - rules = _specifiedRules.specifiedRules, - options, - /** @deprecated will be removed in 17.0.0 */ - typeInfo = new _TypeInfo.TypeInfo(schema), -) { - var _options$maxErrors; + if (result === undefined && isEdited) { + edits.push([key, node]); + } - const maxErrors = - (_options$maxErrors = - options === null || options === void 0 ? void 0 : options.maxErrors) !== - null && _options$maxErrors !== void 0 - ? _options$maxErrors - : 100; - documentAST || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. + if (isLeaving) { + path.pop(); + } else { + var _visitorKeys$node$kin; - (0, _validate.assertValidSchema)(schema); - const abortObj = Object.freeze({}); - const errors = []; - const context = new _ValidationContext.ValidationContext( - schema, - documentAST, - typeInfo, - (error) => { - if (errors.length >= maxErrors) { - errors.push( - new _GraphQLError.GraphQLError( - 'Too many validation errors, error limit reached. Validation aborted.', - ), - ); // eslint-disable-next-line @typescript-eslint/no-throw-literal + stack = { + inArray: inArray, + index: index, + keys: keys, + edits: edits, + prev: stack + }; + inArray = Array.isArray(node); + keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : []; + index = -1; + edits = []; - throw abortObj; + if (parent) { + ancestors.push(parent); } - errors.push(error); - }, - ); // This uses a specialized visitor which runs multiple visitors in parallel, - // while maintaining the visitor skip and break API. - - const visitor = (0, _visitor.visitInParallel)( - rules.map((rule) => rule(context)), - ); // Visit the whole document with each instance of all provided rules. - - try { - (0, _visitor.visit)( - documentAST, - (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor), - ); - } catch (e) { - if (e !== abortObj) { - throw e; + parent = node; } + } while (stack !== undefined); + + if (edits.length !== 0) { + newRoot = edits[edits.length - 1][1]; } - return errors; + return newRoot; } /** - * @internal + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. */ -function validateSDL( - documentAST, - schemaToExtend, - rules = _specifiedRules.specifiedSDLRules, -) { - const errors = []; - const context = new _ValidationContext.SDLValidationContext( - documentAST, - schemaToExtend, - (error) => { - errors.push(error); + +function visitInParallel(visitors) { + var skipping = new Array(visitors.length); + return { + enter: function enter(node) { + for (var i = 0; i < visitors.length; i++) { + if (skipping[i] == null) { + var fn = getVisitFn(visitors[i], node.kind, + /* isLeaving */ + false); + + if (fn) { + var result = fn.apply(visitors[i], arguments); + + if (result === false) { + skipping[i] = node; + } else if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined) { + return result; + } + } + } + } }, - ); - const visitors = rules.map((rule) => rule(context)); - (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors)); - return errors; -} -/** - * Utility function which asserts a SDL document is valid by throwing an error - * if it is invalid. - * - * @internal - */ + leave: function leave(node) { + for (var i = 0; i < visitors.length; i++) { + if (skipping[i] == null) { + var fn = getVisitFn(visitors[i], node.kind, + /* isLeaving */ + true); -function assertValidSDL(documentAST) { - const errors = validateSDL(documentAST); + if (fn) { + var result = fn.apply(visitors[i], arguments); - if (errors.length !== 0) { - throw new Error(errors.map((error) => error.message).join('\n\n')); - } + if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined && result !== false) { + return result; + } + } + } else if (skipping[i] === node) { + skipping[i] = null; + } + } + } + }; } /** - * Utility function which asserts a SDL document is valid by throwing an error - * if it is invalid. - * - * @internal + * Given a visitor instance, if it is leaving or not, and a node kind, return + * the function the visitor runtime should call. */ -function assertValidSDLExtension(documentAST, schema) { - const errors = validateSDL(documentAST, schema); - - if (errors.length !== 0) { - throw new Error(errors.map((error) => error.message).join('\n\n')); - } -} - -/***/ }), +function getVisitFn(visitor, kind, isLeaving) { + var kindVisitor = visitor[kind]; -/***/ 63732: -/***/ ((__unused_webpack_module, exports) => { + if (kindVisitor) { + if (!isLeaving && typeof kindVisitor === 'function') { + // { Kind() {} } + return kindVisitor; + } -"use strict"; + var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter; + if (typeof kindSpecificVisitor === 'function') { + // { Kind: { enter() {}, leave() {} } } + return kindSpecificVisitor; + } + } else { + var specificVisitor = isLeaving ? visitor.leave : visitor.enter; -Object.defineProperty(exports, "__esModule", ({ - value: true, -})); -exports.versionInfo = exports.version = void 0; -// Note: This file is autogenerated using "resources/gen-version.js" script and -// automatically updated by "npm version" command. + if (specificVisitor) { + if (typeof specificVisitor === 'function') { + // { enter() {}, leave() {} } + return specificVisitor; + } -/** - * A string containing the version of the GraphQL.js library - */ -const version = '16.6.0'; -/** - * An object containing the components of the GraphQL.js version string - */ + var specificKindVisitor = specificVisitor[kind]; -exports.version = version; -const versionInfo = Object.freeze({ - major: 16, - minor: 6, - patch: 0, - preReleaseTag: null, -}); -exports.versionInfo = versionInfo; + if (typeof specificKindVisitor === 'function') { + // { enter: { Kind() {} }, leave: { Kind() {} } } + return specificKindVisitor; + } + } + } +} /***/ }), @@ -76343,7 +100977,7 @@ function parseConfigFile(path) { const nodeError = error; switch (nodeError.code) { case 'ENOENT': - throw new Error((0, utils_1.getConfigErrorMessage)(`config file "${path}" not found; make sure the path is correct or pass the \`--projectRoot\` flag to the script`, constants_1.docsLink.scriptFlags)); + throw new Error((0, utils_1.getConfigErrorMessage)(`config file "${path}" not found - make sure the path is correct or pass the \`--projectRoot\` flag to the script`, constants_1.docsLink.scriptFlags)); case 'EACCES': throw new Error((0, utils_1.getConfigErrorMessage)(`config file "${path}" cannot be accessed`)); case 'EISDIR': @@ -76932,7 +101566,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); const utils_1 = __nccwpck_require__(91897); const constants_1 = __nccwpck_require__(93473); function handleClientError(error) { - if (error.networkError.statusCode === 401) { + if (error.networkError?.statusCode === 401) { throw new Error((0, utils_1.getErrorMessage)({ type: 'auth', message: 'token is invalid', @@ -93591,7 +118225,7 @@ var optimism = __nccwpck_require__(42921); var utilities = __nccwpck_require__(29550); var equality = __nccwpck_require__(71014); var trie = __nccwpck_require__(68581); -var graphql = __nccwpck_require__(49009); +var graphql = __nccwpck_require__(24916); var context = __nccwpck_require__(11547); var ApolloCache = (function () { @@ -96026,7 +120660,7 @@ var equality = __nccwpck_require__(71014); var cache = __nccwpck_require__(68274); var utilities = __nccwpck_require__(29550); var errors = __nccwpck_require__(56169); -var graphql = __nccwpck_require__(49009); +var graphql = __nccwpck_require__(24916); var utils = __nccwpck_require__(41826); var tsInvariant = __nccwpck_require__(35022); var graphqlTag = __nccwpck_require__(1355); @@ -98399,7 +123033,7 @@ var globals = __nccwpck_require__(58203); var tslib = __nccwpck_require__(32132); var utilities = __nccwpck_require__(29550); var utils = __nccwpck_require__(41826); -var graphql = __nccwpck_require__(49009); +var graphql = __nccwpck_require__(24916); var core = __nccwpck_require__(44071); typeof WeakMap === 'function' && @@ -99139,7 +123773,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); var tsInvariant = __nccwpck_require__(35022); var process$1 = __nccwpck_require__(10400); -var graphql = __nccwpck_require__(49009); +var graphql = __nccwpck_require__(24916); function maybe(thunk) { try { @@ -99202,7 +123836,7 @@ exports.maybe = maybe; Object.defineProperty(exports, "__esModule", ({ value: true })); var globals = __nccwpck_require__(58203); -var graphql = __nccwpck_require__(49009); +var graphql = __nccwpck_require__(24916); var tslib = __nccwpck_require__(32132); var zenObservableTs = __nccwpck_require__(5145); __nccwpck_require__(36217); diff --git a/packages/cli/package.json b/packages/cli/package.json index 4769996e..3b7b5f34 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@sherlo/cli", - "version": "1.0.15", + "version": "1.0.16", "description": "A CLI that uploads provided iOS & Android builds to Sherlo and starts a test run", "keywords": [ "visual testing", diff --git a/packages/react-native-storybook/package.json b/packages/react-native-storybook/package.json index 3048212a..47709f4b 100644 --- a/packages/react-native-storybook/package.json +++ b/packages/react-native-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@sherlo/react-native-storybook", - "version": "1.0.15", + "version": "1.0.16", "description": "Sherlo is a Visual Testing tool for React Native Storybook", "keywords": [ "visual testing", diff --git a/yarn.lock b/yarn.lock index a70f899a..58ed9d29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3920,32 +3920,32 @@ component-type "^1.2.1" join-component "^1.1.0" -"@sherlo/api-types@1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@sherlo/api-types/-/api-types-1.1.4.tgz#987059db8a1a472ca8fd7a2263c367dd0b3893fb" - integrity sha512-zL5/pZXr49j+asBUTMU2us32A2lkhxQvSPqomte8k9u+tRM+wfhYpULSMVbzRoOmiof4vJjh73R0L3Q/ITl3Fg== +"@sherlo/api-types@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@sherlo/api-types/-/api-types-1.1.5.tgz#4f714b0f9f9fbffc75ae563b1a3d2f808d9c1614" + integrity sha512-QnnCoD8MQHwhbohwRk6N2ASvxyYSCnNCr6r4HZhe2mgaDvkXJyKux9KS5uHv7rC/7NJWggMo/WuYnEskiXcqOg== -"@sherlo/common-client@1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@sherlo/common-client/-/common-client-1.1.4.tgz#7c567726a8a881d79bbcffadf186ed46bb2216a4" - integrity sha512-1rBOxY6XmJdfsw4PoBFydEqkSWJcv7AVwkpQ+afj+Vvh+b8hMhqAJb2r+xV83YytZsfdWrQBv8IiTMo+/R9WVg== +"@sherlo/common-client@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@sherlo/common-client/-/common-client-1.1.5.tgz#ceb6fb4527afdfbbcdc3306091fb3477a5a9c121" + integrity sha512-GsmZxp0ziYqnSh+UTzO+L1207dzORkU3rBDRO0L+0z1n4I1KVWloNGP9rc5WtROV0ZoZn2PG31/AF45+8072dA== dependencies: graphql-tag "2.12.6" -"@sherlo/sdk-client@1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@sherlo/sdk-client/-/sdk-client-1.1.4.tgz#3d36305b3b959ab097a7b130ef4c34b7ca7c8e05" - integrity sha512-1jSMlOfba/Bb5Tql9XRn/cgBLeQGR6/wKdyOUzEnx88H25NFW0qDZ3JRKL3sTblaXOz5LRWE5nn2GNkYHC7Z7g== +"@sherlo/sdk-client@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@sherlo/sdk-client/-/sdk-client-1.1.5.tgz#77df5e0a80afee9b1893f34cee470bf02cae2591" + integrity sha512-PikrH5kTV0P96VG50JuFvZ9KvtzfZebmDW//wAAv7ywMkR4x2syqwRediBh0kCI5SB/IGv0SBG4DqTkON+3f8A== dependencies: "@apollo/client" "3.7.0" aws-appsync-auth-link "3.0.7" graphql-tag "2.12.6" isomorphic-fetch "3.0.0" -"@sherlo/shared@1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@sherlo/shared/-/shared-1.1.4.tgz#37ad911d424db8aa67312f68f65ec6f7dc62e9d5" - integrity sha512-EzQXht29qYFJT7wkAqlQkZtZHv/pzRBeqkS7rOsnvu0fEhdqUsnc5ZgkcNKMxnpg/vrd3/y0ANAB3o3rWe5h0Q== +"@sherlo/shared@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@sherlo/shared/-/shared-1.1.5.tgz#1954feb29556537f5c1f55e0f0dd05b18bbe6592" + integrity sha512-fcm22MQ0QKDX6tNO5gBYTWACEpGhQehXU9A7OyfVx128bgpw4fFPYOViYd5nBu8QtdOh1vAOiTluK7q7x0+Sag== "@shopify/flash-list@1.6.3": version "1.6.3"