diff --git a/netbox/project-static/dist/graphiql/graphiql.min.js b/netbox/project-static/dist/graphiql/graphiql.min.js index 862ce3a80..03d4ac1e1 100644 --- a/netbox/project-static/dist/graphiql/graphiql.min.js +++ b/netbox/project-static/dist/graphiql/graphiql.min.js @@ -22986,17 +22986,79 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.GraphQLError = void 0; +exports.formatError = formatError; +exports.printError = printError; var _isObjectLike = __webpack_require__(/*! ../jsutils/isObjectLike.mjs */ "../../../node_modules/graphql/jsutils/isObjectLike.mjs"); var _location = __webpack_require__(/*! ../language/location.mjs */ "../../../node_modules/graphql/language/location.mjs"); var _printLocation = __webpack_require__(/*! ../language/printLocation.mjs */ "../../../node_modules/graphql/language/printLocation.mjs"); +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 { - constructor(message, options = {}) { + /** + * 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, @@ -23005,22 +23067,22 @@ class GraphQLError extends Error { path, originalError, extensions - } = options; + } = 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.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. + 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. + 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, @@ -23041,17 +23103,18 @@ class GraphQLError extends Error { originalError: { enumerable: false } - }); - // Include (non-enumerable) stack trace. + }); // Include (non-enumerable) stack trace. + /* c8 ignore start */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 - if ((originalError === null || originalError === void 0 ? void 0 : originalError.stack) != null) { + + if (originalError !== null && originalError !== void 0 && originalError.stack) { Object.defineProperty(this, 'stack', { value: originalError.stack, writable: true, configurable: true }); - } else if (Error.captureStackTrace != null) { + } else if (Error.captureStackTrace) { Error.captureStackTrace(this, GraphQLError); } else { Object.defineProperty(this, 'stack', { @@ -23100,6 +23163,29 @@ 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(); +} /***/ }), @@ -23120,12 +23206,24 @@ Object.defineProperty(exports, "GraphQLError", ({ 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 () { @@ -23157,15 +23255,16 @@ var _GraphQLError = __webpack_require__(/*! ./GraphQLError.mjs */ "../../../node * GraphQL operation, produce a new GraphQLError aware of the location in the * document responsible for the original Error. */ + function locatedError(rawOriginalError, nodes, path) { - var _originalError$nodes; - const originalError = (0, _toError.toError)(rawOriginalError); - // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + 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: (_originalError$nodes = originalError.nodes) !== null && _originalError$nodes !== void 0 ? _originalError$nodes : nodes, + nodes: (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, source: originalError.source, positions: originalError.positions, path, @@ -23195,6 +23294,7 @@ var _GraphQLError = __webpack_require__(/*! ./GraphQLError.mjs */ "../../../node * 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, @@ -23204,613 +23304,6 @@ function syntaxError(source, position, description) { /***/ }), -/***/ "../../../node_modules/graphql/execution/IncrementalGraph.mjs": -/*!********************************************************************!*\ - !*** ../../../node_modules/graphql/execution/IncrementalGraph.mjs ***! - \********************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.IncrementalGraph = void 0; -var _BoxedPromiseOrValue = __webpack_require__(/*! ../jsutils/BoxedPromiseOrValue.mjs */ "../../../node_modules/graphql/jsutils/BoxedPromiseOrValue.mjs"); -var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); -var _isPromise = __webpack_require__(/*! ../jsutils/isPromise.mjs */ "../../../node_modules/graphql/jsutils/isPromise.mjs"); -var _promiseWithResolvers = __webpack_require__(/*! ../jsutils/promiseWithResolvers.mjs */ "../../../node_modules/graphql/jsutils/promiseWithResolvers.mjs"); -var _types = __webpack_require__(/*! ./types.mjs */ "../../../node_modules/graphql/execution/types.mjs"); -/** - * @internal - */ -class IncrementalGraph { - constructor() { - this._rootNodes = new Set(); - this._completedQueue = []; - this._nextQueue = []; - } - getNewRootNodes(incrementalDataRecords) { - const initialResultChildren = new Set(); - this._addIncrementalDataRecords(incrementalDataRecords, undefined, initialResultChildren); - return this._promoteNonEmptyToRoot(initialResultChildren); - } - addCompletedSuccessfulExecutionGroup(successfulExecutionGroup) { - for (const deferredFragmentRecord of successfulExecutionGroup.pendingExecutionGroup.deferredFragmentRecords) { - deferredFragmentRecord.pendingExecutionGroups.delete(successfulExecutionGroup.pendingExecutionGroup); - deferredFragmentRecord.successfulExecutionGroups.add(successfulExecutionGroup); - } - const incrementalDataRecords = successfulExecutionGroup.incrementalDataRecords; - if (incrementalDataRecords !== undefined) { - this._addIncrementalDataRecords(incrementalDataRecords, successfulExecutionGroup.pendingExecutionGroup.deferredFragmentRecords); - } - } - *currentCompletedBatch() { - let completed; - while ((completed = this._completedQueue.shift()) !== undefined) { - yield completed; - } - if (this._rootNodes.size === 0) { - for (const resolve of this._nextQueue) { - resolve(undefined); - } - } - } - nextCompletedBatch() { - const { - promise, - resolve - } = (0, _promiseWithResolvers.promiseWithResolvers)(); - this._nextQueue.push(resolve); - return promise; - } - abort() { - for (const resolve of this._nextQueue) { - resolve(undefined); - } - } - hasNext() { - return this._rootNodes.size > 0; - } - completeDeferredFragment(deferredFragmentRecord) { - if (!this._rootNodes.has(deferredFragmentRecord) || deferredFragmentRecord.pendingExecutionGroups.size > 0) { - return; - } - const successfulExecutionGroups = Array.from(deferredFragmentRecord.successfulExecutionGroups); - this._removeRootNode(deferredFragmentRecord); - for (const successfulExecutionGroup of successfulExecutionGroups) { - for (const otherDeferredFragmentRecord of successfulExecutionGroup.pendingExecutionGroup.deferredFragmentRecords) { - otherDeferredFragmentRecord.successfulExecutionGroups.delete(successfulExecutionGroup); - } - } - const newRootNodes = this._promoteNonEmptyToRoot(deferredFragmentRecord.children); - return { - newRootNodes, - successfulExecutionGroups - }; - } - removeDeferredFragment(deferredFragmentRecord) { - if (!this._rootNodes.has(deferredFragmentRecord)) { - return false; - } - this._removeRootNode(deferredFragmentRecord); - return true; - } - removeStream(streamRecord) { - this._removeRootNode(streamRecord); - } - _removeRootNode(deliveryGroup) { - this._rootNodes.delete(deliveryGroup); - } - _addIncrementalDataRecords(incrementalDataRecords, parents, initialResultChildren) { - for (const incrementalDataRecord of incrementalDataRecords) { - if ((0, _types.isPendingExecutionGroup)(incrementalDataRecord)) { - for (const deferredFragmentRecord of incrementalDataRecord.deferredFragmentRecords) { - this._addDeferredFragment(deferredFragmentRecord, initialResultChildren); - deferredFragmentRecord.pendingExecutionGroups.add(incrementalDataRecord); - } - if (this._completesRootNode(incrementalDataRecord)) { - this._onExecutionGroup(incrementalDataRecord); - } - } else if (parents === undefined) { - initialResultChildren !== undefined || (0, _invariant.invariant)(false); - initialResultChildren.add(incrementalDataRecord); - } else { - for (const parent of parents) { - this._addDeferredFragment(parent, initialResultChildren); - parent.children.add(incrementalDataRecord); - } - } - } - } - _promoteNonEmptyToRoot(maybeEmptyNewRootNodes) { - const newRootNodes = []; - for (const node of maybeEmptyNewRootNodes) { - if ((0, _types.isDeferredFragmentRecord)(node)) { - if (node.pendingExecutionGroups.size > 0) { - for (const pendingExecutionGroup of node.pendingExecutionGroups) { - if (!this._completesRootNode(pendingExecutionGroup)) { - this._onExecutionGroup(pendingExecutionGroup); - } - } - this._rootNodes.add(node); - newRootNodes.push(node); - continue; - } - for (const child of node.children) { - maybeEmptyNewRootNodes.add(child); - } - } else { - this._rootNodes.add(node); - newRootNodes.push(node); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this._onStreamItems(node); - } - } - return newRootNodes; - } - _completesRootNode(pendingExecutionGroup) { - return pendingExecutionGroup.deferredFragmentRecords.some(deferredFragmentRecord => this._rootNodes.has(deferredFragmentRecord)); - } - _addDeferredFragment(deferredFragmentRecord, initialResultChildren) { - if (this._rootNodes.has(deferredFragmentRecord)) { - return; - } - const parent = deferredFragmentRecord.parent; - if (parent === undefined) { - initialResultChildren !== undefined || (0, _invariant.invariant)(false); - initialResultChildren.add(deferredFragmentRecord); - return; - } - parent.children.add(deferredFragmentRecord); - this._addDeferredFragment(parent, initialResultChildren); - } - _onExecutionGroup(pendingExecutionGroup) { - let completedExecutionGroup = pendingExecutionGroup.result; - if (!(completedExecutionGroup instanceof _BoxedPromiseOrValue.BoxedPromiseOrValue)) { - completedExecutionGroup = completedExecutionGroup(); - } - const value = completedExecutionGroup.value; - if ((0, _isPromise.isPromise)(value)) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - value.then(resolved => this._enqueue(resolved)); - } else { - this._enqueue(value); - } - } - async _onStreamItems(streamRecord) { - let items = []; - let errors = []; - let incrementalDataRecords = []; - const streamItemQueue = streamRecord.streamItemQueue; - let streamItemRecord; - while ((streamItemRecord = streamItemQueue.shift()) !== undefined) { - let result = streamItemRecord instanceof _BoxedPromiseOrValue.BoxedPromiseOrValue ? streamItemRecord.value : streamItemRecord().value; - if ((0, _isPromise.isPromise)(result)) { - if (items.length > 0) { - this._enqueue({ - streamRecord, - result: - // TODO add additional test case or rework for coverage - errors.length > 0 /* c8 ignore start */ ? { - items, - errors - } /* c8 ignore stop */ : { - items - }, - incrementalDataRecords - }); - items = []; - errors = []; - incrementalDataRecords = []; - } - // eslint-disable-next-line no-await-in-loop - result = await result; - // wait an additional tick to coalesce resolving additional promises - // within the queue - // eslint-disable-next-line no-await-in-loop - await Promise.resolve(); - } - if (result.item === undefined) { - if (items.length > 0) { - this._enqueue({ - streamRecord, - result: errors.length > 0 ? { - items, - errors - } : { - items - }, - incrementalDataRecords - }); - } - this._enqueue(result.errors === undefined ? { - streamRecord - } : { - streamRecord, - errors: result.errors - }); - return; - } - items.push(result.item); - if (result.errors !== undefined) { - errors.push(...result.errors); - } - if (result.incrementalDataRecords !== undefined) { - incrementalDataRecords.push(...result.incrementalDataRecords); - } - } - } - *_yieldCurrentCompletedIncrementalData(first) { - yield first; - yield* this.currentCompletedBatch(); - } - _enqueue(completed) { - const next = this._nextQueue.shift(); - if (next !== undefined) { - next(this._yieldCurrentCompletedIncrementalData(completed)); - return; - } - this._completedQueue.push(completed); - } -} -exports.IncrementalGraph = IncrementalGraph; - -/***/ }), - -/***/ "../../../node_modules/graphql/execution/IncrementalPublisher.mjs": -/*!************************************************************************!*\ - !*** ../../../node_modules/graphql/execution/IncrementalPublisher.mjs ***! - \************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.buildIncrementalResponse = buildIncrementalResponse; -var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); -var _Path = __webpack_require__(/*! ../jsutils/Path.mjs */ "../../../node_modules/graphql/jsutils/Path.mjs"); -var _IncrementalGraph = __webpack_require__(/*! ./IncrementalGraph.mjs */ "../../../node_modules/graphql/execution/IncrementalGraph.mjs"); -var _types = __webpack_require__(/*! ./types.mjs */ "../../../node_modules/graphql/execution/types.mjs"); -function buildIncrementalResponse(context, result, errors, incrementalDataRecords) { - const incrementalPublisher = new IncrementalPublisher(context); - return incrementalPublisher.buildResponse(result, errors, incrementalDataRecords); -} -/** - * This class is used to publish incremental results to the client, enabling semi-concurrent - * execution while preserving result order. - * - * @internal - */ -class IncrementalPublisher { - constructor(context) { - this._context = context; - this._nextId = 0; - this._incrementalGraph = new _IncrementalGraph.IncrementalGraph(); - } - buildResponse(data, errors, incrementalDataRecords) { - const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); - const pending = this._toPendingResults(newRootNodes); - const initialResult = errors === undefined ? { - data, - pending, - hasNext: true - } : { - errors, - data, - pending, - hasNext: true - }; - return { - initialResult, - subsequentResults: this._subscribe() - }; - } - _toPendingResults(newRootNodes) { - const pendingResults = []; - for (const node of newRootNodes) { - const id = String(this._getNextId()); - node.id = id; - const pendingResult = { - id, - path: (0, _Path.pathToArray)(node.path) - }; - if (node.label !== undefined) { - pendingResult.label = node.label; - } - pendingResults.push(pendingResult); - } - return pendingResults; - } - _getNextId() { - return String(this._nextId++); - } - _subscribe() { - let isDone = false; - const _next = async () => { - if (isDone) { - await this._returnAsyncIteratorsIgnoringErrors(); - return { - value: undefined, - done: true - }; - } - const context = { - pending: [], - incremental: [], - completed: [] - }; - let batch = this._incrementalGraph.currentCompletedBatch(); - do { - for (const completedResult of batch) { - this._handleCompletedIncrementalData(completedResult, context); - } - const { - incremental, - completed - } = context; - if (incremental.length > 0 || completed.length > 0) { - const hasNext = this._incrementalGraph.hasNext(); - if (!hasNext) { - isDone = true; - } - const subsequentIncrementalExecutionResult = { - hasNext - }; - const pending = context.pending; - if (pending.length > 0) { - subsequentIncrementalExecutionResult.pending = pending; - } - if (incremental.length > 0) { - subsequentIncrementalExecutionResult.incremental = incremental; - } - if (completed.length > 0) { - subsequentIncrementalExecutionResult.completed = completed; - } - return { - value: subsequentIncrementalExecutionResult, - done: false - }; - } - // eslint-disable-next-line no-await-in-loop - batch = await this._incrementalGraph.nextCompletedBatch(); - } while (batch !== undefined); - await this._returnAsyncIteratorsIgnoringErrors(); - return { - value: undefined, - done: true - }; - }; - const _return = async () => { - isDone = true; - this._incrementalGraph.abort(); - await this._returnAsyncIterators(); - return { - value: undefined, - done: true - }; - }; - const _throw = async error => { - isDone = true; - this._incrementalGraph.abort(); - await this._returnAsyncIterators(); - return Promise.reject(error); - }; - return { - [Symbol.asyncIterator]() { - return this; - }, - next: _next, - return: _return, - throw: _throw - }; - } - _handleCompletedIncrementalData(completedIncrementalData, context) { - if ((0, _types.isCompletedExecutionGroup)(completedIncrementalData)) { - this._handleCompletedExecutionGroup(completedIncrementalData, context); - } else { - this._handleCompletedStreamItems(completedIncrementalData, context); - } - } - _handleCompletedExecutionGroup(completedExecutionGroup, context) { - if ((0, _types.isFailedExecutionGroup)(completedExecutionGroup)) { - for (const deferredFragmentRecord of completedExecutionGroup.pendingExecutionGroup.deferredFragmentRecords) { - const id = deferredFragmentRecord.id; - if (!this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)) { - // This can occur if multiple deferred grouped field sets error for a fragment. - continue; - } - id !== undefined || (0, _invariant.invariant)(false); - context.completed.push({ - id, - errors: completedExecutionGroup.errors - }); - } - return; - } - this._incrementalGraph.addCompletedSuccessfulExecutionGroup(completedExecutionGroup); - for (const deferredFragmentRecord of completedExecutionGroup.pendingExecutionGroup.deferredFragmentRecords) { - const completion = this._incrementalGraph.completeDeferredFragment(deferredFragmentRecord); - if (completion === undefined) { - continue; - } - const id = deferredFragmentRecord.id; - id !== undefined || (0, _invariant.invariant)(false); - const incremental = context.incremental; - const { - newRootNodes, - successfulExecutionGroups - } = completion; - context.pending.push(...this._toPendingResults(newRootNodes)); - for (const successfulExecutionGroup of successfulExecutionGroups) { - const { - bestId, - subPath - } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup); - const incrementalEntry = { - ...successfulExecutionGroup.result, - id: bestId - }; - if (subPath !== undefined) { - incrementalEntry.subPath = subPath; - } - incremental.push(incrementalEntry); - } - context.completed.push({ - id - }); - } - } - _handleCompletedStreamItems(streamItemsResult, context) { - const streamRecord = streamItemsResult.streamRecord; - const id = streamRecord.id; - id !== undefined || (0, _invariant.invariant)(false); - if (streamItemsResult.errors !== undefined) { - context.completed.push({ - id, - errors: streamItemsResult.errors - }); - this._incrementalGraph.removeStream(streamRecord); - if ((0, _types.isCancellableStreamRecord)(streamRecord)) { - this._context.cancellableStreams !== undefined || (0, _invariant.invariant)(false); - this._context.cancellableStreams.delete(streamRecord); - streamRecord.earlyReturn().catch(() => { - /* c8 ignore next 1 */ - // ignore error - }); - } - } else if (streamItemsResult.result === undefined) { - context.completed.push({ - id - }); - this._incrementalGraph.removeStream(streamRecord); - if ((0, _types.isCancellableStreamRecord)(streamRecord)) { - this._context.cancellableStreams !== undefined || (0, _invariant.invariant)(false); - this._context.cancellableStreams.delete(streamRecord); - } - } else { - const incrementalEntry = { - id, - ...streamItemsResult.result - }; - context.incremental.push(incrementalEntry); - const incrementalDataRecords = streamItemsResult.incrementalDataRecords; - if (incrementalDataRecords !== undefined) { - const newRootNodes = this._incrementalGraph.getNewRootNodes(incrementalDataRecords); - context.pending.push(...this._toPendingResults(newRootNodes)); - } - } - } - _getBestIdAndSubPath(initialId, initialDeferredFragmentRecord, completedExecutionGroup) { - let maxLength = (0, _Path.pathToArray)(initialDeferredFragmentRecord.path).length; - let bestId = initialId; - for (const deferredFragmentRecord of completedExecutionGroup.pendingExecutionGroup.deferredFragmentRecords) { - if (deferredFragmentRecord === initialDeferredFragmentRecord) { - continue; - } - const id = deferredFragmentRecord.id; - // TODO: add test case for when an fragment has not been released, but might be processed for the shortest path. - /* c8 ignore next 3 */ - if (id === undefined) { - continue; - } - const fragmentPath = (0, _Path.pathToArray)(deferredFragmentRecord.path); - const length = fragmentPath.length; - if (length > maxLength) { - maxLength = length; - bestId = id; - } - } - const subPath = completedExecutionGroup.path.slice(maxLength); - return { - bestId, - subPath: subPath.length > 0 ? subPath : undefined - }; - } - async _returnAsyncIterators() { - const cancellableStreams = this._context.cancellableStreams; - if (cancellableStreams === undefined) { - return; - } - const promises = []; - for (const streamRecord of cancellableStreams) { - if (streamRecord.earlyReturn !== undefined) { - promises.push(streamRecord.earlyReturn()); - } - } - await Promise.all(promises); - } - async _returnAsyncIteratorsIgnoringErrors() { - await this._returnAsyncIterators().catch(() => { - // Ignore errors - }); - } -} - -/***/ }), - -/***/ "../../../node_modules/graphql/execution/buildExecutionPlan.mjs": -/*!**********************************************************************!*\ - !*** ../../../node_modules/graphql/execution/buildExecutionPlan.mjs ***! - \**********************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.buildExecutionPlan = buildExecutionPlan; -var _getBySet = __webpack_require__(/*! ../jsutils/getBySet.mjs */ "../../../node_modules/graphql/jsutils/getBySet.mjs"); -var _isSameSet = __webpack_require__(/*! ../jsutils/isSameSet.mjs */ "../../../node_modules/graphql/jsutils/isSameSet.mjs"); -function buildExecutionPlan(originalGroupedFieldSet, parentDeferUsages = new Set()) { - const groupedFieldSet = new Map(); - const newGroupedFieldSets = new Map(); - for (const [responseKey, fieldGroup] of originalGroupedFieldSet) { - const filteredDeferUsageSet = getFilteredDeferUsageSet(fieldGroup); - if ((0, _isSameSet.isSameSet)(filteredDeferUsageSet, parentDeferUsages)) { - groupedFieldSet.set(responseKey, fieldGroup); - continue; - } - let newGroupedFieldSet = (0, _getBySet.getBySet)(newGroupedFieldSets, filteredDeferUsageSet); - if (newGroupedFieldSet === undefined) { - newGroupedFieldSet = new Map(); - newGroupedFieldSets.set(filteredDeferUsageSet, newGroupedFieldSet); - } - newGroupedFieldSet.set(responseKey, fieldGroup); - } - return { - groupedFieldSet, - newGroupedFieldSets - }; -} -function getFilteredDeferUsageSet(fieldGroup) { - const filteredDeferUsageSet = new Set(); - for (const fieldDetails of fieldGroup) { - const deferUsage = fieldDetails.deferUsage; - if (deferUsage === undefined) { - filteredDeferUsageSet.clear(); - return filteredDeferUsageSet; - } - filteredDeferUsageSet.add(deferUsage); - } - for (const deferUsage of filteredDeferUsageSet) { - let parentDeferUsage = deferUsage.parentDeferUsage; - while (parentDeferUsage !== undefined) { - if (filteredDeferUsageSet.has(parentDeferUsage)) { - filteredDeferUsageSet.delete(deferUsage); - break; - } - parentDeferUsage = parentDeferUsage.parentDeferUsage; - } - } - return filteredDeferUsageSet; -} - -/***/ }), - /***/ "../../../node_modules/graphql/execution/collectFields.mjs": /*!*****************************************************************!*\ !*** ../../../node_modules/graphql/execution/collectFields.mjs ***! @@ -23824,9 +23317,6 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.collectFields = collectFields; exports.collectSubfields = collectSubfields; -var _AccumulatorMap = __webpack_require__(/*! ../jsutils/AccumulatorMap.mjs */ "../../../node_modules/graphql/jsutils/AccumulatorMap.mjs"); -var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); -var _ast = __webpack_require__(/*! ../language/ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); var _directives = __webpack_require__(/*! ../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); @@ -23841,22 +23331,11 @@ var _values = __webpack_require__(/*! ./values.mjs */ "../../../node_modules/gra * * @internal */ -function collectFields(schema, fragments, variableValues, runtimeType, operation) { - const groupedFieldSet = new _AccumulatorMap.AccumulatorMap(); - const newDeferUsages = []; - const context = { - schema, - fragments, - variableValues, - runtimeType, - operation, - visitedFragmentNames: new Set() - }; - collectFieldsImpl(context, operation.selectionSet, groupedFieldSet, newDeferUsages); - return { - groupedFieldSet, - newDeferUsages - }; + +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 @@ -23868,38 +23347,18 @@ function collectFields(schema, fragments, variableValues, runtimeType, operation * * @internal */ -// eslint-disable-next-line max-params -function collectSubfields(schema, fragments, variableValues, operation, returnType, fieldGroup) { - const context = { - schema, - fragments, - variableValues, - runtimeType: returnType, - operation, - visitedFragmentNames: new Set() - }; - const subGroupedFieldSet = new _AccumulatorMap.AccumulatorMap(); - const newDeferUsages = []; - for (const fieldDetail of fieldGroup) { - const node = fieldDetail.node; + +function collectSubfields(schema, fragments, variableValues, returnType, fieldNodes) { + const subFieldNodes = new Map(); + const visitedFragmentNames = new Set(); + for (const node of fieldNodes) { if (node.selectionSet) { - collectFieldsImpl(context, node.selectionSet, subGroupedFieldSet, newDeferUsages, fieldDetail.deferUsage); + collectFieldsImpl(schema, fragments, variableValues, returnType, node.selectionSet, subFieldNodes, visitedFragmentNames); } } - return { - groupedFieldSet: subGroupedFieldSet, - newDeferUsages - }; + return subFieldNodes; } -function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages, deferUsage) { - const { - schema, - fragments, - variableValues, - runtimeType, - operation, - visitedFragmentNames - } = context; +function collectFieldsImpl(schema, fragments, variableValues, runtimeType, selectionSet, fields, visitedFragmentNames) { for (const selection of selectionSet.selections) { switch (selection.kind) { case _kinds.Kind.FIELD: @@ -23907,10 +23366,13 @@ function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsage if (!shouldIncludeNode(variableValues, selection)) { continue; } - groupedFieldSet.add(getFieldEntryKey(selection), { - node: selection, - deferUsage - }); + 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: @@ -23918,61 +23380,31 @@ function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsage if (!shouldIncludeNode(variableValues, selection) || !doesFragmentConditionMatch(schema, selection, runtimeType)) { continue; } - const newDeferUsage = getDeferUsage(operation, variableValues, selection, deferUsage); - if (!newDeferUsage) { - collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, deferUsage); - } else { - newDeferUsages.push(newDeferUsage); - collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage); - } + collectFieldsImpl(schema, fragments, variableValues, runtimeType, selection.selectionSet, fields, visitedFragmentNames); break; } case _kinds.Kind.FRAGMENT_SPREAD: { const fragName = selection.name.value; - const newDeferUsage = getDeferUsage(operation, variableValues, selection, deferUsage); - if (!newDeferUsage && (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection))) { + if (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection)) { continue; } + visitedFragmentNames.add(fragName); const fragment = fragments[fragName]; - if (fragment == null || !doesFragmentConditionMatch(schema, fragment, runtimeType)) { + if (!fragment || !doesFragmentConditionMatch(schema, fragment, runtimeType)) { continue; } - if (!newDeferUsage) { - visitedFragmentNames.add(fragName); - collectFieldsImpl(context, fragment.selectionSet, groupedFieldSet, newDeferUsages, deferUsage); - } else { - newDeferUsages.push(newDeferUsage); - collectFieldsImpl(context, fragment.selectionSet, groupedFieldSet, newDeferUsages, newDeferUsage); - } + collectFieldsImpl(schema, fragments, variableValues, runtimeType, fragment.selectionSet, fields, visitedFragmentNames); break; } } } } -/** - * Returns an object containing the `@defer` arguments if a field should be - * deferred based on the experimental flag, defer directive present and - * not disabled by the "if" argument. - */ -function getDeferUsage(operation, variableValues, node, parentDeferUsage) { - const defer = (0, _values.getDirectiveValues)(_directives.GraphQLDeferDirective, node, variableValues); - if (!defer) { - return; - } - if (defer.if === false) { - return; - } - operation.operation !== _ast.OperationTypeNode.SUBSCRIPTION || (0, _invariant.invariant)(false, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.'); - return { - label: typeof defer.label === 'string' ? defer.label : undefined, - parentDeferUsage - }; -} /** * 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) { @@ -23987,6 +23419,7 @@ function shouldIncludeNode(variableValues, node) { /** * Determines if a fragment is applicable to the given type. */ + function doesFragmentConditionMatch(schema, fragment, type) { const typeConditionNode = fragment.typeCondition; if (!typeConditionNode) { @@ -24004,6 +23437,7 @@ function doesFragmentConditionMatch(schema, fragment, type) { /** * 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; } @@ -24021,18 +23455,16 @@ function getFieldEntryKey(node) { Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.assertValidExecutionArguments = assertValidExecutionArguments; exports.buildExecutionContext = buildExecutionContext; exports.buildResolveInfo = buildResolveInfo; -exports.createSourceEventStream = createSourceEventStream; exports.defaultTypeResolver = exports.defaultFieldResolver = void 0; exports.execute = execute; exports.executeSync = executeSync; -exports.experimentalExecuteIncrementally = experimentalExecuteIncrementally; -exports.subscribe = subscribe; -var _BoxedPromiseOrValue = __webpack_require__(/*! ../jsutils/BoxedPromiseOrValue.mjs */ "../../../node_modules/graphql/jsutils/BoxedPromiseOrValue.mjs"); +exports.getFieldDef = getFieldDef; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); -var _isAsyncIterable = __webpack_require__(/*! ../jsutils/isAsyncIterable.mjs */ "../../../node_modules/graphql/jsutils/isAsyncIterable.mjs"); var _isIterableObject = __webpack_require__(/*! ../jsutils/isIterableObject.mjs */ "../../../node_modules/graphql/jsutils/isIterableObject.mjs"); var _isObjectLike = __webpack_require__(/*! ../jsutils/isObjectLike.mjs */ "../../../node_modules/graphql/jsutils/isObjectLike.mjs"); var _isPromise = __webpack_require__(/*! ../jsutils/isPromise.mjs */ "../../../node_modules/graphql/jsutils/isPromise.mjs"); @@ -24045,25 +23477,44 @@ var _locatedError = __webpack_require__(/*! ../error/locatedError.mjs */ "../../ var _ast = __webpack_require__(/*! ../language/ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); -var _directives = __webpack_require__(/*! ../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); +var _introspection = __webpack_require__(/*! ../type/introspection.mjs */ "../../../node_modules/graphql/type/introspection.mjs"); var _validate = __webpack_require__(/*! ../type/validate.mjs */ "../../../node_modules/graphql/type/validate.mjs"); -var _buildExecutionPlan = __webpack_require__(/*! ./buildExecutionPlan.mjs */ "../../../node_modules/graphql/execution/buildExecutionPlan.mjs"); var _collectFields = __webpack_require__(/*! ./collectFields.mjs */ "../../../node_modules/graphql/execution/collectFields.mjs"); -var _IncrementalPublisher = __webpack_require__(/*! ./IncrementalPublisher.mjs */ "../../../node_modules/graphql/execution/IncrementalPublisher.mjs"); -var _mapAsyncIterable = __webpack_require__(/*! ./mapAsyncIterable.mjs */ "../../../node_modules/graphql/execution/mapAsyncIterable.mjs"); -var _types = __webpack_require__(/*! ./types.mjs */ "../../../node_modules/graphql/execution/types.mjs"); var _values = __webpack_require__(/*! ./values.mjs */ "../../../node_modules/graphql/execution/values.mjs"); -/* eslint-disable max-params */ -// This file contains a lot of such errors but we plan to refactor it anyway -// so just disable it for entire file. /** * 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, fieldGroup) => (0, _collectFields.collectSubfields)(exeContext.schema, exeContext.fragments, exeContext.variableValues, exeContext.operation, returnType, fieldGroup)); -const UNEXPECTED_EXPERIMENTAL_DIRECTIVES = 'The provided schema unexpectedly contains experimental directives (@defer or @stream). These directives may only be utilized if experimental execution features are explicitly enabled.'; -const UNEXPECTED_MULTIPLE_PAYLOADS = 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)'; + +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. * @@ -24073,177 +23524,105 @@ const UNEXPECTED_MULTIPLE_PAYLOADS = 'Executing this GraphQL operation would une * * If the arguments to this function do not result in a legal execution context, * a GraphQLError will be thrown immediately explaining the invalid input. - * - * This function does not support incremental delivery (`@defer` and `@stream`). - * If an operation which would defer or stream data is executed with this - * function, it will throw or return a rejected promise. - * Use `experimentalExecuteIncrementally` if you want to support incremental - * delivery. */ function execute(args) { - if (args.schema.getDirective('defer') || args.schema.getDirective('stream')) { - throw new Error(UNEXPECTED_EXPERIMENTAL_DIRECTIVES); - } - const result = experimentalExecuteIncrementally(args); - if (!(0, _isPromise.isPromise)(result)) { - if ('initialResult' in result) { - // This can happen if the operation contains @defer or @stream directives - // and is not validated prior to execution - throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); - } - return result; - } - return result.then(incrementalResult => { - if ('initialResult' in incrementalResult) { - // This can happen if the operation contains @defer or @stream directives - // and is not validated prior to execution - throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); - } - return incrementalResult; - }); -} -/** - * Implements the "Executing requests" section of the GraphQL specification, - * including `@defer` and `@stream` as proposed in - * https://github.com/graphql/graphql-spec/pull/742 - * - * This function returns a Promise of an ExperimentalIncrementalExecutionResults - * object. This object either consists of a single ExecutionResult, or an - * object containing an `initialResult` and a stream of `subsequentResults`. - * - * 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 experimentalExecuteIncrementally(args) { - // If a valid execution context cannot be created due to incorrect arguments, + // 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. + + const exeContext = buildExecutionContext(args); // Return early errors if execution context failed. + if (!('schema' in exeContext)) { return { errors: exeContext }; - } - return executeOperation(exeContext); -} -/** - * Implements the "Executing operations" section of the spec. - * - * Returns 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. - */ -function executeOperation(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, - schema, - fragments, - variableValues, - rootValue + operation } = exeContext; - const rootType = schema.getRootType(operation.operation); - if (rootType == null) { - throw new _GraphQLError.GraphQLError(`Schema is not configured to execute ${operation.operation} operation.`, { - nodes: operation + 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); }); } - const collectedFields = (0, _collectFields.collectFields)(schema, fragments, variableValues, rootType, operation); - let groupedFieldSet = collectedFields.groupedFieldSet; - const newDeferUsages = collectedFields.newDeferUsages; - let graphqlWrappedResult; - if (newDeferUsages.length === 0) { - graphqlWrappedResult = executeRootGroupedFieldSet(exeContext, operation.operation, rootType, rootValue, groupedFieldSet, undefined); - } else { - const executionPlan = (0, _buildExecutionPlan.buildExecutionPlan)(groupedFieldSet); - groupedFieldSet = executionPlan.groupedFieldSet; - const newGroupedFieldSets = executionPlan.newGroupedFieldSets; - const newDeferMap = addNewDeferredFragments(newDeferUsages, new Map()); - graphqlWrappedResult = executeRootGroupedFieldSet(exeContext, operation.operation, rootType, rootValue, groupedFieldSet, newDeferMap); - if (newGroupedFieldSets.size > 0) { - const newPendingExecutionGroups = collectExecutionGroups(exeContext, rootType, rootValue, undefined, undefined, newGroupedFieldSets, newDeferMap); - graphqlWrappedResult = withNewExecutionGroups(graphqlWrappedResult, newPendingExecutionGroups); - } - } - if ((0, _isPromise.isPromise)(graphqlWrappedResult)) { - return graphqlWrappedResult.then(resolved => buildDataResponse(exeContext, resolved[0], resolved[1]), error => ({ - data: null, - errors: withError(exeContext.errors, error) - })); - } - return buildDataResponse(exeContext, graphqlWrappedResult[0], graphqlWrappedResult[1]); + return buildResponse(result, exeContext.errors); } catch (error) { - return { - data: null, - errors: withError(exeContext.errors, error) - }; + exeContext.errors.push(error); + return buildResponse(null, exeContext.errors); } } -function withNewExecutionGroups(result, newPendingExecutionGroups) { - if ((0, _isPromise.isPromise)(result)) { - return result.then(resolved => { - addIncrementalDataRecords(resolved, newPendingExecutionGroups); - return resolved; - }); - } - addIncrementalDataRecords(result, newPendingExecutionGroups); - return result; -} -function addIncrementalDataRecords(graphqlWrappedResult, incrementalDataRecords) { - if (incrementalDataRecords === undefined) { - return; - } - if (graphqlWrappedResult[1] === undefined) { - graphqlWrappedResult[1] = [...incrementalDataRecords]; - } else { - graphqlWrappedResult[1].push(...incrementalDataRecords); - } -} -function withError(errors, error) { - return errors === undefined ? [error] : [...errors, error]; -} -function buildDataResponse(exeContext, data, incrementalDataRecords) { - const errors = exeContext.errors; - if (incrementalDataRecords === undefined) { - return errors !== undefined ? { - errors, - data - } : { - data - }; - } - return (0, _IncrementalPublisher.buildIncrementalResponse)(exeContext, data, errors, incrementalDataRecords); -} /** * 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 = experimentalExecuteIncrementally(args); - // Assert that the execution was synchronous. - if ((0, _isPromise.isPromise)(result) || 'initialResult' in result) { + 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. * - * TODO: consider no longer exporting this function * @internal */ + function buildExecutionContext(args) { var _definition$name, _operation$variableDe; const { @@ -24255,11 +23634,8 @@ function buildExecutionContext(args) { operationName, fieldResolver, typeResolver, - subscribeFieldResolver, - enableEarlyExecution + subscribeFieldResolver } = args; - // If the schema used for execution is invalid, throw an error. - (0, _validate.assertValidSchema)(schema); let operation; const fragments = Object.create(null); for (const definition of document.definitions) { @@ -24277,8 +23653,7 @@ function buildExecutionContext(args) { case _kinds.Kind.FRAGMENT_DEFINITION: fragments[definition.name.value] = definition; break; - default: - // ignore non-executable definitions + default: // ignore non-executable definitions } } if (!operation) { @@ -24286,9 +23661,10 @@ function buildExecutionContext(args) { 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 + } // 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 @@ -24306,100 +23682,91 @@ function buildExecutionContext(args) { fieldResolver: fieldResolver !== null && fieldResolver !== void 0 ? fieldResolver : defaultFieldResolver, typeResolver: typeResolver !== null && typeResolver !== void 0 ? typeResolver : defaultTypeResolver, subscribeFieldResolver: subscribeFieldResolver !== null && subscribeFieldResolver !== void 0 ? subscribeFieldResolver : defaultFieldResolver, - enableEarlyExecution: enableEarlyExecution === true, - errors: undefined, - cancellableStreams: undefined + errors: [] }; } -function buildPerEventExecutionContext(exeContext, payload) { - return { - ...exeContext, - rootValue: payload, - errors: undefined - }; -} -function executeRootGroupedFieldSet(exeContext, operation, rootType, rootValue, groupedFieldSet, deferMap) { - switch (operation) { +/** + * 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, undefined, groupedFieldSet, undefined, deferMap); + return executeFields(exeContext, rootType, rootValue, path, rootFields); case _ast.OperationTypeNode.MUTATION: - return executeFieldsSerially(exeContext, rootType, rootValue, undefined, groupedFieldSet, undefined, deferMap); + 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, undefined, groupedFieldSet, undefined, deferMap); + 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, groupedFieldSet, incrementalContext, deferMap) { - return (0, _promiseReduce.promiseReduce)(groupedFieldSet, (graphqlWrappedResult, [responseName, fieldGroup]) => { + +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, fieldGroup, fieldPath, incrementalContext, deferMap); + const result = executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath); if (result === undefined) { - return graphqlWrappedResult; + return results; } if ((0, _isPromise.isPromise)(result)) { - return result.then(resolved => { - graphqlWrappedResult[0][responseName] = resolved[0]; - addIncrementalDataRecords(graphqlWrappedResult, resolved[1]); - return graphqlWrappedResult; + return result.then(resolvedResult => { + results[responseName] = resolvedResult; + return results; }); } - graphqlWrappedResult[0][responseName] = result[0]; - addIncrementalDataRecords(graphqlWrappedResult, result[1]); - return graphqlWrappedResult; - }, [Object.create(null), undefined]); + 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, groupedFieldSet, incrementalContext, deferMap) { + +function executeFields(exeContext, parentType, sourceValue, path, fields) { const results = Object.create(null); - const graphqlWrappedResult = [results, undefined]; let containsPromise = false; try { - for (const [responseName, fieldGroup] of groupedFieldSet) { + for (const [responseName, fieldNodes] of fields.entries()) { const fieldPath = (0, _Path.addPath)(path, responseName, parentType.name); - const result = executeField(exeContext, parentType, sourceValue, fieldGroup, fieldPath, incrementalContext, deferMap); + const result = executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath); if (result !== undefined) { + results[responseName] = result; if ((0, _isPromise.isPromise)(result)) { - results[responseName] = result.then(resolved => { - addIncrementalDataRecords(graphqlWrappedResult, resolved[1]); - return resolved[0]; - }); containsPromise = true; - } else { - results[responseName] = result[0]; - addIncrementalDataRecords(graphqlWrappedResult, result[1]); } } } } catch (error) { if (containsPromise) { // Ensure that any promises returned by other fields are handled, as they may also reject. - return (0, _promiseForObject.promiseForObject)(results, () => { - /* noop */ - }).finally(() => { + return (0, _promiseForObject.promiseForObject)(results).finally(() => { throw error; }); } throw error; - } - // If there are no promises, we can just return the object and any incrementalDataRecords + } // If there are no promises, we can just return the object + if (!containsPromise) { - return graphqlWrappedResult; - } - // Otherwise, results is a map from field name to the result of resolving that + 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, resolved => [resolved, graphqlWrappedResult[1]]); -} -function toNodes(fieldGroup) { - return fieldGroup.map(fieldDetails => fieldDetails.node); + + return (0, _promiseForObject.promiseForObject)(results); } /** * Implements the "Executing fields" section of the spec @@ -24407,49 +23774,51 @@ function toNodes(fieldGroup) { * 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, fieldGroup, path, incrementalContext, deferMap) { + +function executeField(exeContext, parentType, source, fieldNodes, path) { var _fieldDef$resolve; - const fieldName = fieldGroup[0].node.name.value; - const fieldDef = exeContext.schema.getField(parentType, fieldName); + 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, toNodes(fieldGroup), parentType, path); - // Get the resolve function, regardless of if its result is normal or abrupt (error). + 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, fieldGroup[0].node, exeContext.variableValues); - // The resolve function's optional third argument is a context value that + 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)) { - return completePromisedValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap); + completed = result.then(resolved => completeValue(exeContext, returnType, fieldNodes, info, path, resolved)); + } else { + completed = completeValue(exeContext, returnType, fieldNodes, info, path, result); } - const completed = completeValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap); 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 => { - handleFieldError(rawError, exeContext, returnType, fieldGroup, path, incrementalContext); - return [null, undefined]; + const error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(path)); + return handleFieldError(error, returnType, exeContext); }); } return completed; } catch (rawError) { - handleFieldError(rawError, exeContext, returnType, fieldGroup, path, incrementalContext); - return [null, undefined]; + const error = (0, _locatedError.locatedError)(rawError, fieldNodes, (0, _Path.pathToArray)(path)); + return handleFieldError(error, returnType, exeContext); } } /** - * TODO: consider no longer exporting this function * @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. @@ -24466,22 +23835,16 @@ function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) { variableValues: exeContext.variableValues }; } -function handleFieldError(rawError, exeContext, returnType, fieldGroup, path, incrementalContext) { - const error = (0, _locatedError.locatedError)(rawError, toNodes(fieldGroup), (0, _Path.pathToArray)(path)); +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 + } // Otherwise, error protection is applied, logging the error and resolving // a null value for this field if one is encountered. - const context = incrementalContext !== null && incrementalContext !== void 0 ? incrementalContext : exeContext; - let errors = context.errors; - if (errors === undefined) { - errors = []; - context.errors = errors; - } - errors.push(error); + + exeContext.errors.push(error); + return null; } /** * Implements the instructions for completeValue as defined in the @@ -24504,271 +23867,94 @@ function handleFieldError(rawError, exeContext, returnType, fieldGroup, path, in * Otherwise, the field type expects a sub-selection set, and will complete the * value by executing all sub-selections. */ -function completeValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap) { + +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 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, fieldGroup, info, path, result, incrementalContext, deferMap); - if (completed[0] === null) { + 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 value is null or undefined then return null. + if (result == null) { - return [null, undefined]; - } - // If field type is List, complete each item in the list with the inner type + 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, fieldGroup, info, path, result, incrementalContext, deferMap); - } - // If field type is a leaf type, Scalar or Enum, serialize to a valid value, + 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), undefined]; - } - // If field type is an abstract type, Interface or Union, determine the + 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, fieldGroup, info, path, result, incrementalContext, deferMap); - } - // If field type is Object, execute and complete all sub-selections. + 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, fieldGroup, info, path, result, incrementalContext, deferMap); + 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)); } -async function completePromisedValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap) { - try { - const resolved = await result; - let completed = completeValue(exeContext, returnType, fieldGroup, info, path, resolved, incrementalContext, deferMap); - if ((0, _isPromise.isPromise)(completed)) { - completed = await completed; - } - return completed; - } catch (rawError) { - handleFieldError(rawError, exeContext, returnType, fieldGroup, path, incrementalContext); - return [null, undefined]; - } -} -/** - * Returns an object containing info for streaming if a field should be - * streamed based on the experimental flag, stream directive present and - * not disabled by the "if" argument. - */ -function getStreamUsage(exeContext, fieldGroup, path) { - // do not stream inner lists of multi-dimensional lists - if (typeof path.key === 'number') { - return; - } - // TODO: add test for this case (a streamed list nested under a list). - /* c8 ignore next 7 */ - if (fieldGroup._streamUsage !== undefined) { - return fieldGroup._streamUsage; - } - // validation only allows equivalent streams on multiple fields, so it is - // safe to only check the first fieldNode for the stream directive - const stream = (0, _values.getDirectiveValues)(_directives.GraphQLStreamDirective, fieldGroup[0].node, exeContext.variableValues); - if (!stream) { - return; - } - if (stream.if === false) { - return; - } - typeof stream.initialCount === 'number' || (0, _invariant.invariant)(false, 'initialCount must be a number'); - stream.initialCount >= 0 || (0, _invariant.invariant)(false, 'initialCount must be a positive integer'); - exeContext.operation.operation !== _ast.OperationTypeNode.SUBSCRIPTION || (0, _invariant.invariant)(false, '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.'); - const streamedFieldGroup = fieldGroup.map(fieldDetails => ({ - node: fieldDetails.node, - deferUsage: undefined - })); - const streamUsage = { - initialCount: stream.initialCount, - label: typeof stream.label === 'string' ? stream.label : undefined, - fieldGroup: streamedFieldGroup - }; - fieldGroup._streamUsage = streamUsage; - return streamUsage; -} -/** - * Complete a async iterator value by completing the result and calling - * recursively until all the results are completed. - */ -async function completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path, asyncIterator, incrementalContext, deferMap) { - let containsPromise = false; - const completedResults = []; - const graphqlWrappedResult = [completedResults, undefined]; - let index = 0; - const streamUsage = getStreamUsage(exeContext, fieldGroup, path); - const earlyReturn = asyncIterator.return === undefined ? undefined : asyncIterator.return.bind(asyncIterator); - try { - // eslint-disable-next-line no-constant-condition - while (true) { - if (streamUsage && index >= streamUsage.initialCount) { - const streamItemQueue = buildAsyncStreamItemQueue(index, path, asyncIterator, exeContext, streamUsage.fieldGroup, info, itemType); - let streamRecord; - if (earlyReturn === undefined) { - streamRecord = { - label: streamUsage.label, - path, - streamItemQueue - }; - } else { - streamRecord = { - label: streamUsage.label, - path, - earlyReturn, - streamItemQueue - }; - if (exeContext.cancellableStreams === undefined) { - exeContext.cancellableStreams = new Set(); - } - exeContext.cancellableStreams.add(streamRecord); - } - addIncrementalDataRecords(graphqlWrappedResult, [streamRecord]); - break; - } - const itemPath = (0, _Path.addPath)(path, index, undefined); - let iteration; - try { - // eslint-disable-next-line no-await-in-loop - iteration = await asyncIterator.next(); - } catch (rawError) { - throw (0, _locatedError.locatedError)(rawError, toNodes(fieldGroup), (0, _Path.pathToArray)(path)); - } - // TODO: add test case for stream returning done before initialCount - /* c8 ignore next 3 */ - if (iteration.done) { - break; - } - const item = iteration.value; - // TODO: add tests for stream backed by asyncIterator that returns a promise - /* c8 ignore start */ - if ((0, _isPromise.isPromise)(item)) { - completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap)); - containsPromise = true; - } else if ( /* c8 ignore stop */ - completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap) - // TODO: add tests for stream backed by asyncIterator that completes to a promise - /* c8 ignore start */) { - containsPromise = true; - } - /* c8 ignore stop */ - index++; - } - } catch (error) { - if (earlyReturn !== undefined) { - earlyReturn().catch(() => { - /* c8 ignore next 1 */ - // ignore error - }); - } - throw error; - } - return containsPromise ? /* c8 ignore start */Promise.all(completedResults).then(resolved => [resolved, graphqlWrappedResult[1]]) : /* c8 ignore stop */graphqlWrappedResult; -} /** * Complete a list value by completing each item in the list with the * inner type */ -function completeListValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap) { - const itemType = returnType.ofType; - if ((0, _isAsyncIterable.isAsyncIterable)(result)) { - const asyncIterator = result[Symbol.asyncIterator](); - return completeAsyncIteratorValue(exeContext, itemType, fieldGroup, info, path, asyncIterator, incrementalContext, deferMap); - } + +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}".`); - } - return completeIterableValue(exeContext, itemType, fieldGroup, info, path, result, incrementalContext, deferMap); -} -function completeIterableValue(exeContext, itemType, fieldGroup, info, path, items, incrementalContext, deferMap) { - // This is specified as a simple map, however we're optimizing the path + } // 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 = []; - const graphqlWrappedResult = [completedResults, undefined]; - let index = 0; - const streamUsage = getStreamUsage(exeContext, fieldGroup, path); - const iterator = items[Symbol.iterator](); - let iteration = iterator.next(); - while (!iteration.done) { - const item = iteration.value; - if (streamUsage && index >= streamUsage.initialCount) { - const syncStreamRecord = { - label: streamUsage.label, - path, - streamItemQueue: buildSyncStreamItemQueue(item, index, path, iterator, exeContext, streamUsage.fieldGroup, info, itemType) - }; - addIncrementalDataRecords(graphqlWrappedResult, [syncStreamRecord]); - break; - } + 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); - if ((0, _isPromise.isPromise)(item)) { - completedResults.push(completePromisedListItemValue(item, graphqlWrappedResult, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap)); - containsPromise = true; - } else if (completeListItemValue(item, completedResults, graphqlWrappedResult, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap)) { - containsPromise = true; + 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); } - index++; - iteration = iterator.next(); - } - return containsPromise ? Promise.all(completedResults).then(resolved => [resolved, graphqlWrappedResult[1]]) : graphqlWrappedResult; -} -/** - * Complete a list item value by adding it to the completed results. - * - * Returns true if the value is a Promise. - */ -function completeListItemValue(item, completedResults, parent, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap) { - try { - const completedItem = completeValue(exeContext, itemType, fieldGroup, info, itemPath, item, incrementalContext, deferMap); - if ((0, _isPromise.isPromise)(completedItem)) { - // Note: we don't rely on a `catch` method, but we do expect "thenable" - // to take a second callback for the error case. - completedResults.push(completedItem.then(resolved => { - addIncrementalDataRecords(parent, resolved[1]); - return resolved[0]; - }, rawError => { - handleFieldError(rawError, exeContext, itemType, fieldGroup, itemPath, incrementalContext); - return null; - })); - return true; - } - completedResults.push(completedItem[0]); - addIncrementalDataRecords(parent, completedItem[1]); - } catch (rawError) { - handleFieldError(rawError, exeContext, itemType, fieldGroup, itemPath, incrementalContext); - completedResults.push(null); - } - return false; -} -async function completePromisedListItemValue(item, parent, exeContext, itemType, fieldGroup, info, itemPath, incrementalContext, deferMap) { - try { - const resolved = await item; - let completed = completeValue(exeContext, itemType, fieldGroup, info, itemPath, resolved, incrementalContext, deferMap); - if ((0, _isPromise.isPromise)(completed)) { - completed = await completed; - } - addIncrementalDataRecords(parent, completed[1]); - return completed[0]; - } catch (rawError) { - handleFieldError(rawError, exeContext, itemType, fieldGroup, itemPath, incrementalContext); - return null; - } + }); + 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) { @@ -24780,24 +23966,23 @@ function completeLeafValue(returnType, result) { * 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, fieldGroup, info, path, result, incrementalContext, deferMap) { + +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, fieldGroup, info, result), fieldGroup, info, path, result, incrementalContext, deferMap)); + return runtimeType.then(resolvedRuntimeType => completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result)); } - return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldGroup, info, result), fieldGroup, info, path, result, incrementalContext, deferMap); + return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result); } -function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldGroup, info, 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.`, { - nodes: toNodes(fieldGroup) - }); - } - // releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType` + 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.'); } @@ -24807,17 +23992,17 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldGr 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: toNodes(fieldGroup) + nodes: fieldNodes }); } if (!(0, _definition.isObjectType)(runtimeType)) { throw new _GraphQLError.GraphQLError(`Abstract type "${returnType.name}" was resolved to a non-object type "${runtimeTypeName}".`, { - nodes: toNodes(fieldGroup) + 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: toNodes(fieldGroup) + nodes: fieldNodes }); } return runtimeType; @@ -24825,92 +24010,34 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldGr /** * Complete an Object value by executing all sub-selections. */ -function completeObjectValue(exeContext, returnType, fieldGroup, info, path, result, incrementalContext, deferMap) { - // If there is an isTypeOf predicate function, call it with the + +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, fieldGroup); + throw invalidReturnTypeError(returnType, result, fieldNodes); } - return collectAndExecuteSubfields(exeContext, returnType, fieldGroup, path, result, incrementalContext, deferMap); + return executeFields(exeContext, returnType, result, path, subFieldNodes); }); } if (!isTypeOf) { - throw invalidReturnTypeError(returnType, result, fieldGroup); + throw invalidReturnTypeError(returnType, result, fieldNodes); } } - return collectAndExecuteSubfields(exeContext, returnType, fieldGroup, path, result, incrementalContext, deferMap); + return executeFields(exeContext, returnType, result, path, subFieldNodes); } -function invalidReturnTypeError(returnType, result, fieldGroup) { +function invalidReturnTypeError(returnType, result, fieldNodes) { return new _GraphQLError.GraphQLError(`Expected value of type "${returnType.name}" but got: ${(0, _inspect.inspect)(result)}.`, { - nodes: toNodes(fieldGroup) + nodes: fieldNodes }); } -/** - * Instantiates new DeferredFragmentRecords for the given path within an - * incremental data record, returning an updated map of DeferUsage - * objects to DeferredFragmentRecords. - * - * Note: As defer directives may be used with operations returning lists, - * a DeferUsage object may correspond to many DeferredFragmentRecords. - * - * DeferredFragmentRecord creation includes the following steps: - * 1. The new DeferredFragmentRecord is instantiated at the given path. - * 2. The parent result record is calculated from the given incremental data - * record. - * 3. The IncrementalPublisher is notified that a new DeferredFragmentRecord - * with the calculated parent has been added; the record will be released only - * after the parent has completed. - * - */ -function addNewDeferredFragments(newDeferUsages, newDeferMap, path) { - // For each new deferUsage object: - for (const newDeferUsage of newDeferUsages) { - const parentDeferUsage = newDeferUsage.parentDeferUsage; - const parent = parentDeferUsage === undefined ? undefined : deferredFragmentRecordFromDeferUsage(parentDeferUsage, newDeferMap); - // Instantiate the new record. - const deferredFragmentRecord = new _types.DeferredFragmentRecord(path, newDeferUsage.label, parent); - // Update the map. - newDeferMap.set(newDeferUsage, deferredFragmentRecord); - } - return newDeferMap; -} -function deferredFragmentRecordFromDeferUsage(deferUsage, deferMap) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return deferMap.get(deferUsage); -} -function collectAndExecuteSubfields(exeContext, returnType, fieldGroup, path, result, incrementalContext, deferMap) { - // Collect sub-fields to execute to complete this value. - const collectedSubfields = collectSubfields(exeContext, returnType, fieldGroup); - let groupedFieldSet = collectedSubfields.groupedFieldSet; - const newDeferUsages = collectedSubfields.newDeferUsages; - if (deferMap === undefined && newDeferUsages.length === 0) { - return executeFields(exeContext, returnType, result, path, groupedFieldSet, incrementalContext, undefined); - } - const subExecutionPlan = buildSubExecutionPlan(groupedFieldSet, incrementalContext === null || incrementalContext === void 0 ? void 0 : incrementalContext.deferUsageSet); - groupedFieldSet = subExecutionPlan.groupedFieldSet; - const newGroupedFieldSets = subExecutionPlan.newGroupedFieldSets; - const newDeferMap = addNewDeferredFragments(newDeferUsages, new Map(deferMap), path); - const subFields = executeFields(exeContext, returnType, result, path, groupedFieldSet, incrementalContext, newDeferMap); - if (newGroupedFieldSets.size > 0) { - const newPendingExecutionGroups = collectExecutionGroups(exeContext, returnType, result, path, incrementalContext === null || incrementalContext === void 0 ? void 0 : incrementalContext.deferUsageSet, newGroupedFieldSets, newDeferMap); - return withNewExecutionGroups(subFields, newPendingExecutionGroups); - } - return subFields; -} -function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet) { - let executionPlan = originalGroupedFieldSet._executionPlan; - if (executionPlan !== undefined) { - return executionPlan; - } - executionPlan = (0, _buildExecutionPlan.buildExecutionPlan)(originalGroupedFieldSet, deferUsageSet); - originalGroupedFieldSet._executionPlan = executionPlan; - return executionPlan; -} /** * If a resolveType function is not given, then a default resolve behavior is * used which attempts two strategies: @@ -24921,12 +24048,13 @@ function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet) { * 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. + } // Otherwise, test each possible type. + const possibleTypes = info.schema.getPossibleTypes(abstractType); const promisedIsTypeOfResults = []; for (let i = 0; i < possibleTypes.length; i++) { @@ -24968,340 +24096,27 @@ const defaultFieldResolver = function (source, args, contextValue, info) { } }; /** - * Implements the "Subscribe" algorithm described in the GraphQL specification. + * 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. * - * 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. - * - * This function does not support incremental delivery (`@defer` and `@stream`). - * If an operation which would defer or stream data is executed with this - * function, a field error will be raised at the location of the `@defer` or - * `@stream` directive. - * - * Accepts an object with named arguments. + * @internal */ exports.defaultFieldResolver = defaultFieldResolver; -function subscribe(args) { - // 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 - }; +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; } - const resultOrStream = createSourceEventStreamImpl(exeContext); - if ((0, _isPromise.isPromise)(resultOrStream)) { - return resultOrStream.then(resolvedResultOrStream => mapSourceToResponse(exeContext, resolvedResultOrStream)); - } - return mapSourceToResponse(exeContext, resultOrStream); -} -function mapSourceToResponse(exeContext, resultOrStream) { - 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. - return (0, _mapAsyncIterable.mapAsyncIterable)(resultOrStream, payload => executeOperation(buildPerEventExecutionContext(exeContext, payload))); -} -/** - * 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. - */ -function createSourceEventStream(args) { - // 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 createSourceEventStreamImpl(exeContext); -} -function createSourceEventStreamImpl(exeContext) { - try { - const eventStream = executeSubscription(exeContext); - if ((0, _isPromise.isPromise)(eventStream)) { - return eventStream.then(undefined, error => ({ - errors: [error] - })); - } - return eventStream; - } catch (error) { - return { - errors: [error] - }; - } -} -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 { - groupedFieldSet - } = (0, _collectFields.collectFields)(schema, fragments, variableValues, rootType, operation); - const firstRootField = groupedFieldSet.entries().next().value; - const [responseName, fieldGroup] = firstRootField; - const fieldName = fieldGroup[0].node.name.value; - const fieldDef = schema.getField(rootType, fieldName); - const fieldNodes = fieldGroup.map(fieldDetails => fieldDetails.node); - if (!fieldDef) { - throw new _GraphQLError.GraphQLError(`The subscription field "${fieldName}" is not defined.`, { - nodes: fieldNodes - }); - } - const path = (0, _Path.addPath)(undefined, responseName, rootType.name); - const info = 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 result = resolveFn(rootValue, args, contextValue, info); - if ((0, _isPromise.isPromise)(result)) { - return result.then(assertEventStream).then(undefined, error => { - throw (0, _locatedError.locatedError)(error, fieldNodes, (0, _Path.pathToArray)(path)); - }); - } - return assertEventStream(result); - } catch (error) { - throw (0, _locatedError.locatedError)(error, fieldNodes, (0, _Path.pathToArray)(path)); - } -} -function assertEventStream(result) { - if (result instanceof Error) { - throw result; - } - // Assert field returned an event stream, otherwise yield an error. - if (!(0, _isAsyncIterable.isAsyncIterable)(result)) { - throw new _GraphQLError.GraphQLError('Subscription field must return Async Iterable. ' + `Received: ${(0, _inspect.inspect)(result)}.`); - } - return result; -} -function collectExecutionGroups(exeContext, parentType, sourceValue, path, parentDeferUsages, newGroupedFieldSets, deferMap) { - const newPendingExecutionGroups = []; - for (const [deferUsageSet, groupedFieldSet] of newGroupedFieldSets) { - const deferredFragmentRecords = getDeferredFragmentRecords(deferUsageSet, deferMap); - const pendingExecutionGroup = { - deferredFragmentRecords, - result: undefined - }; - const executor = () => executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, { - errors: undefined, - deferUsageSet - }, deferMap); - if (exeContext.enableEarlyExecution) { - pendingExecutionGroup.result = new _BoxedPromiseOrValue.BoxedPromiseOrValue(shouldDefer(parentDeferUsages, deferUsageSet) ? Promise.resolve().then(executor) : executor()); - } else { - pendingExecutionGroup.result = () => new _BoxedPromiseOrValue.BoxedPromiseOrValue(executor()); - } - newPendingExecutionGroups.push(pendingExecutionGroup); - } - return newPendingExecutionGroups; -} -function shouldDefer(parentDeferUsages, deferUsages) { - // If we have a new child defer usage, defer. - // Otherwise, this defer usage was already deferred when it was initially - // encountered, and is now in the midst of executing early, so the new - // deferred grouped fields set can be executed immediately. - return parentDeferUsages === undefined || !Array.from(deferUsages).every(deferUsage => parentDeferUsages.has(deferUsage)); -} -function executeExecutionGroup(pendingExecutionGroup, exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap) { - let result; - try { - result = executeFields(exeContext, parentType, sourceValue, path, groupedFieldSet, incrementalContext, deferMap); - } catch (error) { - return { - pendingExecutionGroup, - path: (0, _Path.pathToArray)(path), - errors: withError(incrementalContext.errors, error) - }; - } - if ((0, _isPromise.isPromise)(result)) { - return result.then(resolved => buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, resolved), error => ({ - pendingExecutionGroup, - path: (0, _Path.pathToArray)(path), - errors: withError(incrementalContext.errors, error) - })); - } - return buildCompletedExecutionGroup(incrementalContext.errors, pendingExecutionGroup, path, result); -} -function buildCompletedExecutionGroup(errors, pendingExecutionGroup, path, result) { - return { - pendingExecutionGroup, - path: (0, _Path.pathToArray)(path), - result: errors === undefined ? { - data: result[0] - } : { - data: result[0], - errors - }, - incrementalDataRecords: result[1] - }; -} -function getDeferredFragmentRecords(deferUsages, deferMap) { - return Array.from(deferUsages).map(deferUsage => deferredFragmentRecordFromDeferUsage(deferUsage, deferMap)); -} -function buildSyncStreamItemQueue(initialItem, initialIndex, streamPath, iterator, exeContext, fieldGroup, info, itemType) { - const streamItemQueue = []; - const enableEarlyExecution = exeContext.enableEarlyExecution; - const firstExecutor = () => { - const initialPath = (0, _Path.addPath)(streamPath, initialIndex, undefined); - const firstStreamItem = new _BoxedPromiseOrValue.BoxedPromiseOrValue(completeStreamItem(initialPath, initialItem, exeContext, { - errors: undefined - }, fieldGroup, info, itemType)); - let iteration = iterator.next(); - let currentIndex = initialIndex + 1; - let currentStreamItem = firstStreamItem; - while (!iteration.done) { - // TODO: add test case for early sync termination - /* c8 ignore next 6 */ - if (currentStreamItem instanceof _BoxedPromiseOrValue.BoxedPromiseOrValue) { - const result = currentStreamItem.value; - if (!(0, _isPromise.isPromise)(result) && result.errors !== undefined) { - break; - } - } - const itemPath = (0, _Path.addPath)(streamPath, currentIndex, undefined); - const value = iteration.value; - const currentExecutor = () => completeStreamItem(itemPath, value, exeContext, { - errors: undefined - }, fieldGroup, info, itemType); - currentStreamItem = enableEarlyExecution ? new _BoxedPromiseOrValue.BoxedPromiseOrValue(currentExecutor()) : () => new _BoxedPromiseOrValue.BoxedPromiseOrValue(currentExecutor()); - streamItemQueue.push(currentStreamItem); - iteration = iterator.next(); - currentIndex = initialIndex + 1; - } - streamItemQueue.push(new _BoxedPromiseOrValue.BoxedPromiseOrValue({})); - return firstStreamItem.value; - }; - streamItemQueue.push(enableEarlyExecution ? new _BoxedPromiseOrValue.BoxedPromiseOrValue(Promise.resolve().then(firstExecutor)) : () => new _BoxedPromiseOrValue.BoxedPromiseOrValue(firstExecutor())); - return streamItemQueue; -} -function buildAsyncStreamItemQueue(initialIndex, streamPath, asyncIterator, exeContext, fieldGroup, info, itemType) { - const streamItemQueue = []; - const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, initialIndex, asyncIterator, exeContext, fieldGroup, info, itemType); - streamItemQueue.push(exeContext.enableEarlyExecution ? new _BoxedPromiseOrValue.BoxedPromiseOrValue(executor()) : () => new _BoxedPromiseOrValue.BoxedPromiseOrValue(executor())); - return streamItemQueue; -} -async function getNextAsyncStreamItemResult(streamItemQueue, streamPath, index, asyncIterator, exeContext, fieldGroup, info, itemType) { - let iteration; - try { - iteration = await asyncIterator.next(); - } catch (error) { - return { - errors: [(0, _locatedError.locatedError)(error, toNodes(fieldGroup), (0, _Path.pathToArray)(streamPath))] - }; - } - if (iteration.done) { - return {}; - } - const itemPath = (0, _Path.addPath)(streamPath, index, undefined); - const result = completeStreamItem(itemPath, iteration.value, exeContext, { - errors: undefined - }, fieldGroup, info, itemType); - const executor = () => getNextAsyncStreamItemResult(streamItemQueue, streamPath, index + 1, asyncIterator, exeContext, fieldGroup, info, itemType); - streamItemQueue.push(exeContext.enableEarlyExecution ? new _BoxedPromiseOrValue.BoxedPromiseOrValue(executor()) : () => new _BoxedPromiseOrValue.BoxedPromiseOrValue(executor())); - return result; -} -function completeStreamItem(itemPath, item, exeContext, incrementalContext, fieldGroup, info, itemType) { - if ((0, _isPromise.isPromise)(item)) { - return completePromisedValue(exeContext, itemType, fieldGroup, info, itemPath, item, incrementalContext, new Map()).then(resolvedItem => buildStreamItemResult(incrementalContext.errors, resolvedItem), error => ({ - errors: withError(incrementalContext.errors, error) - })); - } - let result; - try { - try { - result = completeValue(exeContext, itemType, fieldGroup, info, itemPath, item, incrementalContext, new Map()); - } catch (rawError) { - handleFieldError(rawError, exeContext, itemType, fieldGroup, itemPath, incrementalContext); - result = [null, undefined]; - } - } catch (error) { - return { - errors: withError(incrementalContext.errors, error) - }; - } - if ((0, _isPromise.isPromise)(result)) { - return result.then(undefined, rawError => { - handleFieldError(rawError, exeContext, itemType, fieldGroup, itemPath, incrementalContext); - return [null, undefined]; - }).then(resolvedItem => buildStreamItemResult(incrementalContext.errors, resolvedItem), error => ({ - errors: withError(incrementalContext.errors, error) - })); - } - return buildStreamItemResult(incrementalContext.errors, result); -} -function buildStreamItemResult(errors, result) { - return { - item: result[0], - errors, - incrementalDataRecords: result[1] - }; + return parentType.getFields()[fieldName]; } /***/ }), @@ -25320,7 +24135,7 @@ Object.defineProperty(exports, "__esModule", ({ Object.defineProperty(exports, "createSourceEventStream", ({ enumerable: true, get: function () { - return _execute.createSourceEventStream; + return _subscribe.createSourceEventStream; } })); Object.defineProperty(exports, "defaultFieldResolver", ({ @@ -25347,12 +24162,6 @@ Object.defineProperty(exports, "executeSync", ({ return _execute.executeSync; } })); -Object.defineProperty(exports, "experimentalExecuteIncrementally", ({ - enumerable: true, - get: function () { - return _execute.experimentalExecuteIncrementally; - } -})); Object.defineProperty(exports, "getArgumentValues", ({ enumerable: true, get: function () { @@ -25380,18 +24189,19 @@ Object.defineProperty(exports, "responsePathAsArray", ({ Object.defineProperty(exports, "subscribe", ({ enumerable: true, get: function () { - return _execute.subscribe; + return _subscribe.subscribe; } })); var _Path = __webpack_require__(/*! ../jsutils/Path.mjs */ "../../../node_modules/graphql/jsutils/Path.mjs"); var _execute = __webpack_require__(/*! ./execute.mjs */ "../../../node_modules/graphql/execution/execute.mjs"); +var _subscribe = __webpack_require__(/*! ./subscribe.mjs */ "../../../node_modules/graphql/execution/subscribe.mjs"); var _values = __webpack_require__(/*! ./values.mjs */ "../../../node_modules/graphql/execution/values.mjs"); /***/ }), -/***/ "../../../node_modules/graphql/execution/mapAsyncIterable.mjs": +/***/ "../../../node_modules/graphql/execution/mapAsyncIterator.mjs": /*!********************************************************************!*\ - !*** ../../../node_modules/graphql/execution/mapAsyncIterable.mjs ***! + !*** ../../../node_modules/graphql/execution/mapAsyncIterator.mjs ***! \********************************************************************/ /***/ (function(__unused_webpack_module, exports) { @@ -25400,12 +24210,12 @@ var _values = __webpack_require__(/*! ./values.mjs */ "../../../node_modules/gra Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.mapAsyncIterable = mapAsyncIterable; +exports.mapAsyncIterator = mapAsyncIterator; /** * Given an AsyncIterable and a callback function, return an AsyncIterator * which produces values mapped via calling the callback function. */ -function mapAsyncIterable(iterable, callback) { +function mapAsyncIterator(iterable, callback) { const iterator = iterable[Symbol.asyncIterator](); async function mapResult(result) { if (result.done) { @@ -25455,49 +24265,201 @@ function mapAsyncIterable(iterable, callback) { /***/ }), -/***/ "../../../node_modules/graphql/execution/types.mjs": -/*!*********************************************************!*\ - !*** ../../../node_modules/graphql/execution/types.mjs ***! - \*********************************************************/ -/***/ (function(__unused_webpack_module, exports) { +/***/ "../../../node_modules/graphql/execution/subscribe.mjs": +/*!*************************************************************!*\ + !*** ../../../node_modules/graphql/execution/subscribe.mjs ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DeferredFragmentRecord = void 0; -exports.isCancellableStreamRecord = isCancellableStreamRecord; -exports.isCompletedExecutionGroup = isCompletedExecutionGroup; -exports.isDeferredFragmentRecord = isDeferredFragmentRecord; -exports.isFailedExecutionGroup = isFailedExecutionGroup; -exports.isPendingExecutionGroup = isPendingExecutionGroup; -function isPendingExecutionGroup(incrementalDataRecord) { - return 'deferredFragmentRecords' in incrementalDataRecord; +exports.createSourceEventStream = createSourceEventStream; +exports.subscribe = subscribe; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); +var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); +var _isAsyncIterable = __webpack_require__(/*! ../jsutils/isAsyncIterable.mjs */ "../../../node_modules/graphql/jsutils/isAsyncIterable.mjs"); +var _Path = __webpack_require__(/*! ../jsutils/Path.mjs */ "../../../node_modules/graphql/jsutils/Path.mjs"); +var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); +var _locatedError = __webpack_require__(/*! ../error/locatedError.mjs */ "../../../node_modules/graphql/error/locatedError.mjs"); +var _collectFields = __webpack_require__(/*! ./collectFields.mjs */ "../../../node_modules/graphql/execution/collectFields.mjs"); +var _execute = __webpack_require__(/*! ./execute.mjs */ "../../../node_modules/graphql/execution/execute.mjs"); +var _mapAsyncIterator = __webpack_require__(/*! ./mapAsyncIterator.mjs */ "../../../node_modules/graphql/execution/mapAsyncIterator.mjs"); +var _values = __webpack_require__(/*! ./values.mjs */ "../../../node_modules/graphql/execution/values.mjs"); +/** + * 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 isCompletedExecutionGroup(subsequentResult) { - return 'pendingExecutionGroup' in subsequentResult; +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] + }; } -function isFailedExecutionGroup(completedExecutionGroup) { - return completedExecutionGroup.errors !== undefined; -} -/** @internal */ -class DeferredFragmentRecord { - constructor(path, label, parent) { - this.path = path; - this.label = label; - this.parent = parent; - this.pendingExecutionGroups = new Set(); - this.successfulExecutionGroups = new Set(); - this.children = new Set(); +/** + * 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; } } -exports.DeferredFragmentRecord = DeferredFragmentRecord; -function isDeferredFragmentRecord(deliveryGroup) { - return deliveryGroup instanceof DeferredFragmentRecord; -} -function isCancellableStreamRecord(deliveryGroup) { - return 'earlyReturn' in deliveryGroup; +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)); + } } /***/ }), @@ -25517,6 +24479,7 @@ exports.getArgumentValues = getArgumentValues; exports.getDirectiveValues = getDirectiveValues; exports.getVariableValues = getVariableValues; var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); +var _keyMap = __webpack_require__(/*! ../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _printPathArray = __webpack_require__(/*! ../jsutils/printPathArray.mjs */ "../../../node_modules/graphql/jsutils/printPathArray.mjs"); var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); @@ -25570,7 +24533,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) { })); continue; } - if (!Object.hasOwn(inputs, varName)) { + if (!hasOwnProperty(inputs, varName)) { if (varDefNode.defaultValue) { coercedValues[varName] = (0, _valueFromAST.valueFromAST)(varDefNode.defaultValue, varType); } else if ((0, _definition.isNonNullType)(varType)) { @@ -25610,18 +24573,20 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) { * 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 + 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 = new Map(argumentNodes.map(arg => [arg.name.value, arg])); + 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.get(name); - if (argumentNode == null) { + const argumentNode = argNodeMap[name]; + if (!argumentNode) { if (argDef.defaultValue !== undefined) { coercedValues[name] = argDef.defaultValue; } else if ((0, _definition.isNonNullType)(argType)) { @@ -25635,7 +24600,7 @@ function getArgumentValues(def, node, variableValues) { let isNull = valueNode.kind === _kinds.Kind.NULL; if (valueNode.kind === _kinds.Kind.VARIABLE) { const variableName = valueNode.name.value; - if (variableValues == null || !Object.hasOwn(variableValues, variableName)) { + if (variableValues == null || !hasOwnProperty(variableValues, variableName)) { if (argDef.defaultValue !== undefined) { coercedValues[name] = argDef.defaultValue; } else if ((0, _definition.isNonNullType)(argType)) { @@ -25676,6 +24641,7 @@ function getArgumentValues(def, node, variableValues) { * 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); @@ -25683,6 +24649,9 @@ function getDirectiveValues(directiveDef, node, variableValues) { return getArgumentValues(directiveDef, directiveNode, variableValues); } } +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} /***/ }), @@ -25699,11 +24668,52 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.graphql = graphql; exports.graphqlSync = graphqlSync; +var _devAssert = __webpack_require__(/*! ./jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _isPromise = __webpack_require__(/*! ./jsutils/isPromise.mjs */ "../../../node_modules/graphql/jsutils/isPromise.mjs"); var _parser = __webpack_require__(/*! ./language/parser.mjs */ "../../../node_modules/graphql/language/parser.mjs"); var _validate = __webpack_require__(/*! ./type/validate.mjs */ "../../../node_modules/graphql/type/validate.mjs"); var _validate2 = __webpack_require__(/*! ./validation/validate.mjs */ "../../../node_modules/graphql/validation/validate.mjs"); var _execute = __webpack_require__(/*! ./execution/execute.mjs */ "../../../node_modules/graphql/execution/execute.mjs"); +/** + * This is the primary entry point function for fulfilling GraphQL operations + * by parsing, validating, and executing a GraphQL document along side a + * GraphQL schema. + * + * More sophisticated GraphQL servers, such as those which persist queries, + * may wish to separate the validation and execution phases to a static time + * tooling step, and a server runtime step. + * + * Accepts either an object with named arguments, or individual arguments: + * + * schema: + * The GraphQL type system to use when validating and executing a query. + * source: + * A GraphQL language formatted string representing the requested operation. + * rootValue: + * The value provided as the first argument to resolver functions on the top + * level type (e.g. the query object type). + * contextValue: + * The context value is provided as an argument to resolver functions after + * field arguments. It is used to pass shared information useful at any point + * during executing this query, for example the currently logged in user and + * connections to databases or other services. + * variableValues: + * A mapping of variable name to runtime value to use for all variables + * defined in the requestString. + * operationName: + * The name of the operation to use if requestString contains multiple + * possible operations. Can be omitted if requestString contains only + * one operation. + * fieldResolver: + * A resolver function to use when one is not provided by the schema. + * If not provided, the default field resolver is used (which looks for a + * value or method on the source value with the field's name). + * typeResolver: + * A type resolver function to use when none is provided by the schema. + * If not provided, the default type resolver is used (which looks for a + * `__typename` field or alternatively calls the `isTypeOf` method). + */ + function graphql(args) { // Always return a Promise for a consistent API. return new Promise(resolve => resolve(graphqlImpl(args))); @@ -25714,15 +24724,18 @@ function graphql(args) { * 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. + 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, @@ -25732,15 +24745,15 @@ function graphqlImpl(args) { operationName, fieldResolver, typeResolver - } = args; - // Validate Schema + } = args; // Validate Schema + const schemaValidationErrors = (0, _validate.validateSchema)(schema); if (schemaValidationErrors.length > 0) { return { errors: schemaValidationErrors }; - } - // Parse + } // Parse + let document; try { document = (0, _parser.parse)(source); @@ -25748,15 +24761,15 @@ function graphqlImpl(args) { return { errors: [syntaxError] }; - } - // Validate + } // Validate + const validationErrors = (0, _validate2.validate)(schema, document); if (validationErrors.length > 0) { return { errors: validationErrors }; - } - // Execute + } // Execute + return (0, _execute.execute)({ schema, document, @@ -25848,12 +24861,6 @@ Object.defineProperty(exports, "GraphQLBoolean", ({ return _index.GraphQLBoolean; } })); -Object.defineProperty(exports, "GraphQLDeferDirective", ({ - enumerable: true, - get: function () { - return _index.GraphQLDeferDirective; - } -})); Object.defineProperty(exports, "GraphQLDeprecatedDirective", ({ enumerable: true, get: function () { @@ -25962,12 +24969,6 @@ Object.defineProperty(exports, "GraphQLSpecifiedByDirective", ({ return _index.GraphQLSpecifiedByDirective; } })); -Object.defineProperty(exports, "GraphQLStreamDirective", ({ - enumerable: true, - get: function () { - return _index.GraphQLStreamDirective; - } -})); Object.defineProperty(exports, "GraphQLString", ({ enumerable: true, get: function () { @@ -26430,6 +25431,12 @@ Object.defineProperty(exports, "assertUnionType", ({ return _index.assertUnionType; } })); +Object.defineProperty(exports, "assertValidName", ({ + enumerable: true, + get: function () { + return _index6.assertValidName; + } +})); Object.defineProperty(exports, "assertValidSchema", ({ enumerable: true, get: function () { @@ -26514,12 +25521,6 @@ Object.defineProperty(exports, "executeSync", ({ return _index3.executeSync; } })); -Object.defineProperty(exports, "experimentalExecuteIncrementally", ({ - enumerable: true, - get: function () { - return _index3.experimentalExecuteIncrementally; - } -})); Object.defineProperty(exports, "extendSchema", ({ enumerable: true, get: function () { @@ -26538,6 +25539,12 @@ Object.defineProperty(exports, "findDangerousChanges", ({ return _index6.findDangerousChanges; } })); +Object.defineProperty(exports, "formatError", ({ + enumerable: true, + get: function () { + return _index5.formatError; + } +})); Object.defineProperty(exports, "getArgumentValues", ({ enumerable: true, get: function () { @@ -26586,12 +25593,24 @@ Object.defineProperty(exports, "getOperationAST", ({ 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 () { @@ -26712,12 +25731,6 @@ Object.defineProperty(exports, "isNonNullType", ({ return _index.isNonNullType; } })); -Object.defineProperty(exports, "isNullabilityAssertionNode", ({ - enumerable: true, - get: function () { - return _index2.isNullabilityAssertionNode; - } -})); Object.defineProperty(exports, "isNullableType", ({ enumerable: true, get: function () { @@ -26826,6 +25839,12 @@ Object.defineProperty(exports, "isUnionType", ({ return _index.isUnionType; } })); +Object.defineProperty(exports, "isValidNameError", ({ + enumerable: true, + get: function () { + return _index6.isValidNameError; + } +})); Object.defineProperty(exports, "isValueNode", ({ enumerable: true, get: function () { @@ -26880,10 +25899,10 @@ Object.defineProperty(exports, "print", ({ return _index2.print; } })); -Object.defineProperty(exports, "printDirective", ({ +Object.defineProperty(exports, "printError", ({ enumerable: true, get: function () { - return _index6.printDirective; + return _index5.printError; } })); Object.defineProperty(exports, "printIntrospectionSchema", ({ @@ -27053,76 +26072,6 @@ var _index6 = __webpack_require__(/*! ./utilities/index.mjs */ "../../../node_mo /***/ }), -/***/ "../../../node_modules/graphql/jsutils/AccumulatorMap.mjs": -/*!****************************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/AccumulatorMap.mjs ***! - \****************************************************************/ -/***/ (function(__unused_webpack_module, exports) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.AccumulatorMap = void 0; -/** - * ES6 Map with additional `add` method to accumulate items. - */ -class AccumulatorMap extends Map { - get [Symbol.toStringTag]() { - return 'AccumulatorMap'; - } - add(key, item) { - const group = this.get(key); - if (group === undefined) { - this.set(key, [item]); - } else { - group.push(item); - } - } -} -exports.AccumulatorMap = AccumulatorMap; - -/***/ }), - -/***/ "../../../node_modules/graphql/jsutils/BoxedPromiseOrValue.mjs": -/*!*********************************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/BoxedPromiseOrValue.mjs ***! - \*********************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.BoxedPromiseOrValue = void 0; -var _isPromise = __webpack_require__(/*! ./isPromise.mjs */ "../../../node_modules/graphql/jsutils/isPromise.mjs"); -/** - * A BoxedPromiseOrValue is a container for a value or promise where the value - * will be updated when the promise resolves. - * - * A BoxedPromiseOrValue may only be used with promises whose possible - * rejection has already been handled, otherwise this will lead to unhandled - * promise rejections. - * - * @internal - * */ -class BoxedPromiseOrValue { - constructor(value) { - this.value = value; - if ((0, _isPromise.isPromise)(value)) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - value.then(resolved => { - this.value = resolved; - }); - } - } -} -exports.BoxedPromiseOrValue = BoxedPromiseOrValue; - -/***/ }), - /***/ "../../../node_modules/graphql/jsutils/Path.mjs": /*!******************************************************!*\ !*** ../../../node_modules/graphql/jsutils/Path.mjs ***! @@ -27149,6 +26098,7 @@ function addPath(prev, key, typename) { /** * Given a Path, return an Array of the path keys. */ + function pathToArray(path) { const flattened = []; let curr = path; @@ -27161,27 +26111,6 @@ function pathToArray(path) { /***/ }), -/***/ "../../../node_modules/graphql/jsutils/capitalize.mjs": -/*!************************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/capitalize.mjs ***! - \************************************************************/ -/***/ (function(__unused_webpack_module, exports) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.capitalize = capitalize; -/** - * Converts the first character of string to upper case and the remaining to lower case. - */ -function capitalize(str) { - return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); -} - -/***/ }), - /***/ "../../../node_modules/graphql/jsutils/devAssert.mjs": /*!***********************************************************!*\ !*** ../../../node_modules/graphql/jsutils/devAssert.mjs ***! @@ -27195,7 +26124,8 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.devAssert = devAssert; function devAssert(condition, message) { - if (!condition) { + const booleanCondition = Boolean(condition); + if (!booleanCondition) { throw new Error(message); } } @@ -27206,7 +26136,7 @@ function devAssert(condition, message) { /*!************************************************************!*\ !*** ../../../node_modules/graphql/jsutils/didYouMean.mjs ***! \************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ (function(__unused_webpack_module, exports) { @@ -27214,84 +26144,29 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.didYouMean = didYouMean; -var _formatList = __webpack_require__(/*! ./formatList.mjs */ "../../../node_modules/graphql/jsutils/formatList.mjs"); const MAX_SUGGESTIONS = 5; +/** + * Given [ A, B, C ] return ' Did you mean A, B, or C?'. + */ + function didYouMean(firstArg, secondArg) { - const [subMessage, suggestions] = secondArg ? [firstArg, secondArg] : [undefined, firstArg]; - if (suggestions.length === 0) { - return ''; - } + const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [undefined, firstArg]; let message = ' Did you mean '; - if (subMessage != null) { + if (subMessage) { message += subMessage + ' '; } - const suggestionList = (0, _formatList.orList)(suggestions.slice(0, MAX_SUGGESTIONS).map(x => `"${x}"`)); - return message + suggestionList + '?'; -} - -/***/ }), - -/***/ "../../../node_modules/graphql/jsutils/formatList.mjs": -/*!************************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/formatList.mjs ***! - \************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.andList = andList; -exports.orList = orList; -var _invariant = __webpack_require__(/*! ./invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); -/** - * Given [ A, B, C ] return 'A, B, or C'. - */ -function orList(items) { - return formatList('or', items); -} -/** - * Given [ A, B, C ] return 'A, B, and C'. - */ -function andList(items) { - return formatList('and', items); -} -function formatList(conjunction, items) { - items.length !== 0 || (0, _invariant.invariant)(false); - switch (items.length) { + const suggestions = suggestionsArg.map(x => `"${x}"`); + switch (suggestions.length) { + case 0: + return ''; case 1: - return items[0]; + return message + suggestions[0] + '?'; case 2: - return items[0] + ' ' + conjunction + ' ' + items[1]; + return message + suggestions[0] + ' or ' + suggestions[1] + '?'; } - const allButLast = items.slice(0, -1); - const lastItem = items.at(-1); - return allButLast.join(', ') + ', ' + conjunction + ' ' + lastItem; -} - -/***/ }), - -/***/ "../../../node_modules/graphql/jsutils/getBySet.mjs": -/*!**********************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/getBySet.mjs ***! - \**********************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.getBySet = getBySet; -var _isSameSet = __webpack_require__(/*! ./isSameSet.mjs */ "../../../node_modules/graphql/jsutils/isSameSet.mjs"); -function getBySet(map, setToMatch) { - for (const set of map.keys()) { - if ((0, _isSameSet.isSameSet)(set, setToMatch)) { - return map.get(set); - } - } - return undefined; + const selected = suggestions.slice(0, MAX_SUGGESTIONS); + const lastItem = selected.pop(); + return message + selected.join(', ') + ', or ' + lastItem + '?'; } /***/ }), @@ -27300,7 +26175,7 @@ function getBySet(map, setToMatch) { /*!*********************************************************!*\ !*** ../../../node_modules/graphql/jsutils/groupBy.mjs ***! \*********************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ (function(__unused_webpack_module, exports) { @@ -27308,14 +26183,19 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.groupBy = groupBy; -var _AccumulatorMap = __webpack_require__(/*! ./AccumulatorMap.mjs */ "../../../node_modules/graphql/jsutils/AccumulatorMap.mjs"); /** * Groups array items into a Map, given a function to produce grouping key. */ function groupBy(list, keyFn) { - const result = new _AccumulatorMap.AccumulatorMap(); + const result = new Map(); for (const item of list) { - result.add(keyFn(item), item); + const key = keyFn(item); + const group = result.get(key); + if (group === undefined) { + result.set(key, [item]); + } else { + group.push(item); + } } return result; } @@ -27360,6 +26240,7 @@ const MAX_RECURSIVE_DEPTH = 2; /** * Used to print values in error messages. */ + function inspect(value) { return formatValue(value, []); } @@ -27384,8 +26265,8 @@ function formatObjectValue(value, previouslySeenValues) { } const seenValues = [...previouslySeenValues, value]; if (isJSONable(value)) { - const jsonValue = value.toJSON(); - // check for infinite recursion + const jsonValue = value.toJSON(); // check for infinite recursion + if (jsonValue !== value) { return typeof jsonValue === 'string' ? jsonValue : formatValue(jsonValue, seenValues); } @@ -27454,15 +26335,21 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.instanceOf = void 0; var _inspect = __webpack_require__(/*! ./inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); +/* c8 ignore next 3 */ + +const isProduction = globalThis.process && +// eslint-disable-next-line no-undef +"development" === 'production'; /** * 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 = exports.instanceOf = /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 -globalThis.process != null && globalThis.process.env.NODE_ENV === 'production' ? function instanceOf(value, constructor) { +isProduction ? function instanceOf(value, constructor) { return value instanceof constructor; } : function instanceOf(value, constructor) { if (value instanceof constructor) { @@ -27470,11 +26357,13 @@ globalThis.process != null && globalThis.process.env.NODE_ENV === 'production' ? } 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 ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name; + 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. @@ -27509,7 +26398,8 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.invariant = invariant; function invariant(condition, message) { - if (!condition) { + const booleanCondition = Boolean(condition); + if (!booleanCondition) { throw new Error(message != null ? message : 'Unexpected invariant triggered.'); } } @@ -27617,32 +26507,6 @@ function isPromise(value) { /***/ }), -/***/ "../../../node_modules/graphql/jsutils/isSameSet.mjs": -/*!***********************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/isSameSet.mjs ***! - \***********************************************************/ -/***/ (function(__unused_webpack_module, exports) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.isSameSet = isSameSet; -function isSameSet(setA, setB) { - if (setA.size !== setB.size) { - return false; - } - for (const item of setA) { - if (!setB.has(item)) { - return false; - } - } - return true; -} - -/***/ }), - /***/ "../../../node_modules/graphql/jsutils/keyMap.mjs": /*!********************************************************!*\ !*** ../../../node_modules/graphql/jsutils/keyMap.mjs ***! @@ -27904,15 +26768,14 @@ exports.promiseForObject = promiseForObject; * This is akin to bluebird's `Promise.props`, but implemented only using * `Promise.all` so it will work with any implementation of ES6 promises. */ -async function promiseForObject(object, callback) { - const keys = Object.keys(object); - const values = Object.values(object); - const resolvedValues = await Promise.all(values); - const resolvedObject = Object.create(null); - for (let i = 0; i < keys.length; ++i) { - resolvedObject[keys[i]] = resolvedValues[i]; - } - return callback(resolvedObject); +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; + }); } /***/ }), @@ -27947,39 +26810,6 @@ function promiseReduce(values, callbackFn, initialValue) { /***/ }), -/***/ "../../../node_modules/graphql/jsutils/promiseWithResolvers.mjs": -/*!**********************************************************************!*\ - !*** ../../../node_modules/graphql/jsutils/promiseWithResolvers.mjs ***! - \**********************************************************************/ -/***/ (function(__unused_webpack_module, exports) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.promiseWithResolvers = promiseWithResolvers; -/** - * Based on Promise.withResolvers proposal - * https://github.com/tc39/proposal-promise-with-resolvers - */ -function promiseWithResolvers() { - // these are assigned synchronously within the Promise constructor - let resolve; - let reject; - const promise = new Promise((res, rej) => { - resolve = res; - reject = rej; - }); - return { - promise, - resolve, - reject - }; -} - -/***/ }), - /***/ "../../../node_modules/graphql/jsutils/suggestionList.mjs": /*!****************************************************************!*\ !*** ../../../node_modules/graphql/jsutils/suggestionList.mjs ***! @@ -27997,6 +26827,7 @@ var _naturalCompare = __webpack_require__(/*! ./naturalCompare.mjs */ "../../../ * 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); @@ -28026,6 +26857,7 @@ function suggestionList(input, options) { * * This distance can be useful for detecting typos in input or sorting */ + class LexicalDistance { constructor(input) { this._input = input; @@ -28037,8 +26869,8 @@ class LexicalDistance { if (this._input === option) { return 0; } - const optionLowerCase = option.toLowerCase(); - // Any case change counts as a single edit + const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit + if (this._inputLowerCase === optionLowerCase) { return 1; } @@ -28068,7 +26900,8 @@ class LexicalDistance { // delete currentRow[j - 1] + 1, // insert - upRow[j - 1] + cost); + 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]; @@ -28078,8 +26911,8 @@ class LexicalDistance { smallestCell = currentCell; } currentRow[j] = currentCell; - } - // Early exit, since distance can't go smaller than smallest element of the previous row. + } // Early exit, since distance can't go smaller than smallest element of the previous row. + if (smallestCell > threshold) { return undefined; } @@ -28115,6 +26948,7 @@ var _inspect = __webpack_require__(/*! ./inspect.mjs */ "../../../node_modules/g /** * 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); } @@ -28174,6 +27008,25 @@ exports.isNode = isNode; * 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; @@ -28197,14 +27050,45 @@ class Location { */ exports.Location = Location; class Token { - // eslint-disable-next-line max-params + /** + * 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.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.value = value; this.prev = null; this.next = null; @@ -28221,6 +27105,10 @@ class Token { }; } } +/** + * The list of all possible AST node types. + */ + /** * @internal */ @@ -28232,16 +27120,8 @@ const QueryDocumentKeys = exports.QueryDocumentKeys = { VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], Variable: ['name'], SelectionSet: ['selections'], - Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet', - // Note: Client Controlled Nullability is experimental and may be changed - // or removed in the future. - 'nullabilityAssertion'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], Argument: ['name', 'value'], - // Note: Client Controlled Nullability is experimental and may be changed - // or removed in the future. - ListNullabilityOperator: ['nullabilityAssertion'], - NonNullAssertion: ['nullabilityAssertion'], - ErrorBoundary: ['nullabilityAssertion'], FragmentSpread: ['name', 'directives'], InlineFragment: ['typeCondition', 'directives', 'selectionSet'], FragmentDefinition: ['name', @@ -28284,10 +27164,13 @@ 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; (function (OperationTypeNode) { OperationTypeNode['QUERY'] = 'query'; @@ -28320,28 +27203,28 @@ var _characterClasses = __webpack_require__(/*! ./characterClasses.mjs */ "../.. * * @internal */ + function dedentBlockStringLines(lines) { - var _firstNonEmptyLine; + 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 ??= i; + 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((_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : 0, lastNonEmptyLine + 1); + 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; @@ -28353,6 +27236,7 @@ function leadingWhitespace(str) { /** * @internal */ + function isPrintableAsBlockString(value) { if (value === '') { return true; // empty string is printable @@ -28378,10 +27262,12 @@ function isPrintableAsBlockString(value) { 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) { @@ -28392,12 +27278,13 @@ function isPrintableAsBlockString(value) { hasIndent = false; break; case 9: // \t + case 32: // - hasIndent ||= isEmptyLine; + hasIndent || (hasIndent = isEmptyLine); break; default: - hasCommonIndent &&= hasIndent; + hasCommonIndent && (hasCommonIndent = hasIndent); isEmptyLine = false; } } @@ -28416,24 +27303,25 @@ function isPrintableAsBlockString(value) { * * @internal */ + function printBlockString(value, options) { - const escapedValue = value.replaceAll('"""', '\\"""'); - // Expand a block string's raw value into independent lines. + 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 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. + 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'; @@ -28481,6 +27369,7 @@ function isWhiteSpace(code) { * ``` * @internal */ + function isDigit(code) { return code >= 0x0030 && code <= 0x0039; } @@ -28494,6 +27383,7 @@ function isDigit(code) { * ``` * @internal */ + function isLetter(code) { return code >= 0x0061 && code <= 0x007a || // A-Z @@ -28508,6 +27398,7 @@ function isLetter(code) { * ``` * @internal */ + function isNameStart(code) { return isLetter(code) || code === 0x005f; } @@ -28520,6 +27411,7 @@ function isNameStart(code) { * ``` * @internal */ + function isNameContinue(code) { return isLetter(code) || isDigit(code) || code === 0x005f; } @@ -28543,7 +27435,6 @@ exports.DirectiveLocation = void 0; */ var DirectiveLocation; (function (DirectiveLocation) { - /** Request Definitions */ DirectiveLocation['QUERY'] = 'QUERY'; DirectiveLocation['MUTATION'] = 'MUTATION'; DirectiveLocation['SUBSCRIPTION'] = 'SUBSCRIPTION'; @@ -28552,7 +27443,6 @@ var DirectiveLocation; DirectiveLocation['FRAGMENT_SPREAD'] = 'FRAGMENT_SPREAD'; DirectiveLocation['INLINE_FRAGMENT'] = 'INLINE_FRAGMENT'; DirectiveLocation['VARIABLE_DEFINITION'] = 'VARIABLE_DEFINITION'; - /** Type System Definitions */ DirectiveLocation['SCHEMA'] = 'SCHEMA'; DirectiveLocation['SCALAR'] = 'SCALAR'; DirectiveLocation['OBJECT'] = 'OBJECT'; @@ -28566,6 +27456,12 @@ var DirectiveLocation; 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. + */ + /***/ }), /***/ "../../../node_modules/graphql/language/index.mjs": @@ -28645,6 +27541,12 @@ Object.defineProperty(exports, "getLocation", ({ return _location.getLocation; } })); +Object.defineProperty(exports, "getVisitFn", ({ + enumerable: true, + get: function () { + return _visitor.getVisitFn; + } +})); Object.defineProperty(exports, "isConstValueNode", ({ enumerable: true, get: function () { @@ -28663,12 +27565,6 @@ Object.defineProperty(exports, "isExecutableDefinitionNode", ({ return _predicates.isExecutableDefinitionNode; } })); -Object.defineProperty(exports, "isNullabilityAssertionNode", ({ - enumerable: true, - get: function () { - return _predicates.isNullabilityAssertionNode; - } -})); Object.defineProperty(exports, "isSelectionNode", ({ enumerable: true, get: function () { @@ -28797,24 +27693,16 @@ exports.Kind = void 0; */ var Kind; (function (Kind) { - /** Name */ Kind['NAME'] = 'Name'; - /** Document */ Kind['DOCUMENT'] = 'Document'; Kind['OPERATION_DEFINITION'] = 'OperationDefinition'; Kind['VARIABLE_DEFINITION'] = 'VariableDefinition'; Kind['SELECTION_SET'] = 'SelectionSet'; Kind['FIELD'] = 'Field'; Kind['ARGUMENT'] = 'Argument'; - /** Nullability Modifiers */ - Kind['LIST_NULLABILITY_OPERATOR'] = 'ListNullabilityOperator'; - Kind['NON_NULL_ASSERTION'] = 'NonNullAssertion'; - Kind['ERROR_BOUNDARY'] = 'ErrorBoundary'; - /** Fragments */ Kind['FRAGMENT_SPREAD'] = 'FragmentSpread'; Kind['INLINE_FRAGMENT'] = 'InlineFragment'; Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition'; - /** Values */ Kind['VARIABLE'] = 'Variable'; Kind['INT'] = 'IntValue'; Kind['FLOAT'] = 'FloatValue'; @@ -28825,16 +27713,12 @@ var Kind; Kind['LIST'] = 'ListValue'; Kind['OBJECT'] = 'ObjectValue'; Kind['OBJECT_FIELD'] = 'ObjectField'; - /** Directives */ Kind['DIRECTIVE'] = 'Directive'; - /** Types */ Kind['NAMED_TYPE'] = 'NamedType'; Kind['LIST_TYPE'] = 'ListType'; Kind['NON_NULL_TYPE'] = 'NonNullType'; - /** Type System Definitions */ Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition'; Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition'; - /** Type Definitions */ Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition'; Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition'; Kind['FIELD_DEFINITION'] = 'FieldDefinition'; @@ -28844,11 +27728,8 @@ var Kind; Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition'; Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition'; Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition'; - /** Directive Definitions */ Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition'; - /** Type System Extensions */ Kind['SCHEMA_EXTENSION'] = 'SchemaExtension'; - /** Type Extensions */ Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension'; Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension'; Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension'; @@ -28857,6 +27738,12 @@ var Kind; 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. + */ + /***/ }), /***/ "../../../node_modules/graphql/language/lexer.mjs": @@ -28885,7 +27772,23 @@ var _tokenKind = __webpack_require__(/*! ./tokenKind.mjs */ "../../../node_modul * 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; @@ -28900,6 +27803,7 @@ class Lexer { /** * Advances the token stream to the next non-ignored token. */ + advance() { this.lastToken = this.token; const token = this.token = this.lookahead(); @@ -28909,6 +27813,7 @@ class Lexer { * 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) { @@ -28917,10 +27822,10 @@ class Lexer { 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. + 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; } @@ -28934,7 +27839,7 @@ class Lexer { */ exports.Lexer = Lexer; function isPunctuatorTokenKind(kind) { - return kind === _tokenKind.TokenKind.BANG || kind === _tokenKind.TokenKind.QUESTION_MARK || 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; + 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 @@ -28944,6 +27849,7 @@ function isPunctuatorTokenKind(kind) { * SourceCharacter :: * - "Any Unicode scalar value" */ + function isUnicodeScalarValue(code) { return code >= 0x0000 && code <= 0xd7ff || code >= 0xe000 && code <= 0x10ffff; } @@ -28955,6 +27861,7 @@ function isUnicodeScalarValue(code) { * 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)); } @@ -28971,6 +27878,7 @@ function isTrailingSurrogate(code) { * 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) { @@ -28979,13 +27887,14 @@ function printCodePointAt(lexer, location) { // Printable ASCII const char = String.fromCodePoint(code); return char === '"' ? "'\"'" : `"${char}"`; - } - // Unicode code point + } // 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; @@ -28998,13 +27907,14 @@ function createToken(lexer, kind, start, end, value) { * 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 + const code = body.charCodeAt(position); // SourceCharacter + switch (code) { // Ignored :: // - UnicodeBOM @@ -29021,8 +27931,11 @@ function readNextToken(lexer, start) { // // Comma :: , case 0xfeff: // + case 0x0009: // \t + case 0x0020: // + case 0x002c: // , ++position; @@ -29031,6 +27944,7 @@ function readNextToken(lexer, start) { // - "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; @@ -29048,6 +27962,7 @@ function readNextToken(lexer, start) { lexer.lineStart = position; continue; // Comment + case 0x0023: // # return readComment(lexer, position); @@ -29059,6 +27974,7 @@ function readNextToken(lexer, start) { // - StringValue // // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } + case 0x0021: // ! return createToken(lexer, _tokenKind.TokenKind.BANG, position, position + 1); @@ -29104,22 +28020,20 @@ function readNextToken(lexer, start) { case 0x007d: // } return createToken(lexer, _tokenKind.TokenKind.BRACE_R, position, position + 1); - case 0x003f: - // ? - return createToken(lexer, _tokenKind.TokenKind.QUESTION_MARK, 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 | -) + } // IntValue | FloatValue (Digit | -) + if ((0, _characterClasses.isDigit)(code) || code === 0x002d) { return readNumber(lexer, position, code); - } - // Name + } // Name + if ((0, _characterClasses.isNameStart)(code)) { return readName(lexer, position); } @@ -29136,17 +28050,18 @@ function readNextToken(lexer, start) { * 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) + const code = body.charCodeAt(position); // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { break; - } - // SourceCharacter + } // SourceCharacter + if (isUnicodeScalarValue(code)) { ++position; } else if (isSupplementaryCodePoint(body, position)) { @@ -29186,16 +28101,17 @@ function readComment(lexer, start) { * Sign :: one of + - * ``` */ + function readNumber(lexer, start, firstCode) { const body = lexer.source.body; let position = start; let code = firstCode; - let isFloat = false; - // NegativeSign (-) + let isFloat = false; // NegativeSign (-) + if (code === 0x002d) { code = body.charCodeAt(++position); - } - // Zero (0) + } // Zero (0) + if (code === 0x0030) { code = body.charCodeAt(++position); if ((0, _characterClasses.isDigit)(code)) { @@ -29204,26 +28120,26 @@ function readNumber(lexer, start, firstCode) { } else { position = readDigits(lexer, position, code); code = body.charCodeAt(position); - } - // Full stop (.) + } // Full stop (.) + if (code === 0x002e) { isFloat = true; code = body.charCodeAt(++position); position = readDigits(lexer, position, code); code = body.charCodeAt(position); - } - // E e + } // E e + if (code === 0x0045 || code === 0x0065) { isFloat = true; - code = body.charCodeAt(++position); - // + - + 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 + } // 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)}.`); } @@ -29232,12 +28148,14 @@ function readNumber(lexer, start, firstCode) { /** * 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; } @@ -29263,6 +28181,7 @@ function readDigits(lexer, start, firstCode) { * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` * ``` */ + function readString(lexer, start) { const body = lexer.source.body; const bodyLength = body.length; @@ -29270,13 +28189,13 @@ function readString(lexer, start) { let chunkStart = position; let value = ''; while (position < bodyLength) { - const code = body.charCodeAt(position); - // Closing Quote (") + 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 (\) + } // Escape Sequence (\) + if (code === 0x005c) { value += body.slice(chunkStart, position); const escape = body.charCodeAt(position + 1) === 0x0075 // u @@ -29286,12 +28205,12 @@ function readString(lexer, start) { position += escape.size; chunkStart = position; continue; - } - // LineTerminator (\n | \r) + } // LineTerminator (\n | \r) + if (code === 0x000a || code === 0x000d) { break; - } - // SourceCharacter + } // SourceCharacter + if (isUnicodeScalarValue(code)) { ++position; } else if (isSupplementaryCodePoint(body, position)) { @@ -29301,15 +28220,16 @@ function readString(lexer, start) { } } 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}). + let size = 3; // Cannot be larger than 12 chars (\u{00000000}). + while (size < 12) { - const code = body.charCodeAt(position + size++); - // Closing Brace (}) + 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)) { @@ -29319,8 +28239,8 @@ function readEscapedUnicodeVariableWidth(lexer, position) { value: String.fromCodePoint(point), size }; - } - // Append this hex digit to the code point. + } // Append this hex digit to the code point. + point = point << 4 | readHexDigit(code); if (point < 0) { break; @@ -29336,9 +28256,9 @@ function readEscapedUnicodeFixedWidth(lexer, position) { value: String.fromCodePoint(code), size: 6 }; - } - // GraphQL allows JSON-style surrogate pair escape sequences, but only when + } // 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) { @@ -29366,6 +28286,7 @@ function readEscapedUnicodeFixedWidth(lexer, position) { * * 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. @@ -29385,6 +28306,7 @@ function read16BitHexCode(body, position) { * - `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 @@ -29403,6 +28325,7 @@ function readHexDigit(code) { * | `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); @@ -29470,6 +28393,7 @@ function readEscapedCharacter(lexer, position) { * - `\"""` * ``` */ + function readBlockString(lexer, start) { const body = lexer.source.body; const bodyLength = body.length; @@ -29479,8 +28403,8 @@ function readBlockString(lexer, start) { let currentLine = ''; const blockLines = []; while (position < bodyLength) { - const code = body.charCodeAt(position); - // Closing Triple-Quote (""") + 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); @@ -29490,15 +28414,16 @@ function readBlockString(lexer, start) { lexer.line += blockLines.length - 1; lexer.lineStart = lineStart; return token; - } - // Escaped Triple-Quote (\""") + } // 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 + } // LineTerminator + if (code === 0x000a || code === 0x000d) { currentLine += body.slice(chunkStart, position); blockLines.push(currentLine); @@ -29511,8 +28436,8 @@ function readBlockString(lexer, start) { chunkStart = position; lineStart = position; continue; - } - // SourceCharacter + } // SourceCharacter + if (isUnicodeScalarValue(code)) { ++position; } else if (isSupplementaryCodePoint(body, position)) { @@ -29531,6 +28456,7 @@ function readBlockString(lexer, start) { * - NameStart NameContinue* [lookahead != NameContinue] * ``` */ + function readName(lexer, start) { const body = lexer.source.body; const bodyLength = body.length; @@ -29562,6 +28488,10 @@ Object.defineProperty(exports, "__esModule", ({ exports.getLocation = getLocation; var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); 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. @@ -29608,6 +28538,10 @@ var _kinds = __webpack_require__(/*! ./kinds.mjs */ "../../../node_modules/graph var _lexer = __webpack_require__(/*! ./lexer.mjs */ "../../../node_modules/graphql/language/lexer.mjs"); var _source = __webpack_require__(/*! ./source.mjs */ "../../../node_modules/graphql/language/source.mjs"); var _tokenKind = __webpack_require__(/*! ./tokenKind.mjs */ "../../../node_modules/graphql/language/tokenKind.mjs"); +/** + * Configuration options to control parser behavior + */ + /** * Given a GraphQL source, parses it into a Document. * Throws GraphQLError if a syntax error is encountered. @@ -29626,6 +28560,7 @@ function parse(source, options) { * * Consider providing the results to the utility function: valueFromAST(). */ + function parseValue(source, options) { const parser = new Parser(source, options); parser.expectToken(_tokenKind.TokenKind.SOF); @@ -29637,6 +28572,7 @@ function parseValue(source, options) { * 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); @@ -29654,6 +28590,7 @@ function parseConstValue(source, options) { * * Consider providing the results to the utility function: typeFromAST(). */ + function parseType(source, options) { const parser = new Parser(source, options); parser.expectToken(_tokenKind.TokenKind.SOF); @@ -29672,6 +28609,7 @@ function parseType(source, options) { * * @internal */ + class Parser { constructor(source, options = {}) { const sourceObj = (0, _source.isSource)(source) ? source : new _source.Source(source); @@ -29682,17 +28620,19 @@ class Parser { /** * 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. + } // Implements the parsing rules in the Document section. + /** * Document : Definition+ */ + parseDocument() { return this.node(this._lexer.token, { kind: _kinds.Kind.DOCUMENT, @@ -29722,11 +28662,12 @@ class Parser { * - EnumTypeDefinition * - InputObjectTypeDefinition */ + parseDefinition() { if (this.peek(_tokenKind.TokenKind.BRACE_L)) { return this.parseOperationDefinition(); - } - // Many definitions begin with a description and require a lookahead. + } // 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) { @@ -29763,13 +28704,14 @@ class Parser { } } throw this.unexpected(keywordToken); - } - // Implements the parsing rules in the Operations section. + } // 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)) { @@ -29799,6 +28741,7 @@ class Parser { /** * OperationType : one of query mutation subscription */ + parseOperationType() { const operationToken = this.expectToken(_tokenKind.TokenKind.NAME); switch (operationToken.value) { @@ -29814,12 +28757,14 @@ class Parser { /** * 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, @@ -29832,6 +28777,7 @@ class Parser { /** * Variable : $ Name */ + parseVariable() { const start = this._lexer.token; this.expectToken(_tokenKind.TokenKind.DOLLAR); @@ -29845,6 +28791,7 @@ class Parser { * SelectionSet : { Selection+ } * ``` */ + parseSelectionSet() { return this.node(this._lexer.token, { kind: _kinds.Kind.SELECTION_SET, @@ -29857,6 +28804,7 @@ class Parser { * - FragmentSpread * - InlineFragment */ + parseSelection() { return this.peek(_tokenKind.TokenKind.SPREAD) ? this.parseFragment() : this.parseField(); } @@ -29865,6 +28813,7 @@ class Parser { * * Alias : Name : */ + parseField() { const start = this._lexer.token; const nameOrAlias = this.parseName(); @@ -29881,47 +28830,22 @@ class Parser { alias, name, arguments: this.parseArguments(false), - // Experimental support for Client Controlled Nullability changes - // the grammar of Field: - nullabilityAssertion: this.parseNullabilityAssertion(), directives: this.parseDirectives(false), selectionSet: this.peek(_tokenKind.TokenKind.BRACE_L) ? this.parseSelectionSet() : undefined }); } - // TODO: add grammar comment after it finalizes - parseNullabilityAssertion() { - // Note: Client Controlled Nullability is experimental and may be changed or - // removed in the future. - if (this._options.experimentalClientControlledNullability !== true) { - return undefined; - } - const start = this._lexer.token; - let nullabilityAssertion; - if (this.expectOptionalToken(_tokenKind.TokenKind.BRACKET_L)) { - const innerModifier = this.parseNullabilityAssertion(); - this.expectToken(_tokenKind.TokenKind.BRACKET_R); - nullabilityAssertion = this.node(start, { - kind: _kinds.Kind.LIST_NULLABILITY_OPERATOR, - nullabilityAssertion: innerModifier - }); - } - if (this.expectOptionalToken(_tokenKind.TokenKind.BANG)) { - nullabilityAssertion = this.node(start, { - kind: _kinds.Kind.NON_NULL_ASSERTION, - nullabilityAssertion - }); - } else if (this.expectOptionalToken(_tokenKind.TokenKind.QUESTION_MARK)) { - nullabilityAssertion = this.node(start, { - kind: _kinds.Kind.ERROR_BOUNDARY, - nullabilityAssertion - }); - } - return nullabilityAssertion; - } + /** + * 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(); @@ -29934,8 +28858,8 @@ class Parser { } parseConstArgument() { return this.parseArgument(true); - } - // Implements the parsing rules in the Fragments section. + } // Implements the parsing rules in the Fragments section. + /** * Corresponds to both FragmentSpread and InlineFragment in the spec. * @@ -29943,6 +28867,7 @@ class Parser { * * InlineFragment : ... TypeCondition? Directives? SelectionSet */ + parseFragment() { const start = this._lexer.token; this.expectToken(_tokenKind.TokenKind.SPREAD); @@ -29967,12 +28892,13 @@ class Parser { * * TypeCondition : NamedType */ + parseFragmentDefinition() { const start = this._lexer.token; - this.expectKeyword('fragment'); - // Legacy support for defining variables within fragments changes + 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, @@ -29994,12 +28920,33 @@ class Parser { /** * 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) { @@ -30072,6 +29019,12 @@ class Parser { block: token.kind === _tokenKind.TokenKind.BLOCK_STRING }); } + /** + * ListValue[Const] : + * - [ ] + * - [ Value[?Const]+ ] + */ + parseList(isConst) { const item = () => this.parseValueLiteral(isConst); return this.node(this._lexer.token, { @@ -30079,6 +29032,14 @@ class Parser { 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, { @@ -30086,6 +29047,10 @@ class Parser { 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(); @@ -30095,7 +29060,12 @@ class Parser { 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)) { @@ -30106,6 +29076,12 @@ class Parser { parseConstDirectives() { return this.parseDirectives(true); } + /** + * ``` + * Directive[Const] : @ Name Arguments[?Const]? + * ``` + */ + parseDirective(isConst) { const start = this._lexer.token; this.expectToken(_tokenKind.TokenKind.AT); @@ -30114,14 +29090,15 @@ class Parser { name: this.parseName(), arguments: this.parseArguments(isConst) }); - } - // Implements the parsing rules in the Types section. + } // Implements the parsing rules in the Types section. + /** * Type : * - NamedType * - ListType * - NonNullType */ + parseTypeReference() { const start = this._lexer.token; let type; @@ -30146,19 +29123,21 @@ class Parser { /** * 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. + } // 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(); @@ -30169,6 +29148,7 @@ class Parser { * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } * ``` */ + parseSchemaDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30185,6 +29165,7 @@ class Parser { /** * OperationTypeDefinition : OperationType : NamedType */ + parseOperationTypeDefinition() { const start = this._lexer.token; const operation = this.parseOperationType(); @@ -30199,6 +29180,7 @@ class Parser { /** * ScalarTypeDefinition : Description? scalar Name Directives[Const]? */ + parseScalarTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30217,6 +29199,7 @@ class Parser { * Description? * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? */ + parseObjectTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30239,6 +29222,7 @@ class Parser { * - implements `&`? NamedType * - ImplementsInterfaces & NamedType */ + parseImplementsInterfaces() { return this.expectOptionalKeyword('implements') ? this.delimitedMany(_tokenKind.TokenKind.AMP, this.parseNamedType) : []; } @@ -30247,6 +29231,7 @@ class Parser { * FieldsDefinition : { FieldDefinition+ } * ``` */ + parseFieldsDefinition() { return this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseFieldDefinition, _tokenKind.TokenKind.BRACE_R); } @@ -30254,6 +29239,7 @@ class Parser { * FieldDefinition : * - Description? Name ArgumentsDefinition? : Type Directives[Const]? */ + parseFieldDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30274,6 +29260,7 @@ class Parser { /** * ArgumentsDefinition : ( InputValueDefinition+ ) */ + parseArgumentDefs() { return this.optionalMany(_tokenKind.TokenKind.PAREN_L, this.parseInputValueDef, _tokenKind.TokenKind.PAREN_R); } @@ -30281,6 +29268,7 @@ class Parser { * InputValueDefinition : * - Description? Name : Type DefaultValue? Directives[Const]? */ + parseInputValueDef() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30305,6 +29293,7 @@ class Parser { * InterfaceTypeDefinition : * - Description? interface Name Directives[Const]? FieldsDefinition? */ + parseInterfaceTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30326,6 +29315,7 @@ class Parser { * UnionTypeDefinition : * - Description? union Name Directives[Const]? UnionMemberTypes? */ + parseUnionTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30346,6 +29336,7 @@ class Parser { * - = `|`? NamedType * - UnionMemberTypes | NamedType */ + parseUnionMemberTypes() { return this.expectOptionalToken(_tokenKind.TokenKind.EQUALS) ? this.delimitedMany(_tokenKind.TokenKind.PIPE, this.parseNamedType) : []; } @@ -30353,6 +29344,7 @@ class Parser { * EnumTypeDefinition : * - Description? enum Name Directives[Const]? EnumValuesDefinition? */ + parseEnumTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30373,12 +29365,14 @@ class Parser { * 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(); @@ -30394,6 +29388,7 @@ class Parser { /** * 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.`); @@ -30404,6 +29399,7 @@ class Parser { * InputObjectTypeDefinition : * - Description? input Name Directives[Const]? InputFieldsDefinition? */ + parseInputObjectTypeDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30424,6 +29420,7 @@ class Parser { * InputFieldsDefinition : { InputValueDefinition+ } * ``` */ + parseInputFieldsDefinition() { return this.optionalMany(_tokenKind.TokenKind.BRACE_L, this.parseInputValueDef, _tokenKind.TokenKind.BRACE_R); } @@ -30440,6 +29437,7 @@ class Parser { * - EnumTypeExtension * - InputObjectTypeDefinition */ + parseTypeSystemExtension() { const keywordToken = this._lexer.lookahead(); if (keywordToken.kind === _tokenKind.TokenKind.NAME) { @@ -30469,6 +29467,7 @@ class Parser { * - extend schema Directives[Const] * ``` */ + parseSchemaExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30488,6 +29487,7 @@ class Parser { * ScalarTypeExtension : * - extend scalar Name Directives[Const] */ + parseScalarTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30509,6 +29509,7 @@ class Parser { * - extend type Name ImplementsInterfaces? Directives[Const] * - extend type Name ImplementsInterfaces */ + parseObjectTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30534,6 +29535,7 @@ class Parser { * - extend interface Name ImplementsInterfaces? Directives[Const] * - extend interface Name ImplementsInterfaces */ + parseInterfaceTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30558,6 +29560,7 @@ class Parser { * - extend union Name Directives[Const]? UnionMemberTypes * - extend union Name Directives[Const] */ + parseUnionTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30580,6 +29583,7 @@ class Parser { * - extend enum Name Directives[Const]? EnumValuesDefinition * - extend enum Name Directives[Const] */ + parseEnumTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30602,6 +29606,7 @@ class Parser { * - extend input Name Directives[Const]? InputFieldsDefinition * - extend input Name Directives[Const] */ + parseInputObjectTypeExtension() { const start = this._lexer.token; this.expectKeyword('extend'); @@ -30625,6 +29630,7 @@ class Parser { * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations * ``` */ + parseDirectiveDefinition() { const start = this._lexer.token; const description = this.parseDescription(); @@ -30649,6 +29655,7 @@ class Parser { * - `|`? DirectiveLocation * - DirectiveLocations | DirectiveLocation */ + parseDirectiveLocations() { return this.delimitedMany(_tokenKind.TokenKind.PIPE, this.parseDirectiveLocation); } @@ -30679,20 +29686,22 @@ class Parser { * `INPUT_OBJECT` * `INPUT_FIELD_DEFINITION` */ + parseDirectiveLocation() { const start = this._lexer.token; const name = this.parseName(); - if (Object.hasOwn(_directiveLocation.DirectiveLocation, name.value)) { + if (Object.prototype.hasOwnProperty.call(_directiveLocation.DirectiveLocation, name.value)) { return name; } throw this.unexpected(start); - } - // Core parsing utility functions + } // 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); @@ -30702,6 +29711,7 @@ class Parser { /** * Determines if the next token is of a given kind */ + peek(kind) { return this._lexer.token.kind === kind; } @@ -30709,6 +29719,7 @@ class Parser { * 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) { @@ -30721,6 +29732,7 @@ class Parser { * 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) { @@ -30733,6 +29745,7 @@ class Parser { * 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) { @@ -30745,6 +29758,7 @@ class Parser { * 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) { @@ -30756,6 +29770,7 @@ class Parser { /** * 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)}.`); @@ -30765,6 +29780,7 @@ class Parser { * 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 = []; @@ -30779,6 +29795,7 @@ class Parser { * 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 = []; @@ -30794,6 +29811,7 @@ class Parser { * 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 = []; @@ -30807,6 +29825,7 @@ class Parser { * 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 = []; @@ -30823,7 +29842,7 @@ class Parser { 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 than ${maxTokens} tokens. Parsing aborted.`); + throw (0, _syntaxError.syntaxError)(this._lexer.source, token.start, `Document contains more that ${maxTokens} tokens. Parsing aborted.`); } } } @@ -30839,6 +29858,7 @@ function getTokenDesc(token) { /** * A helper function to describe a token kind as a string for debugging. */ + function getTokenKindDesc(kind) { return (0, _lexer.isPunctuatorTokenKind)(kind) ? `"${kind}"` : kind; } @@ -30859,7 +29879,6 @@ Object.defineProperty(exports, "__esModule", ({ exports.isConstValueNode = isConstValueNode; exports.isDefinitionNode = isDefinitionNode; exports.isExecutableDefinitionNode = isExecutableDefinitionNode; -exports.isNullabilityAssertionNode = isNullabilityAssertionNode; exports.isSelectionNode = isSelectionNode; exports.isTypeDefinitionNode = isTypeDefinitionNode; exports.isTypeExtensionNode = isTypeExtensionNode; @@ -30877,9 +29896,6 @@ function isExecutableDefinitionNode(node) { function isSelectionNode(node) { return node.kind === _kinds.Kind.FIELD || node.kind === _kinds.Kind.FRAGMENT_SPREAD || node.kind === _kinds.Kind.INLINE_FRAGMENT; } -function isNullabilityAssertionNode(node) { - return node.kind === _kinds.Kind.LIST_NULLABILITY_OPERATOR || node.kind === _kinds.Kind.NON_NULL_ASSERTION || node.kind === _kinds.Kind.ERROR_BOUNDARY; -} 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; } @@ -30927,6 +29943,7 @@ function printLocation(location) { /** * 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; @@ -30937,8 +29954,8 @@ function printSourceLocation(source, sourceLocation) { 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 + const locationLine = lines[lineIndex]; // Special case for minified documents + if (locationLine.length > 120) { const subLineIndex = Math.floor(columnNum / 80); const subLineColumnNum = columnNum % 80; @@ -30978,14 +29995,24 @@ exports.printString = printString; */ function printString(str) { return `"${str.replace(escapedRegExp, escapedReplacer)}"`; -} -// eslint-disable-next-line no-control-regex +} // 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', '', '', '\\"', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '\\\\', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '\\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']; +} // 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']; /***/ }), @@ -31008,6 +30035,7 @@ var _visitor = __webpack_require__(/*! ./visitor.mjs */ "../../../node_modules/g * Converts an AST into a string, using one set of reasonable * formatting rules. */ + function print(ast) { return (0, _visitor.visit)(ast, printDocASTReducer); } @@ -31026,9 +30054,9 @@ const printDocASTReducer = { 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 + 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; } }, @@ -31050,19 +30078,15 @@ const printDocASTReducer = { alias, name, arguments: args, - nullabilityAssertion, directives, selectionSet }) { - const prefix = join([wrap('', alias, ': '), name], ''); + 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, - // Note: Client Controlled Nullability is experimental and may be - // changed or removed in the future. - nullabilityAssertion, wrap(' ', join(directives, ' ')), wrap(' ', selectionSet)]); + return join([argsLine, join(directives, ' '), selectionSet], ' '); } }, Argument: { @@ -31071,28 +30095,6 @@ const printDocASTReducer = { value }) => name + ': ' + value }, - // Nullability Modifiers - ListNullabilityOperator: { - leave({ - nullabilityAssertion - }) { - return join(['[', nullabilityAssertion, ']']); - } - }, - NonNullAssertion: { - leave({ - nullabilityAssertion - }) { - return join([nullabilityAssertion, '!']); - } - }, - ErrorBoundary: { - leave({ - nullabilityAssertion - }) { - return join([nullabilityAssertion, '?']); - } - }, // Fragments FragmentSpread: { leave: ({ @@ -31114,8 +30116,8 @@ const printDocASTReducer = { variableDefinitions, directives, selectionSet - }) => - // Note: fragment variable definitions are experimental and may be changed + } // 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 }, @@ -31134,7 +30136,7 @@ const printDocASTReducer = { leave: ({ value, block: isBlockString - }) => isBlockString === true ? (0, _blockString.printBlockString)(value) : (0, _printString.printString)(value) + }) => isBlockString ? (0, _blockString.printBlockString)(value) : (0, _printString.printString)(value) }, BooleanValue: { leave: ({ @@ -31152,21 +30154,12 @@ const printDocASTReducer = { ListValue: { leave: ({ values - }) => { - const valuesLine = '[' + join(values, ', ') + ']'; - if (valuesLine.length > MAX_LINE_LENGTH) { - return '[\n' + indent(join(values, '\n')) + '\n]'; - } - return valuesLine; - } + }) => '[' + join(values, ', ') + ']' }, ObjectValue: { leave: ({ fields - }) => { - const fieldsLine = '{ ' + join(fields, ', ') + ' }'; - return fieldsLine.length > MAX_LINE_LENGTH ? block(fields) : fieldsLine; - } + }) => '{' + join(fields, ', ') + '}' }, ObjectField: { leave: ({ @@ -31348,6 +30341,7 @@ const printDocASTReducer = { * 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 : ''; @@ -31355,21 +30349,25 @@ function join(maybeArray, separator = '') { /** * 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.replaceAll('\n', '\n ')); + 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; } @@ -31390,6 +30388,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.Source = void 0; exports.isSource = isSource; var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); +var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _instanceOf = __webpack_require__(/*! ../jsutils/instanceOf.mjs */ "../../../node_modules/graphql/jsutils/instanceOf.mjs"); /** * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are @@ -31403,6 +30402,7 @@ class Source { 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; @@ -31446,7 +30446,6 @@ var TokenKind; TokenKind['SOF'] = ''; TokenKind['EOF'] = ''; TokenKind['BANG'] = '!'; - TokenKind['QUESTION_MARK'] = '?'; TokenKind['DOLLAR'] = '$'; TokenKind['AMP'] = '&'; TokenKind['PAREN_L'] = '('; @@ -31468,6 +30467,12 @@ var TokenKind; TokenKind['COMMENT'] = 'Comment'; })(TokenKind || (exports.TokenKind = TokenKind = {})); +/** + * The enum type representing the token kinds values. + * + * @deprecated Please use `TokenKind`. Will be remove in v17. + */ + /***/ }), /***/ "../../../node_modules/graphql/language/visitor.mjs": @@ -31483,19 +30488,105 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.BREAK = void 0; exports.getEnterLeaveForKind = getEnterLeaveForKind; +exports.getVisitFn = getVisitFn; exports.visit = visit; exports.visitInParallel = visitInParallel; var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _ast = __webpack_require__(/*! ./ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); var _kinds = __webpack_require__(/*! ./kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); +/** + * A visitor is provided to visit, it contains the collection of + * relevant functions to be called during the visitor's traversal. + */ + const BREAK = exports.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 + * } + * }) + * ``` + */ + 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]; @@ -31507,6 +30598,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { const path = []; const ancestors = []; /* eslint-enable no-undef-init */ + do { index++; const isLeaving = index === keys.length; @@ -31540,7 +30632,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { edits = stack.edits; inArray = stack.inArray; stack = stack.prev; - } else if (parent != null) { + } else if (parent) { key = inArray ? index : keys[index]; node = parent[key]; if (node === null || node === undefined) { @@ -31580,7 +30672,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { if (isLeaving) { path.pop(); } else { - var _visitorKeys$node$kin; + var _node$kind; stack = { inArray, index, @@ -31589,10 +30681,10 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { prev: stack }; inArray = Array.isArray(node); - keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : []; + keys = inArray ? node : (_node$kind = visitorKeys[node.kind]) !== null && _node$kind !== void 0 ? _node$kind : []; index = -1; edits = []; - if (parent != null) { + if (parent) { ancestors.push(parent); } parent = node; @@ -31600,7 +30692,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { } while (stack !== undefined); if (edits.length !== 0) { // New root - return edits.at(-1)[1]; + return edits[edits.length - 1][1]; } return root; } @@ -31610,6 +30702,7 @@ function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { * * 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); @@ -31622,7 +30715,7 @@ function visitInParallel(visitors) { enter, leave } = getEnterLeaveForKind(visitors[i], kind); - hasVisitor ||= enter != null || leave != null; + hasVisitor || (hasVisitor = enter != null || leave != null); enterList[i] = enter; leaveList[i] = leave; } @@ -31670,6 +30763,7 @@ function visitInParallel(visitors) { /** * 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') { @@ -31681,13 +30775,29 @@ function getEnterLeaveForKind(visitor, kind) { enter: kindVisitor, leave: undefined }; - } - // { enter() {}, leave() {} } + } // { 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; +} /***/ }), @@ -31704,12 +30814,16 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.assertEnumValueName = assertEnumValueName; exports.assertName = assertName; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _characterClasses = __webpack_require__(/*! ../language/characterClasses.mjs */ "../../../node_modules/graphql/language/characterClasses.mjs"); /** * 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.'); } @@ -31728,6 +30842,7 @@ function assertName(name) { * * @internal */ + function assertEnumValueName(name) { if (name === 'true' || name === 'false' || name === 'null') { throw new _GraphQLError.GraphQLError(`Enum values cannot be named: ${name}`); @@ -31796,6 +30911,7 @@ var _didYouMean = __webpack_require__(/*! ../jsutils/didYouMean.mjs */ "../../.. var _identityFunc = __webpack_require__(/*! ../jsutils/identityFunc.mjs */ "../../../node_modules/graphql/jsutils/identityFunc.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _instanceOf = __webpack_require__(/*! ../jsutils/instanceOf.mjs */ "../../../node_modules/graphql/jsutils/instanceOf.mjs"); +var _isObjectLike = __webpack_require__(/*! ../jsutils/isObjectLike.mjs */ "../../../node_modules/graphql/jsutils/isObjectLike.mjs"); var _keyMap = __webpack_require__(/*! ../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _keyValMap = __webpack_require__(/*! ../jsutils/keyValMap.mjs */ "../../../node_modules/graphql/jsutils/keyValMap.mjs"); var _mapValue = __webpack_require__(/*! ../jsutils/mapValue.mjs */ "../../../node_modules/graphql/jsutils/mapValue.mjs"); @@ -31818,6 +30934,7 @@ function assertType(type) { /** * There are predicates for each kind of GraphQL type. */ + function isScalarType(type) { return (0, _instanceOf.instanceOf)(type, GraphQLScalarType); } @@ -31890,6 +31007,10 @@ function assertNonNullType(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); } @@ -31899,6 +31020,10 @@ function assertInputType(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); } @@ -31908,6 +31033,10 @@ function assertOutputType(type) { } return type; } +/** + * These types may describe types which may be leaf values. + */ + function isLeafType(type) { return isScalarType(type) || isEnumType(type); } @@ -31917,6 +31046,10 @@ function assertLeafType(type) { } return type; } +/** + * These types may describe the parent context of a selection set. + */ + function isCompositeType(type) { return isObjectType(type) || isInterfaceType(type) || isUnionType(type); } @@ -31926,6 +31059,10 @@ function assertCompositeType(type) { } return type; } +/** + * These types may describe the parent context of a selection set. + */ + function isAbstractType(type) { return isInterfaceType(type) || isUnionType(type); } @@ -31954,8 +31091,10 @@ function assertAbstractType(type) { * }) * ``` */ + 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]() { @@ -31992,6 +31131,7 @@ class GraphQLList { 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]() { @@ -32004,6 +31144,9 @@ class GraphQLNonNull { return this.toString(); } } +/** + * These types wrap and modify other types + */ exports.GraphQLNonNull = GraphQLNonNull; function isWrappingType(type) { return isListType(type) || isNonNullType(type); @@ -32014,6 +31157,10 @@ function assertWrappingType(type) { } return type; } +/** + * These types can all accept null as a value. + */ + function isNullableType(type) { return isType(type) && !isNonNullType(type); } @@ -32028,6 +31175,10 @@ function getNullableType(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); } @@ -32046,12 +31197,27 @@ function getNamedType(type) { 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 * @@ -32096,6 +31262,8 @@ class GraphQLScalarType { 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.`); } @@ -32123,6 +31291,7 @@ class GraphQLScalarType { return this.toString(); } } + /** * Object Type Definition * @@ -32173,10 +31342,9 @@ class GraphQLObjectType { this.extensions = (0, _toObjMap.toObjMap)(config.extensions); this.astNode = config.astNode; this.extensionASTNodes = (_config$extensionASTN2 = config.extensionASTNodes) !== null && _config$extensionASTN2 !== void 0 ? _config$extensionASTN2 : []; - // prettier-ignore - // FIXME: blocked by https://github.com/prettier/prettier/issues/14625 - this._fields = defineFieldMap.bind(undefined, config.fields); - this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + 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'; @@ -32213,14 +31381,21 @@ class GraphQLObjectType { } } exports.GraphQLObjectType = GraphQLObjectType; -function defineInterfaces(interfaces) { - return resolveReadonlyArrayThunk(interfaces !== null && interfaces !== void 0 ? interfaces : []); +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(fields) { - const fieldMap = resolveObjMapThunk(fields); +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, @@ -32234,8 +31409,8 @@ function defineFieldMap(fields) { }; }); } -function defineArguments(args) { - return Object.entries(args).map(([argName, argConfig]) => ({ +function defineArguments(config) { + return Object.entries(config).map(([argName, argConfig]) => ({ name: (0, _assertName.assertName)(argName), description: argConfig.description, type: argConfig.type, @@ -32245,6 +31420,9 @@ function defineArguments(args) { 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, @@ -32260,6 +31438,7 @@ function fieldsToFieldsConfig(fields) { /** * @internal */ + function argsToArgsConfig(args) { return (0, _keyValMap.keyValMap)(args, arg => arg.name, arg => ({ description: arg.description, @@ -32273,6 +31452,7 @@ function argsToArgsConfig(args) { function isRequiredArgument(arg) { return isNonNullType(arg.type) && arg.defaultValue === undefined; } + /** * Interface Type Definition * @@ -32301,10 +31481,9 @@ class GraphQLInterfaceType { this.extensions = (0, _toObjMap.toObjMap)(config.extensions); this.astNode = config.astNode; this.extensionASTNodes = (_config$extensionASTN3 = config.extensionASTNodes) !== null && _config$extensionASTN3 !== void 0 ? _config$extensionASTN3 : []; - // prettier-ignore - // FIXME: blocked by https://github.com/prettier/prettier/issues/14625 - this._fields = defineFieldMap.bind(undefined, config.fields); - this._interfaces = defineInterfaces.bind(undefined, config.interfaces); + 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'; @@ -32340,6 +31519,7 @@ class GraphQLInterfaceType { return this.toString(); } } + /** * Union Type Definition * @@ -32374,7 +31554,8 @@ class GraphQLUnionType { 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.types); + 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'; @@ -32404,19 +31585,12 @@ class GraphQLUnionType { } } exports.GraphQLUnionType = GraphQLUnionType; -function defineTypes(types) { - return resolveReadonlyArrayThunk(types); -} -function enumValuesFromConfig(values) { - return Object.entries(values).map(([valueName, valueConfig]) => ({ - 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 - })); +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 * @@ -32440,7 +31614,8 @@ function enumValuesFromConfig(values) { * 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 /* */ { +class GraphQLEnumType { + /* */ constructor(config) { var _config$extensionASTN5; this.name = (0, _assertName.assertName)(config.name); @@ -32448,7 +31623,7 @@ class GraphQLEnumType /* */ { 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 = typeof config.values === 'function' ? config.values : enumValuesFromConfig(config.values); + this._values = typeof config.values === 'function' ? config.values : defineEnumValues(this.name, config.values); this._valueLookup = null; this._nameLookup = null; } @@ -32457,7 +31632,7 @@ class GraphQLEnumType /* */ { } getValues() { if (typeof this._values === 'function') { - this._values = enumValuesFromConfig(this._values()); + this._values = defineEnumValues(this.name, this._values()); } return this._values; } @@ -32467,7 +31642,7 @@ class GraphQLEnumType /* */ { } return this._nameLookup[name]; } - serialize(outputValue /* T */) { + serialize(outputValue) { if (this._valueLookup === null) { this._valueLookup = new Map(this.getValues().map(enumValue => [enumValue.value, enumValue])); } @@ -32477,7 +31652,8 @@ class GraphQLEnumType /* */ { } return enumValue.name; } - parseValue(inputValue) { + 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)); @@ -32488,7 +31664,8 @@ class GraphQLEnumType /* */ { } return enumValue.value; } - parseLiteral(valueNode, _variables) { + 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); @@ -32535,6 +31712,21 @@ function didYouMeanEnumValue(enumType, unknownValueStr) { 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 * @@ -32565,7 +31757,7 @@ class GraphQLInputObjectType { this.astNode = config.astNode; this.extensionASTNodes = (_config$extensionASTN6 = config.extensionASTNodes) !== null && _config$extensionASTN6 !== void 0 ? _config$extensionASTN6 : []; this.isOneOf = (_config$isOneOf = config.isOneOf) !== null && _config$isOneOf !== void 0 ? _config$isOneOf : false; - this._fields = defineInputFieldMap.bind(undefined, config.fields); + this._fields = defineInputFieldMap.bind(undefined, config); } get [Symbol.toStringTag]() { return 'GraphQLInputObjectType'; @@ -32603,17 +31795,21 @@ class GraphQLInputObjectType { } } exports.GraphQLInputObjectType = GraphQLInputObjectType; -function defineInputFieldMap(fields) { - const fieldMap = resolveObjMapThunk(fields); - return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => ({ - 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 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; @@ -32632,13 +31828,15 @@ function isRequiredInputField(field) { Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.GraphQLStreamDirective = exports.GraphQLSpecifiedByDirective = exports.GraphQLSkipDirective = exports.GraphQLOneOfDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = exports.GraphQLDeprecatedDirective = exports.GraphQLDeferDirective = exports.DEFAULT_DEPRECATION_REASON = void 0; +exports.GraphQLSpecifiedByDirective = exports.GraphQLSkipDirective = exports.GraphQLOneOfDirective = 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 = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _instanceOf = __webpack_require__(/*! ../jsutils/instanceOf.mjs */ "../../../node_modules/graphql/jsutils/instanceOf.mjs"); +var _isObjectLike = __webpack_require__(/*! ../jsutils/isObjectLike.mjs */ "../../../node_modules/graphql/jsutils/isObjectLike.mjs"); var _toObjMap = __webpack_require__(/*! ../jsutils/toObjMap.mjs */ "../../../node_modules/graphql/jsutils/toObjMap.mjs"); var _directiveLocation = __webpack_require__(/*! ../language/directiveLocation.mjs */ "../../../node_modules/graphql/language/directiveLocation.mjs"); var _assertName = __webpack_require__(/*! ./assertName.mjs */ "../../../node_modules/graphql/type/assertName.mjs"); @@ -32647,6 +31845,7 @@ var _scalars = __webpack_require__(/*! ./scalars.mjs */ "../../../node_modules/g /** * Test if the given value is a GraphQL directive. */ + function isDirective(directive) { return (0, _instanceOf.instanceOf)(directive, GraphQLDirective); } @@ -32656,6 +31855,16 @@ function assertDirective(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. @@ -32669,7 +31878,9 @@ class GraphQLDirective { 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]() { @@ -32693,6 +31904,7 @@ class GraphQLDirective { return this.toString(); } } + /** * Used to conditionally include fields or fragments. */ @@ -32711,6 +31923,7 @@ const GraphQLIncludeDirective = exports.GraphQLIncludeDirective = new GraphQLDir /** * Used to conditionally skip (exclude) fields or fragments. */ + const GraphQLSkipDirective = exports.GraphQLSkipDirective = new GraphQLDirective({ name: 'skip', description: 'Directs the executor to skip this field or fragment when the `if` argument is true.', @@ -32722,56 +31935,15 @@ const GraphQLSkipDirective = exports.GraphQLSkipDirective = new GraphQLDirective } } }); -/** - * Used to conditionally defer fragments. - */ -const GraphQLDeferDirective = exports.GraphQLDeferDirective = new GraphQLDirective({ - name: 'defer', - description: 'Directs the executor to defer this fragment when the `if` argument is true or undefined.', - locations: [_directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, _directiveLocation.DirectiveLocation.INLINE_FRAGMENT], - args: { - if: { - type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), - description: 'Deferred when true or undefined.', - defaultValue: true - }, - label: { - type: _scalars.GraphQLString, - description: 'Unique name' - } - } -}); -/** - * Used to conditionally stream list fields. - */ -const GraphQLStreamDirective = exports.GraphQLStreamDirective = new GraphQLDirective({ - name: 'stream', - description: 'Directs the executor to stream plural fields when the `if` argument is true or undefined.', - locations: [_directiveLocation.DirectiveLocation.FIELD], - args: { - if: { - type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), - description: 'Stream when true or undefined.', - defaultValue: true - }, - label: { - type: _scalars.GraphQLString, - description: 'Unique name' - }, - initialCount: { - defaultValue: 0, - type: _scalars.GraphQLInt, - description: 'Number of items to return immediately' - } - } -}); /** * Constant string used for default reason for a deprecation. */ + const DEFAULT_DEPRECATION_REASON = exports.DEFAULT_DEPRECATION_REASON = 'No longer supported'; /** * Used to declare element of a GraphQL schema as deprecated. */ + const GraphQLDeprecatedDirective = exports.GraphQLDeprecatedDirective = new GraphQLDirective({ name: 'deprecated', description: 'Marks an element of a GraphQL schema as no longer supported.', @@ -32787,6 +31959,7 @@ const GraphQLDeprecatedDirective = exports.GraphQLDeprecatedDirective = new Grap /** * Used to provide a URL for specifying the behavior of custom scalar definitions. */ + const GraphQLSpecifiedByDirective = exports.GraphQLSpecifiedByDirective = new GraphQLDirective({ name: 'specifiedBy', description: 'Exposes a URL that specifies the behavior of this scalar.', @@ -32801,6 +31974,7 @@ const GraphQLSpecifiedByDirective = exports.GraphQLSpecifiedByDirective = new Gr /** * Used to indicate an Input Object is a OneOf Input Object. */ + const GraphQLOneOfDirective = exports.GraphQLOneOfDirective = new GraphQLDirective({ name: 'oneOf', description: 'Indicates exactly one field must be supplied and this field must not be `null`.', @@ -32810,6 +31984,7 @@ const GraphQLOneOfDirective = exports.GraphQLOneOfDirective = new GraphQLDirecti /** * The full list of specified directives. */ + const specifiedDirectives = exports.specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective, GraphQLOneOfDirective]); function isSpecifiedDirective(directive) { return specifiedDirectives.some(({ @@ -32854,12 +32029,6 @@ Object.defineProperty(exports, "GraphQLBoolean", ({ return _scalars.GraphQLBoolean; } })); -Object.defineProperty(exports, "GraphQLDeferDirective", ({ - enumerable: true, - get: function () { - return _directives.GraphQLDeferDirective; - } -})); Object.defineProperty(exports, "GraphQLDeprecatedDirective", ({ enumerable: true, get: function () { @@ -32962,12 +32131,6 @@ Object.defineProperty(exports, "GraphQLSpecifiedByDirective", ({ return _directives.GraphQLSpecifiedByDirective; } })); -Object.defineProperty(exports, "GraphQLStreamDirective", ({ - enumerable: true, - get: function () { - return _directives.GraphQLStreamDirective; - } -})); Object.defineProperty(exports, "GraphQLString", ({ enumerable: true, get: function () { @@ -33474,7 +32637,7 @@ const __Directive = exports.__Directive = new _definition.GraphQLObjectType({ resolve(field, { includeDeprecated }) { - return includeDeprecated === true ? field.args : field.args.filter(arg => arg.deprecationReason == null); + return includeDeprecated ? field.args : field.args.filter(arg => arg.deprecationReason == null); } } }) @@ -33594,6 +32757,7 @@ const __Type = exports.__Type = new _definition.GraphQLObjectType({ } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered) + false || (0, _invariant.invariant)(false, `Unexpected type: "${(0, _inspect.inspect)(type)}".`); } }, @@ -33603,9 +32767,8 @@ const __Type = exports.__Type = new _definition.GraphQLObjectType({ }, description: { type: _scalars.GraphQLString, - resolve: type => - // FIXME: add test case - /* c8 ignore next */ + resolve: (type // FIXME: add test case + ) => /* c8 ignore next */ 'description' in type ? type.description : undefined }, specifiedByURL: { @@ -33625,7 +32788,7 @@ const __Type = exports.__Type = new _definition.GraphQLObjectType({ }) { if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) { const fields = Object.values(type.getFields()); - return includeDeprecated === true ? fields : fields.filter(field => field.deprecationReason == null); + return includeDeprecated ? fields : fields.filter(field => field.deprecationReason == null); } } }, @@ -33660,7 +32823,7 @@ const __Type = exports.__Type = new _definition.GraphQLObjectType({ }) { if ((0, _definition.isEnumType)(type)) { const values = type.getValues(); - return includeDeprecated === true ? values : values.filter(field => field.deprecationReason == null); + return includeDeprecated ? values : values.filter(field => field.deprecationReason == null); } } }, @@ -33677,7 +32840,7 @@ const __Type = exports.__Type = new _definition.GraphQLObjectType({ }) { if ((0, _definition.isInputObjectType)(type)) { const values = Object.values(type.getFields()); - return includeDeprecated === true ? values : values.filter(field => field.deprecationReason == null); + return includeDeprecated ? values : values.filter(field => field.deprecationReason == null); } } }, @@ -33718,7 +32881,7 @@ const __Field = exports.__Field = new _definition.GraphQLObjectType({ resolve(field, { includeDeprecated }) { - return includeDeprecated === true ? field.args : field.args.filter(arg => arg.deprecationReason == null); + return includeDeprecated ? field.args : field.args.filter(arg => arg.deprecationReason == null); } }, type: { @@ -33848,6 +33011,7 @@ const __TypeKind = exports.__TypeKind = new _definition.GraphQLEnumType({ * Note that these are GraphQLField and not GraphQLFieldConfig, * so the format for args is different. */ + const SchemaMetaFieldDef = exports.SchemaMetaFieldDef = { name: '__schema', type: new _definition.GraphQLNonNull(__Schema), @@ -33927,11 +33091,13 @@ var _definition = __webpack_require__(/*! ./definition.mjs */ "../../../node_mod * 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 = exports.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) * */ + const GRAPHQL_MIN_INT = exports.GRAPHQL_MIN_INT = -2147483648; const GraphQLInt = exports.GraphQLInt = new _definition.GraphQLScalarType({ name: 'Int', @@ -34002,9 +33168,7 @@ const GraphQLFloat = exports.GraphQLFloat = new _definition.GraphQLScalarType({ }, 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)}`, { - nodes: valueNode - }); + throw new _GraphQLError.GraphQLError(`Float cannot represent non numeric value: ${(0, _printer.print)(valueNode)}`, valueNode); } return parseFloat(valueNode.value); } @@ -34013,9 +33177,9 @@ const GraphQLString = exports.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 + 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; } @@ -34106,10 +33270,10 @@ function isSpecifiedScalarType(type) { return specifiedScalarTypes.some(({ name }) => type.name === name); -} -// Support serializing objects with custom valueOf() or toJSON() functions - +} // 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') { @@ -34141,8 +33305,10 @@ Object.defineProperty(exports, "__esModule", ({ exports.GraphQLSchema = void 0; exports.assertSchema = assertSchema; exports.isSchema = isSchema; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _instanceOf = __webpack_require__(/*! ../jsutils/instanceOf.mjs */ "../../../node_modules/graphql/jsutils/instanceOf.mjs"); +var _isObjectLike = __webpack_require__(/*! ../jsutils/isObjectLike.mjs */ "../../../node_modules/graphql/jsutils/isObjectLike.mjs"); var _toObjMap = __webpack_require__(/*! ../jsutils/toObjMap.mjs */ "../../../node_modules/graphql/jsutils/toObjMap.mjs"); var _ast = __webpack_require__(/*! ../language/ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); var _definition = __webpack_require__(/*! ./definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); @@ -34151,6 +33317,7 @@ var _introspection = __webpack_require__(/*! ./introspection.mjs */ "../../../no /** * Test if the given value is a GraphQL schema. */ + function isSchema(schema) { return (0, _instanceOf.instanceOf)(schema, GraphQLSchema); } @@ -34160,6 +33327,16 @@ function assertSchema(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 * @@ -34229,22 +33406,28 @@ function assertSchema(schema) { * ``` */ 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; + 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 + 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) { @@ -34271,17 +33454,18 @@ class GraphQLSchema { } } } - collectReferencedTypes(_introspection.__Schema, allReferencedTypes); - // Storing the resulting map for reference by the schema. + collectReferencedTypes(_introspection.__Schema, allReferencedTypes); // Storing the resulting map for reference by the schema. + this._typeMap = Object.create(null); - this._subTypeMap = new Map(); - // Keep track of all implementations by interface name. + 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}".`); } @@ -34356,17 +33540,25 @@ class GraphQLSchema { }; } isSubType(abstractType, maybeSubType) { - let set = this._subTypeMap.get(abstractType); - if (set === undefined) { + let map = this._subTypeMap[abstractType.name]; + if (map === undefined) { + map = Object.create(null); if ((0, _definition.isUnionType)(abstractType)) { - set = new Set(abstractType.getTypes()); + for (const type of abstractType.getTypes()) { + map[type.name] = true; + } } else { const implementations = this.getImplementations(abstractType); - set = new Set([...implementations.objects, ...implementations.interfaces]); + for (const type of implementations.objects) { + map[type.name] = true; + } + for (const type of implementations.interfaces) { + map[type.name] = true; + } } - this._subTypeMap.set(abstractType, set); + this._subTypeMap[abstractType.name] = map; } - return set.has(maybeSubType); + return map[maybeSubType.name] !== undefined; } getDirectives() { return this._directives; @@ -34374,33 +33566,6 @@ class GraphQLSchema { getDirective(name) { return this.getDirectives().find(directive => directive.name === name); } - /** - * 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. - */ - getField(parentType, fieldName) { - switch (fieldName) { - case _introspection.SchemaMetaFieldDef.name: - return this.getQueryType() === parentType ? _introspection.SchemaMetaFieldDef : undefined; - case _introspection.TypeMetaFieldDef.name: - return this.getQueryType() === parentType ? _introspection.TypeMetaFieldDef : undefined; - case _introspection.TypeNameMetaFieldDef.name: - return _introspection.TypeNameMetaFieldDef; - } - // this function is part "hot" path inside executor and check presence - // of 'getFields' is faster than to use `!isUnionType` - if ('getFields' in parentType) { - return parentType.getFields()[fieldName]; - } - return undefined; - } toConfig() { return { description: this.description, @@ -34459,9 +33624,6 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.assertValidSchema = assertValidSchema; exports.validateSchema = validateSchema; -var _AccumulatorMap = __webpack_require__(/*! ../jsutils/AccumulatorMap.mjs */ "../../../node_modules/graphql/jsutils/AccumulatorMap.mjs"); -var _capitalize = __webpack_require__(/*! ../jsutils/capitalize.mjs */ "../../../node_modules/graphql/jsutils/capitalize.mjs"); -var _formatList = __webpack_require__(/*! ../jsutils/formatList.mjs */ "../../../node_modules/graphql/jsutils/formatList.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _ast = __webpack_require__(/*! ../language/ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); @@ -34477,20 +33639,21 @@ var _schema = __webpack_require__(/*! ./schema.mjs */ "../../../node_modules/gra * 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. + (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. + } // 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 + 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; @@ -34499,6 +33662,7 @@ function validateSchema(schema) { * 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) { @@ -34522,28 +33686,22 @@ class SchemaValidationContext { } function validateRootTypes(context) { const schema = context.schema; - if (schema.getQueryType() == null) { + 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 rootTypesMap = new _AccumulatorMap.AccumulatorMap(); - for (const operationType of Object.values(_ast.OperationTypeNode)) { - const rootType = schema.getRootType(operationType); - if (rootType != null) { - if (!(0, _definition.isObjectType)(rootType)) { - var _getOperationTypeNode; - const operationTypeStr = (0, _capitalize.capitalize)(operationType); - const rootTypeStr = (0, _inspect.inspect)(rootType); - context.reportError(operationType === _ast.OperationTypeNode.QUERY ? `${operationTypeStr} root type must be Object type, it cannot be ${rootTypeStr}.` : `${operationTypeStr} root type must be Object type if provided, it cannot be ${rootTypeStr}.`, (_getOperationTypeNode = getOperationTypeNode(schema, operationType)) !== null && _getOperationTypeNode !== void 0 ? _getOperationTypeNode : rootType.astNode); - } else { - rootTypesMap.add(rootType, operationType); - } - } + 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); } - for (const [rootType, operationTypes] of rootTypesMap) { - if (operationTypes.length > 1) { - const operationList = (0, _formatList.andList)(operationTypes); - context.reportError(`All root types must be different, "${rootType.name}" type is used as ${operationList} root types.`, operationTypes.map(operationType => getOperationTypeNode(schema, operationType))); - } + 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) { @@ -34552,7 +33710,9 @@ function getOperationTypeNode(schema, operation) { // 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 : []; + 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) { @@ -34561,17 +33721,15 @@ function validateDirectives(context) { 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); - if (directive.locations.length === 0) { - context.reportError(`Directive @${directive.name} must include 1 or more locations.`, directive.astNode); - } + } // 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. + 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); } @@ -34596,20 +33754,20 @@ function validateTypes(context) { 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). + } // 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. + 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. + 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. @@ -34619,32 +33777,32 @@ function validateTypes(context) { 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 + 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. + 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 + 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 + } // 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 + 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); @@ -34657,7 +33815,7 @@ function validateFields(context, type) { } } function validateInterfaces(context, type) { - const ifaceTypeNames = new Set(); + 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)); @@ -34667,51 +33825,50 @@ function validateInterfaces(context, type) { context.reportError(`Type ${type.name} cannot implement itself because it would create a circular reference.`, getAllImplementsInterfaceNodes(type, iface)); continue; } - if (ifaceTypeNames.has(iface.name)) { + if (ifaceTypeNames[iface.name]) { context.reportError(`Type ${type.name} can only implement ${iface.name} once.`, getAllImplementsInterfaceNodes(type, iface)); continue; } - ifaceTypeNames.add(iface.name); + 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. + 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 == null) { + 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 + } // 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. + } // 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. + 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. + } // 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. + } // 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); @@ -34734,13 +33891,13 @@ function validateUnionMembers(context, union) { if (memberTypes.length === 0) { context.reportError(`Union type ${union.name} must define one or more member types.`, [union.astNode, ...union.extensionASTNodes]); } - const includedTypeNames = new Set(); + const includedTypeNames = Object.create(null); for (const memberType of memberTypes) { - if (includedTypeNames.has(memberType.name)) { + if (includedTypeNames[memberType.name]) { context.reportError(`Union type ${union.name} can only include type ${memberType.name} once.`, getUnionMemberTypeNodes(union, memberType.name)); continue; } - includedTypeNames.add(memberType.name); + 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))); } @@ -34760,12 +33917,12 @@ 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 + } // 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 + 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); @@ -34792,20 +33949,20 @@ 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 = new Set(); - // Array of types nodes used to produce meaningful errors - const fieldPath = []; - // Position in the type path + 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. + 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.has(inputObj)) { + if (visitedTypes[inputObj.name]) { return; } - visitedTypes.add(inputObj); + visitedTypes[inputObj.name] = true; fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; const fields = Object.values(inputObj.getFields()); for (const field of fields) { @@ -34831,11 +33988,13 @@ function getAllImplementsInterfaceNodes(type, iface) { astNode, extensionASTNodes } = type; - const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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 : []; + 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) { @@ -34843,11 +34002,13 @@ function getUnionMemberTypeNodes(union, typeName) { astNode, extensionASTNodes } = union; - const nodes = astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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 : []; + return /* c8 ignore next */( + (_unionNode$types = unionNode.types) !== null && _unionNode$types !== void 0 ? _unionNode$types : [] + ); }).filter(typeNode => typeNode.name.value === typeName); } function getDeprecatedDirectiveNode(definitionNode) { @@ -34874,12 +34035,14 @@ var _ast = __webpack_require__(/*! ../language/ast.mjs */ "../../../node_modules var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _visitor = __webpack_require__(/*! ../language/visitor.mjs */ "../../../node_modules/graphql/language/visitor.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); +var _introspection = __webpack_require__(/*! ../type/introspection.mjs */ "../../../node_modules/graphql/type/introspection.mjs"); var _typeFromAST = __webpack_require__(/*! ./typeFromAST.mjs */ "../../../node_modules/graphql/utilities/typeFromAST.mjs"); /** * 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, /** @@ -34914,22 +34077,34 @@ class TypeInfo { return 'TypeInfo'; } getType() { - return this._typeStack.at(-1); + if (this._typeStack.length > 0) { + return this._typeStack[this._typeStack.length - 1]; + } } getParentType() { - return this._parentTypeStack.at(-1); + if (this._parentTypeStack.length > 0) { + return this._parentTypeStack[this._parentTypeStack.length - 1]; + } } getInputType() { - return this._inputTypeStack.at(-1); + if (this._inputTypeStack.length > 0) { + return this._inputTypeStack[this._inputTypeStack.length - 1]; + } } getParentInputType() { - return this._inputTypeStack.at(-2); + if (this._inputTypeStack.length > 1) { + return this._inputTypeStack[this._inputTypeStack.length - 2]; + } } getFieldDef() { - return this._fieldDefStack.at(-1); + if (this._fieldDefStack.length > 0) { + return this._fieldDefStack[this._fieldDefStack.length - 1]; + } } getDefaultValue() { - return this._defaultValueStack.at(-1); + if (this._defaultValueStack.length > 0) { + return this._defaultValueStack[this._defaultValueStack.length - 1]; + } } getDirective() { return this._directive; @@ -34941,11 +34116,11 @@ class TypeInfo { return this._enumValue; } enter(node) { - const schema = this._schema; - // Note: many of the types below are explicitly typed as "unknown" to drop + 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: { @@ -35011,8 +34186,8 @@ class TypeInfo { 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. + 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; @@ -35024,7 +34199,7 @@ class TypeInfo { let inputField; if ((0, _definition.isInputObjectType)(objectType)) { inputField = objectType.getFields()[node.name.value]; - if (inputField != null) { + if (inputField) { inputFieldType = inputField.type; } } @@ -35042,8 +34217,7 @@ class TypeInfo { this._enumValue = enumValue; break; } - default: - // Ignore other nodes + default: // Ignore other nodes } } leave(node) { @@ -35079,19 +34253,37 @@ class TypeInfo { case _kinds.Kind.ENUM: this._enumValue = null; break; - default: - // Ignore other nodes + default: // Ignore other nodes } } } + +/** + * 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. + */ exports.TypeInfo = TypeInfo; function getFieldDef(schema, parentType, fieldNode) { - return schema.getField(parentType, fieldNode.name.value); + 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) { @@ -35124,6 +34316,56 @@ function visitWithTypeInfo(typeInfo, visitor) { /***/ }), +/***/ "../../../node_modules/graphql/utilities/assertValidName.mjs": +/*!*******************************************************************!*\ + !*** ../../../node_modules/graphql/utilities/assertValidName.mjs ***! + \*******************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.assertValidName = assertValidName; +exports.isValidNameError = isValidNameError; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); +var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); +var _assertName = __webpack_require__(/*! ../type/assertName.mjs */ "../../../node_modules/graphql/type/assertName.mjs"); +/* 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 */ + +/***/ }), + /***/ "../../../node_modules/graphql/utilities/astFromValue.mjs": /*!****************************************************************!*\ !*** ../../../node_modules/graphql/utilities/astFromValue.mjs ***! @@ -35164,6 +34406,7 @@ var _scalars = __webpack_require__(/*! ../type/scalars.mjs */ "../../../node_mod * | null | NullValue | * */ + function astFromValue(value, type) { if ((0, _definition.isNonNullType)(type)) { const astValue = astFromValue(value, type.ofType); @@ -35171,19 +34414,19 @@ function astFromValue(value, type) { return null; } return astValue; - } - // only explicit null, not undefined, NaN + } // only explicit null, not undefined, NaN + if (value === null) { return { kind: _kinds.Kind.NULL }; - } - // undefined + } // undefined + if (value === undefined) { return null; - } - // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + } // 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)) { @@ -35200,9 +34443,9 @@ function astFromValue(value, type) { }; } return astFromValue(value, itemType); - } - // Populate the fields of the input object by creating ASTs from each value + } // 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; @@ -35232,15 +34475,15 @@ function astFromValue(value, type) { const serialized = type.serialize(value); if (serialized == null) { return null; - } - // Others serialize based on their corresponding JavaScript scalar types. + } // 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. + } // JavaScript numbers can be Int or Float values. + if (typeof serialized === 'number' && Number.isFinite(serialized)) { const stringNum = String(serialized); return integerStringRegExp.test(stringNum) ? { @@ -35258,8 +34501,8 @@ function astFromValue(value, type) { kind: _kinds.Kind.ENUM, value: serialized }; - } - // ID types can use Int literals. + } // ID types can use Int literals. + if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) { return { kind: _kinds.Kind.INT, @@ -35275,6 +34518,7 @@ function astFromValue(value, type) { } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. + false || (0, _invariant.invariant)(false, 'Unexpected input type: ' + (0, _inspect.inspect)(type)); } /** @@ -35282,6 +34526,7 @@ function astFromValue(value, type) { * - NegativeSign? 0 * - NegativeSign? NonZeroDigit ( Digit+ )? */ + const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; /***/ }), @@ -35299,6 +34544,8 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.buildASTSchema = buildASTSchema; exports.buildSchema = buildSchema; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); +var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _parser = __webpack_require__(/*! ../language/parser.mjs */ "../../../node_modules/graphql/language/parser.mjs"); var _directives = __webpack_require__(/*! ../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); var _schema = __webpack_require__(/*! ../type/schema.mjs */ "../../../node_modules/graphql/type/schema.mjs"); @@ -35315,6 +34562,7 @@ var _extendSchema = __webpack_require__(/*! ./extendSchema.mjs */ "../../../node * 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); } @@ -35360,6 +34608,7 @@ function buildASTSchema(documentAST, options) { * 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, @@ -35408,50 +34657,49 @@ var _valueFromAST = __webpack_require__(/*! ./valueFromAST.mjs */ "../../../node * 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) { - // Even though the `introspection` argument is typed, in most cases it's received - // as an untyped value from the server, so we will do an additional check here. - (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 = new Map(schemaIntrospection.types.map(typeIntrospection => [typeIntrospection.name, buildType(typeIntrospection)])); - // Include standard types only if they are used. + (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.has(stdType.name)) { - typeMap.set(stdType.name, stdType); + if (typeMap[stdType.name]) { + typeMap[stdType.name] = stdType; } - } - // Get the root Query, Mutation, and Subscription types. - const queryType = schemaIntrospection.queryType != null ? getObjectType(schemaIntrospection.queryType) : null; - const mutationType = schemaIntrospection.mutationType != null ? getObjectType(schemaIntrospection.mutationType) : null; - const subscriptionType = schemaIntrospection.subscriptionType != null ? getObjectType(schemaIntrospection.subscriptionType) : null; - // Get the directives supported by Introspection, assuming empty-set if + } // 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 != null ? schemaIntrospection.directives.map(buildDirective) : []; - // Then produce and return a Schema with these types. + + 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: [...typeMap.values()], + 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. + }); // 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 == null) { + 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 == null) { + if (!nullableRef) { throw new Error('Decorated type deeper than introspection query.'); } const nullableType = getType(nullableRef); @@ -35464,8 +34712,8 @@ function buildClientSchema(introspection, options) { if (!typeName) { throw new Error(`Unknown type reference: ${(0, _inspect.inspect)(typeRef)}.`); } - const type = typeMap.get(typeName); - if (type == null) { + 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; @@ -35475,9 +34723,9 @@ function buildClientSchema(introspection, options) { } function getInterfaceType(typeRef) { return (0, _definition.assertInterfaceType)(getNamedType(typeRef)); - } - // Given a type's introspection result, construct the correct + } // 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) { @@ -35514,7 +34762,7 @@ function buildClientSchema(introspection, options) { if (implementingIntrospection.interfaces === null && implementingIntrospection.kind === _introspection.TypeKind.INTERFACE) { return []; } - if (implementingIntrospection.interfaces == null) { + if (!implementingIntrospection.interfaces) { const implementingIntrospectionStr = (0, _inspect.inspect)(implementingIntrospection); throw new Error(`Introspection result missing interfaces: ${implementingIntrospectionStr}.`); } @@ -35537,7 +34785,7 @@ function buildClientSchema(introspection, options) { }); } function buildUnionDef(unionIntrospection) { - if (unionIntrospection.possibleTypes == null) { + if (!unionIntrospection.possibleTypes) { const unionIntrospectionStr = (0, _inspect.inspect)(unionIntrospection); throw new Error(`Introspection result missing possibleTypes: ${unionIntrospectionStr}.`); } @@ -35548,7 +34796,7 @@ function buildClientSchema(introspection, options) { }); } function buildEnumDef(enumIntrospection) { - if (enumIntrospection.enumValues == null) { + if (!enumIntrospection.enumValues) { const enumIntrospectionStr = (0, _inspect.inspect)(enumIntrospection); throw new Error(`Introspection result missing enumValues: ${enumIntrospectionStr}.`); } @@ -35562,7 +34810,7 @@ function buildClientSchema(introspection, options) { }); } function buildInputObjectDef(inputObjectIntrospection) { - if (inputObjectIntrospection.inputFields == null) { + if (!inputObjectIntrospection.inputFields) { const inputObjectIntrospectionStr = (0, _inspect.inspect)(inputObjectIntrospection); throw new Error(`Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`); } @@ -35574,7 +34822,7 @@ function buildClientSchema(introspection, options) { }); } function buildFieldDefMap(typeIntrospection) { - if (typeIntrospection.fields == null) { + if (!typeIntrospection.fields) { throw new Error(`Introspection result missing fields: ${(0, _inspect.inspect)(typeIntrospection)}.`); } return (0, _keyValMap.keyValMap)(typeIntrospection.fields, fieldIntrospection => fieldIntrospection.name, buildField); @@ -35585,7 +34833,7 @@ function buildClientSchema(introspection, options) { const typeStr = (0, _inspect.inspect)(type); throw new Error(`Introspection must provide output type for fields, but received: ${typeStr}.`); } - if (fieldIntrospection.args == null) { + if (!fieldIntrospection.args) { const fieldIntrospectionStr = (0, _inspect.inspect)(fieldIntrospection); throw new Error(`Introspection result missing field args: ${fieldIntrospectionStr}.`); } @@ -35614,11 +34862,11 @@ function buildClientSchema(introspection, options) { }; } function buildDirective(directiveIntrospection) { - if (directiveIntrospection.args == null) { + if (!directiveIntrospection.args) { const directiveIntrospectionStr = (0, _inspect.inspect)(directiveIntrospection); throw new Error(`Introspection result missing directive args: ${directiveIntrospectionStr}.`); } - if (directiveIntrospection.locations == null) { + if (!directiveIntrospection.locations) { const directiveIntrospectionStr = (0, _inspect.inspect)(directiveIntrospection); throw new Error(`Introspection result missing directive locations: ${directiveIntrospectionStr}.`); } @@ -35689,8 +34937,8 @@ function coerceInputValueImpl(inputValue, type, onError, path) { 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. + } // Lists accept a non-list value as a list of one. + return [coerceInputValueImpl(inputValue, itemType, onError, path)]; } if ((0, _definition.isInputObjectType)(type)) { @@ -35712,10 +34960,10 @@ function coerceInputValueImpl(inputValue, type, onError, path) { continue; } coercedValue[field.name] = coerceInputValueImpl(fieldValue, field.type, onError, (0, _Path.addPath)(path, field.name, type.name)); - } - // Ensure every provided field is defined. + } // Ensure every provided field is defined. + for (const fieldName of Object.keys(inputValue)) { - if (fieldDefs[fieldName] == null) { + 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))); } @@ -35734,10 +34982,10 @@ function coerceInputValueImpl(inputValue, type, onError, path) { return coercedValue; } if ((0, _definition.isLeafType)(type)) { - let parseResult; - // Scalars and Enums determine if an input value is valid via parseValue(), + 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) { @@ -35757,6 +35005,7 @@ function coerceInputValueImpl(inputValue, type, onError, path) { } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. + false || (0, _invariant.invariant)(false, 'Unexpected input type: ' + (0, _inspect.inspect)(type)); } @@ -35780,6 +35029,7 @@ var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_mod * 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) { @@ -35806,11 +35056,13 @@ Object.defineProperty(exports, "__esModule", ({ })); exports.extendSchema = extendSchema; exports.extendSchemaImpl = extendSchemaImpl; -var _AccumulatorMap = __webpack_require__(/*! ../jsutils/AccumulatorMap.mjs */ "../../../node_modules/graphql/jsutils/AccumulatorMap.mjs"); +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); +var _keyMap = __webpack_require__(/*! ../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _mapValue = __webpack_require__(/*! ../jsutils/mapValue.mjs */ "../../../node_modules/graphql/jsutils/mapValue.mjs"); var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); +var _predicates = __webpack_require__(/*! ../language/predicates.mjs */ "../../../node_modules/graphql/language/predicates.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); var _directives = __webpack_require__(/*! ../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); var _introspection = __webpack_require__(/*! ../type/introspection.mjs */ "../../../node_modules/graphql/type/introspection.mjs"); @@ -35833,6 +35085,7 @@ var _valueFromAST = __webpack_require__(/*! ./valueFromAST.mjs */ "../../../node */ 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); } @@ -35843,77 +35096,47 @@ function extendSchema(schema, documentAST, options) { /** * @internal */ + function extendSchemaImpl(schemaConfig, documentAST, options) { - var _schemaDef$descriptio, _schemaDef, _schemaDef$descriptio2, _schemaDef2, _options$assumeValid; + var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid; + // Collect the type definitions and extensions found in the document. const typeDefs = []; - const scalarExtensions = new _AccumulatorMap.AccumulatorMap(); - const objectExtensions = new _AccumulatorMap.AccumulatorMap(); - const interfaceExtensions = new _AccumulatorMap.AccumulatorMap(); - const unionExtensions = new _AccumulatorMap.AccumulatorMap(); - const enumExtensions = new _AccumulatorMap.AccumulatorMap(); - const inputObjectExtensions = new _AccumulatorMap.AccumulatorMap(); - // New directives and types are separate because a directives and types can + 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. + let schemaDef; // Schema extensions are collected which may add additional operation types. + const schemaExtensions = []; - let isSchemaChanged = false; for (const def of documentAST.definitions) { - switch (def.kind) { - case _kinds.Kind.SCHEMA_DEFINITION: - schemaDef = def; - break; - case _kinds.Kind.SCHEMA_EXTENSION: - schemaExtensions.push(def); - break; - case _kinds.Kind.DIRECTIVE_DEFINITION: - directiveDefs.push(def); - break; - // Type Definitions - case _kinds.Kind.SCALAR_TYPE_DEFINITION: - case _kinds.Kind.OBJECT_TYPE_DEFINITION: - case _kinds.Kind.INTERFACE_TYPE_DEFINITION: - case _kinds.Kind.UNION_TYPE_DEFINITION: - case _kinds.Kind.ENUM_TYPE_DEFINITION: - case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: - typeDefs.push(def); - break; - // Type System Extensions - case _kinds.Kind.SCALAR_TYPE_EXTENSION: - scalarExtensions.add(def.name.value, def); - break; - case _kinds.Kind.OBJECT_TYPE_EXTENSION: - objectExtensions.add(def.name.value, def); - break; - case _kinds.Kind.INTERFACE_TYPE_EXTENSION: - interfaceExtensions.add(def.name.value, def); - break; - case _kinds.Kind.UNION_TYPE_EXTENSION: - unionExtensions.add(def.name.value, def); - break; - case _kinds.Kind.ENUM_TYPE_EXTENSION: - enumExtensions.add(def.name.value, def); - break; - case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: - inputObjectExtensions.add(def.name.value, def); - break; - default: - continue; + 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); } - isSchemaChanged = true; - } - // If this document contains no new types, extensions, or directives then + } // If this document contains no new types, extensions, or directives then // return the same unmodified GraphQLSchema instance. - if (!isSchemaChanged) { + + if (Object.keys(typeExtensionsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExtensions.length === 0 && schemaDef == null) { return schemaConfig; } - const typeMap = new Map(schemaConfig.types.map(type => [type.name, extendNamedType(type)])); + const typeMap = Object.create(null); + for (const existingType of schemaConfig.types) { + typeMap[existingType.name] = extendNamedType(existingType); + } for (const typeNode of typeDefs) { - var _stdTypeMap$get; + var _stdTypeMap$name; const name = typeNode.name.value; - typeMap.set(name, (_stdTypeMap$get = stdTypeMap.get(name)) !== null && _stdTypeMap$get !== void 0 ? _stdTypeMap$get : buildType(typeNode)); + typeMap[name] = (_stdTypeMap$name = stdTypeMap[name]) !== null && _stdTypeMap$name !== void 0 ? _stdTypeMap$name : buildType(typeNode); } const operationTypes = { // Get the extended root operation types. @@ -35923,20 +35146,20 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { // Then, incorporate schema definition and all schema extensions. ...(schemaDef && getOperationTypes([schemaDef])), ...getOperationTypes(schemaExtensions) - }; - // Then produce and return a Schema config with these types. + }; // Then produce and return a Schema config with these types. + return { - description: (_schemaDef$descriptio = (_schemaDef = schemaDef) === null || _schemaDef === void 0 ? void 0 : (_schemaDef$descriptio2 = _schemaDef.description) === null || _schemaDef$descriptio2 === void 0 ? void 0 : _schemaDef$descriptio2.value) !== null && _schemaDef$descriptio !== void 0 ? _schemaDef$descriptio : schemaConfig.description, + 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: Array.from(typeMap.values()), + types: Object.values(typeMap), directives: [...schemaConfig.directives.map(replaceDirective), ...directiveDefs.map(buildDirective)], - extensions: schemaConfig.extensions, + 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 + }; // 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 @@ -35945,21 +35168,17 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { if ((0, _definition.isNonNullType)(type)) { // @ts-expect-error return new _definition.GraphQLNonNull(replaceType(type.ofType)); - } - // @ts-expect-error FIXME + } // @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.get(type.name); + return typeMap[type.name]; } function replaceDirective(directive) { - if ((0, _directives.isSpecifiedDirective)(directive)) { - // Builtin directives are not extended. - return directive; - } const config = directive.toConfig(); return new _directives.GraphQLDirective({ ...config, @@ -35991,12 +35210,13 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } /* 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 _inputObjectExtension; + var _typeExtensionsMap$co; const config = type.toConfig(); - const extensions = (_inputObjectExtension = inputObjectExtensions.get(config.name)) !== null && _inputObjectExtension !== void 0 ? _inputObjectExtension : []; + const extensions = (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co !== void 0 ? _typeExtensionsMap$co : []; return new _definition.GraphQLInputObjectType({ ...config, fields: () => ({ @@ -36010,9 +35230,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { }); } function extendEnumType(type) { - var _enumExtensions$get; + var _typeExtensionsMap$ty; const config = type.toConfig(); - const extensions = (_enumExtensions$get = enumExtensions.get(type.name)) !== null && _enumExtensions$get !== void 0 ? _enumExtensions$get : []; + const extensions = (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && _typeExtensionsMap$ty !== void 0 ? _typeExtensionsMap$ty : []; return new _definition.GraphQLEnumType({ ...config, values: { @@ -36023,9 +35243,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { }); } function extendScalarType(type) { - var _scalarExtensions$get; + var _typeExtensionsMap$co2; const config = type.toConfig(); - const extensions = (_scalarExtensions$get = scalarExtensions.get(config.name)) !== null && _scalarExtensions$get !== void 0 ? _scalarExtensions$get : []; + 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; @@ -36038,9 +35258,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { }); } function extendObjectType(type) { - var _objectExtensions$get; + var _typeExtensionsMap$co3; const config = type.toConfig(); - const extensions = (_objectExtensions$get = objectExtensions.get(config.name)) !== null && _objectExtensions$get !== void 0 ? _objectExtensions$get : []; + 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)], @@ -36052,9 +35272,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { }); } function extendInterfaceType(type) { - var _interfaceExtensions$; + var _typeExtensionsMap$co4; const config = type.toConfig(); - const extensions = (_interfaceExtensions$ = interfaceExtensions.get(config.name)) !== null && _interfaceExtensions$ !== void 0 ? _interfaceExtensions$ : []; + 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)], @@ -36066,9 +35286,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { }); } function extendUnionType(type) { - var _unionExtensions$get; + var _typeExtensionsMap$co5; const config = type.toConfig(); - const extensions = (_unionExtensions$get = unionExtensions.get(config.name)) !== null && _unionExtensions$get !== void 0 ? _unionExtensions$get : []; + 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)], @@ -36092,8 +35312,10 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { 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 : []; + 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 @@ -36105,9 +35327,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { return opTypes; } function getNamedType(node) { - var _stdTypeMap$get2; + var _stdTypeMap$name2; const name = node.name.value; - const type = (_stdTypeMap$get2 = stdTypeMap.get(name)) !== null && _stdTypeMap$get2 !== void 0 ? _stdTypeMap$get2 : typeMap.get(name); + const type = (_stdTypeMap$name2 = stdTypeMap[name]) !== null && _stdTypeMap$name2 !== void 0 ? _stdTypeMap$name2 : typeMap[name]; if (type === undefined) { throw new Error(`Unknown type: "${name}".`); } @@ -36140,8 +35362,10 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { 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 : []; + 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] = { @@ -36160,10 +35384,12 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } function buildArgumentMap(args) { // FIXME: https://github.com/graphql/graphql-js/issues/2203 - const argsNodes = /* c8 ignore next */args !== null && args !== void 0 ? args : []; + 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. @@ -36182,10 +35408,13 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { 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 : []; + 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. @@ -36205,8 +35434,10 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { 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 : []; + 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] = { @@ -36227,7 +35458,9 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { // 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 : []; + 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) { @@ -36239,16 +35472,19 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { // 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 : []; + 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 _objectExtensions$get2, _astNode$description; - const extensionASTNodes = (_objectExtensions$get2 = objectExtensions.get(name)) !== null && _objectExtensions$get2 !== void 0 ? _objectExtensions$get2 : []; + var _astNode$description; const allNodes = [astNode, ...extensionASTNodes]; return new _definition.GraphQLObjectType({ name, @@ -36261,8 +35497,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } case _kinds.Kind.INTERFACE_TYPE_DEFINITION: { - var _interfaceExtensions$2, _astNode$description2; - const extensionASTNodes = (_interfaceExtensions$2 = interfaceExtensions.get(name)) !== null && _interfaceExtensions$2 !== void 0 ? _interfaceExtensions$2 : []; + var _astNode$description2; const allNodes = [astNode, ...extensionASTNodes]; return new _definition.GraphQLInterfaceType({ name, @@ -36275,8 +35510,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } case _kinds.Kind.ENUM_TYPE_DEFINITION: { - var _enumExtensions$get2, _astNode$description3; - const extensionASTNodes = (_enumExtensions$get2 = enumExtensions.get(name)) !== null && _enumExtensions$get2 !== void 0 ? _enumExtensions$get2 : []; + var _astNode$description3; const allNodes = [astNode, ...extensionASTNodes]; return new _definition.GraphQLEnumType({ name, @@ -36288,8 +35522,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } case _kinds.Kind.UNION_TYPE_DEFINITION: { - var _unionExtensions$get2, _astNode$description4; - const extensionASTNodes = (_unionExtensions$get2 = unionExtensions.get(name)) !== null && _unionExtensions$get2 !== void 0 ? _unionExtensions$get2 : []; + var _astNode$description4; const allNodes = [astNode, ...extensionASTNodes]; return new _definition.GraphQLUnionType({ name, @@ -36301,8 +35534,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } case _kinds.Kind.SCALAR_TYPE_DEFINITION: { - var _scalarExtensions$get2, _astNode$description5; - const extensionASTNodes = (_scalarExtensions$get2 = scalarExtensions.get(name)) !== null && _scalarExtensions$get2 !== void 0 ? _scalarExtensions$get2 : []; + var _astNode$description5; return new _definition.GraphQLScalarType({ name, description: (_astNode$description5 = astNode.description) === null || _astNode$description5 === void 0 ? void 0 : _astNode$description5.value, @@ -36313,8 +35545,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: { - var _inputObjectExtension2, _astNode$description6; - const extensionASTNodes = (_inputObjectExtension2 = inputObjectExtensions.get(name)) !== null && _inputObjectExtension2 !== void 0 ? _inputObjectExtension2 : []; + var _astNode$description6; const allNodes = [astNode, ...extensionASTNodes]; return new _definition.GraphQLInputObjectType({ name, @@ -36328,27 +35559,30 @@ function extendSchemaImpl(schemaConfig, documentAST, options) { } } } -const stdTypeMap = new Map([..._scalars.specifiedScalarTypes, ..._introspection.introspectionTypes].map(type => [type.name, type])); +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` + 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` + const specifiedBy = (0, _values.getDirectiveValues)(_directives.GraphQLSpecifiedByDirective, node); // @ts-expect-error validated by `getDirectiveValues` + return specifiedBy === null || specifiedBy === void 0 ? void 0 : specifiedBy.url; } /** * Given an input object node, returns if the node should be OneOf. */ + function isOneOf(node) { return Boolean((0, _values.getDirectiveValues)(_directives.GraphQLOneOfDirective, node)); } @@ -36417,6 +35651,7 @@ function findBreakingChanges(oldSchema, newSchema) { * 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); @@ -36685,8 +35920,8 @@ function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { // 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 they're both named types, see if their names are equivalent + return (0, _definition.isNamedType)(newType) && oldType.name === newType.name; } function typeKindName(type) { @@ -36710,6 +35945,7 @@ function typeKindName(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) { @@ -36912,6 +36148,7 @@ var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_mod * 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) { @@ -36935,6 +36172,59 @@ function getOperationAST(documentAST, operationName) { /***/ }), +/***/ "../../../node_modules/graphql/utilities/getOperationRootType.mjs": +/*!************************************************************************!*\ + !*** ../../../node_modules/graphql/utilities/getOperationRootType.mjs ***! + \************************************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports.getOperationRootType = getOperationRootType; +var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); +/** + * 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 + }); +} + +/***/ }), + /***/ "../../../node_modules/graphql/utilities/index.mjs": /*!*********************************************************!*\ !*** ../../../node_modules/graphql/utilities/index.mjs ***! @@ -36964,6 +36254,12 @@ Object.defineProperty(exports, "TypeInfo", ({ return _TypeInfo.TypeInfo; } })); +Object.defineProperty(exports, "assertValidName", ({ + enumerable: true, + get: function () { + return _assertValidName.assertValidName; + } +})); Object.defineProperty(exports, "astFromValue", ({ enumerable: true, get: function () { @@ -37036,6 +36332,12 @@ Object.defineProperty(exports, "getOperationAST", ({ return _getOperationAST.getOperationAST; } })); +Object.defineProperty(exports, "getOperationRootType", ({ + enumerable: true, + get: function () { + return _getOperationRootType.getOperationRootType; + } +})); Object.defineProperty(exports, "introspectionFromSchema", ({ enumerable: true, get: function () { @@ -37054,18 +36356,18 @@ Object.defineProperty(exports, "isTypeSubTypeOf", ({ 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, "printDirective", ({ - enumerable: true, - get: function () { - return _printSchema.printDirective; - } -})); Object.defineProperty(exports, "printIntrospectionSchema", ({ enumerable: true, get: function () { @@ -37122,6 +36424,7 @@ Object.defineProperty(exports, "visitWithTypeInfo", ({ })); var _getIntrospectionQuery = __webpack_require__(/*! ./getIntrospectionQuery.mjs */ "../../../node_modules/graphql/utilities/getIntrospectionQuery.mjs"); var _getOperationAST = __webpack_require__(/*! ./getOperationAST.mjs */ "../../../node_modules/graphql/utilities/getOperationAST.mjs"); +var _getOperationRootType = __webpack_require__(/*! ./getOperationRootType.mjs */ "../../../node_modules/graphql/utilities/getOperationRootType.mjs"); var _introspectionFromSchema = __webpack_require__(/*! ./introspectionFromSchema.mjs */ "../../../node_modules/graphql/utilities/introspectionFromSchema.mjs"); var _buildClientSchema = __webpack_require__(/*! ./buildClientSchema.mjs */ "../../../node_modules/graphql/utilities/buildClientSchema.mjs"); var _buildASTSchema = __webpack_require__(/*! ./buildASTSchema.mjs */ "../../../node_modules/graphql/utilities/buildASTSchema.mjs"); @@ -37138,6 +36441,7 @@ var _concatAST = __webpack_require__(/*! ./concatAST.mjs */ "../../../node_modul var _separateOperations = __webpack_require__(/*! ./separateOperations.mjs */ "../../../node_modules/graphql/utilities/separateOperations.mjs"); var _stripIgnoredCharacters = __webpack_require__(/*! ./stripIgnoredCharacters.mjs */ "../../../node_modules/graphql/utilities/stripIgnoredCharacters.mjs"); var _typeComparators = __webpack_require__(/*! ./typeComparators.mjs */ "../../../node_modules/graphql/utilities/typeComparators.mjs"); +var _assertValidName = __webpack_require__(/*! ./assertValidName.mjs */ "../../../node_modules/graphql/utilities/assertValidName.mjs"); var _findBreakingChanges = __webpack_require__(/*! ./findBreakingChanges.mjs */ "../../../node_modules/graphql/utilities/findBreakingChanges.mjs"); /***/ }), @@ -37167,6 +36471,7 @@ var _getIntrospectionQuery = __webpack_require__(/*! ./getIntrospectionQuery.mjs * 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, @@ -37181,7 +36486,7 @@ function introspectionFromSchema(schema, options) { schema, document }); - result.errors == null && result.data != null || (0, _invariant.invariant)(false); + !result.errors && result.data || (0, _invariant.invariant)(false); return result.data; } @@ -37201,6 +36506,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.lexicographicSortSchema = lexicographicSortSchema; var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); +var _keyValMap = __webpack_require__(/*! ../jsutils/keyValMap.mjs */ "../../../node_modules/graphql/jsutils/keyValMap.mjs"); var _naturalCompare = __webpack_require__(/*! ../jsutils/naturalCompare.mjs */ "../../../node_modules/graphql/jsutils/naturalCompare.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); var _directives = __webpack_require__(/*! ../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); @@ -37211,12 +36517,13 @@ var _schema = __webpack_require__(/*! ../type/schema.mjs */ "../../../node_modul * * This function returns a sorted copy of the given GraphQLSchema. */ + function lexicographicSortSchema(schema) { const schemaConfig = schema.toConfig(); - const typeMap = new Map(sortByName(schemaConfig.types).map(type => [type.name, sortNamedType(type)])); + const typeMap = (0, _keyValMap.keyValMap)(sortByName(schemaConfig.types), type => type.name, sortNamedType); return new _schema.GraphQLSchema({ ...schemaConfig, - types: Array.from(typeMap.values()), + types: Object.values(typeMap), directives: sortByName(schemaConfig.directives).map(sortDirective), query: replaceMaybeType(schemaConfig.query), mutation: replaceMaybeType(schemaConfig.mutation), @@ -37229,12 +36536,12 @@ function lexicographicSortSchema(schema) { } else if ((0, _definition.isNonNullType)(type)) { // @ts-expect-error return new _definition.GraphQLNonNull(replaceType(type.ofType)); - } - // @ts-expect-error FIXME: TS Conversion + } // @ts-expect-error FIXME: TS Conversion + return replaceNamedType(type); } function replaceNamedType(type) { - return typeMap.get(type.name); + return typeMap[type.name]; } function replaceMaybeType(maybeType) { return maybeType && replaceNamedType(maybeType); @@ -37312,6 +36619,7 @@ function lexicographicSortSchema(schema) { } /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. + false || (0, _invariant.invariant)(false, 'Unexpected type: ' + (0, _inspect.inspect)(type)); } } @@ -37346,7 +36654,6 @@ function sortBy(array, mapToKey) { Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.printDirective = printDirective; exports.printIntrospectionSchema = printIntrospectionSchema; exports.printSchema = printSchema; exports.printType = printType; @@ -37375,19 +36682,23 @@ function printFilteredSchema(schema, directiveFilter, typeFilter) { return [printSchemaDefinition(schema), ...directives.map(directive => printDirective(directive)), ...types.map(type => printType(type))].filter(Boolean).join('\n\n'); } function printSchemaDefinition(schema) { - const queryType = schema.getQueryType(); - const mutationType = schema.getMutationType(); - const subscriptionType = schema.getSubscriptionType(); - // Special case: When a schema has no root operation types, no valid schema - // definition can be printed. - if (!queryType && !mutationType && !subscriptionType) { + if (schema.description == null && isSchemaOfCommonNames(schema)) { return; } - // Only print a schema definition if there is a description or if it should - // not be omitted because of having default type names. - if (schema.description != null || !hasDefaultRootOperationTypes(schema)) { - return printDescription(schema) + 'schema {\n' + (queryType ? ` query: ${queryType.name}\n` : '') + (mutationType ? ` mutation: ${mutationType.name}\n` : '') + (subscriptionType ? ` subscription: ${subscriptionType.name}\n` : '') + '}'; + 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 @@ -37402,16 +36713,23 @@ function printSchemaDefinition(schema) { * } * ``` * - * When using this naming convention, the schema description can be omitted so - * long as these names are only used for operation types. - * - * Note however that if any of these default names are used elsewhere in the - * schema but not as a root operation type, the schema definition must still - * be printed to avoid ambiguity. + * When using this naming convention, the schema description can be omitted. */ -function hasDefaultRootOperationTypes(schema) { - /* eslint-disable eqeqeq */ - return schema.getQueryType() == schema.getType('Query') && schema.getMutationType() == schema.getType('Mutation') && schema.getSubscriptionType() == schema.getType('Subscription'); + +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)) { @@ -37434,6 +36752,7 @@ function printType(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) { @@ -37472,9 +36791,9 @@ function printBlock(items) { 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 == null)) { + } // 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 + ')'; @@ -37526,7 +36845,7 @@ function printDescription(def, indentation = '', firstInBlock = true) { block: (0, _blockString.isPrintableAsBlockString)(description) }); const prefix = indentation && !firstInBlock ? '\n' + indentation : indentation; - return prefix + blockString.replaceAll('\n', '\n' + indentation) + '\n'; + return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; } /***/ }), @@ -37551,10 +36870,11 @@ var _visitor = __webpack_require__(/*! ../language/visitor.mjs */ "../../../node * 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. + 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: @@ -37563,22 +36883,21 @@ function separateOperations(documentAST) { case _kinds.Kind.FRAGMENT_DEFINITION: depGraph[definitionNode.name.value] = collectDependencies(definitionNode.selectionSet); break; - default: - // ignore non-executable definitions + default: // ignore non-executable definitions } - } - // For each operation, produce a new synthesized AST which includes only what + } // 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 + } // 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)) @@ -37586,6 +36905,7 @@ function separateOperations(documentAST) { } return separatedDocumentASTs; } + // From a dependency graph, collects a list of transitive dependencies by // recursing through a dependency graph. function collectTransitiveDependencies(collected, depGraph, fromName) { @@ -37632,6 +36952,7 @@ var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_mod * * @internal */ + function sortValueNode(valueNode) { switch (valueNode.kind) { case _kinds.Kind.OBJECT: @@ -37739,6 +37060,7 @@ var _tokenKind = __webpack_require__(/*! ../language/tokenKind.mjs */ "../../../ * """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; @@ -37753,6 +37075,7 @@ function stripIgnoredCharacters(source) { * 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) { @@ -37796,28 +37119,29 @@ 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 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 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. + } // 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 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); @@ -37827,8 +37151,8 @@ function isTypeSubTypeOf(schema, maybeSubType, superType) { 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 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); @@ -37838,9 +37162,9 @@ function isTypeSubTypeOf(schema, maybeSubType, superType) { 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. + } // 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); } /** @@ -37852,6 +37176,7 @@ function isTypeSubTypeOf(schema, maybeSubType, superType) { * * This function is commutative. */ + function doTypesOverlap(schema, typeA, typeB) { // Equivalent types overlap if (typeA === typeB) { @@ -37862,15 +37187,15 @@ function doTypesOverlap(schema, typeA, 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. + } // 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. + } // Otherwise the types do not overlap. + return false; } @@ -37923,6 +37248,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.valueFromAST = valueFromAST; var _inspect = __webpack_require__(/*! ../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); var _invariant = __webpack_require__(/*! ../jsutils/invariant.mjs */ "../../../node_modules/graphql/jsutils/invariant.mjs"); +var _keyMap = __webpack_require__(/*! ../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); /** @@ -37945,6 +37271,7 @@ var _definition = __webpack_require__(/*! ../type/definition.mjs */ "../../../no * | NullValue | null | * */ + function valueFromAST(valueNode, type, variables) { if (!valueNode) { // When there is no node, then there is also no value. @@ -37960,10 +37287,10 @@ function valueFromAST(valueNode, type, variables) { 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. + } // 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)) { @@ -38009,10 +37336,10 @@ function valueFromAST(valueNode, type, variables) { return; // Invalid: intentionally return no value. } const coercedObj = Object.create(null); - const fieldNodes = new Map(valueNode.fields.map(field => [field.name.value, field])); + const fieldNodes = (0, _keyMap.keyMap)(valueNode.fields, field => field.name.value); for (const field of Object.values(type.getFields())) { - const fieldNode = fieldNodes.get(field.name); - if (fieldNode == null || isMissingVariable(fieldNode.value, variables)) { + 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)) { @@ -38054,10 +37381,11 @@ function valueFromAST(valueNode, type, variables) { } /* 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 +} // 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); } @@ -38094,6 +37422,7 @@ var _kinds = __webpack_require__(/*! ../language/kinds.mjs */ "../../../node_mod * | Null | null | * */ + function valueFromASTUntyped(valueNode, variables) { switch (valueNode.kind) { case _kinds.Kind.NULL: @@ -38192,14 +37521,14 @@ class ASTValidationContext { let fragments = this._recursivelyReferencedFragments.get(operation); if (!fragments) { fragments = []; - const collectedNames = new Set(); + 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.has(fragName)) { - collectedNames.add(fragName); + if (collectedNames[fragName] !== true) { + collectedNames[fragName] = true; const fragment = this.getFragment(fragName); if (fragment) { fragments.push(fragment); @@ -38312,24 +37641,6 @@ exports.ValidationContext = ValidationContext; Object.defineProperty(exports, "__esModule", ({ value: true })); -Object.defineProperty(exports, "DeferStreamDirectiveLabelRule", ({ - enumerable: true, - get: function () { - return _DeferStreamDirectiveLabelRule.DeferStreamDirectiveLabelRule; - } -})); -Object.defineProperty(exports, "DeferStreamDirectiveOnRootFieldRule", ({ - enumerable: true, - get: function () { - return _DeferStreamDirectiveOnRootFieldRule.DeferStreamDirectiveOnRootFieldRule; - } -})); -Object.defineProperty(exports, "DeferStreamDirectiveOnValidOperationsRule", ({ - enumerable: true, - get: function () { - return _DeferStreamDirectiveOnValidOperationsRule.DeferStreamDirectiveOnValidOperationsRule; - } -})); Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ enumerable: true, get: function () { @@ -38462,12 +37773,6 @@ Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ return _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule; } })); -Object.defineProperty(exports, "StreamDirectiveOnListFieldRule", ({ - enumerable: true, - get: function () { - return _StreamDirectiveOnListFieldRule.StreamDirectiveOnListFieldRule; - } -})); Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ enumerable: true, get: function () { @@ -38585,9 +37890,6 @@ Object.defineProperty(exports, "validate", ({ var _validate = __webpack_require__(/*! ./validate.mjs */ "../../../node_modules/graphql/validation/validate.mjs"); var _ValidationContext = __webpack_require__(/*! ./ValidationContext.mjs */ "../../../node_modules/graphql/validation/ValidationContext.mjs"); var _specifiedRules = __webpack_require__(/*! ./specifiedRules.mjs */ "../../../node_modules/graphql/validation/specifiedRules.mjs"); -var _DeferStreamDirectiveLabelRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveLabelRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveLabelRule.mjs"); -var _DeferStreamDirectiveOnRootFieldRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveOnRootFieldRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs"); -var _DeferStreamDirectiveOnValidOperationsRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveOnValidOperationsRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs"); var _ExecutableDefinitionsRule = __webpack_require__(/*! ./rules/ExecutableDefinitionsRule.mjs */ "../../../node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs"); var _FieldsOnCorrectTypeRule = __webpack_require__(/*! ./rules/FieldsOnCorrectTypeRule.mjs */ "../../../node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs"); var _FragmentsOnCompositeTypesRule = __webpack_require__(/*! ./rules/FragmentsOnCompositeTypesRule.mjs */ "../../../node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs"); @@ -38605,7 +37907,6 @@ var _PossibleFragmentSpreadsRule = __webpack_require__(/*! ./rules/PossibleFragm var _ProvidedRequiredArgumentsRule = __webpack_require__(/*! ./rules/ProvidedRequiredArgumentsRule.mjs */ "../../../node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs"); var _ScalarLeafsRule = __webpack_require__(/*! ./rules/ScalarLeafsRule.mjs */ "../../../node_modules/graphql/validation/rules/ScalarLeafsRule.mjs"); var _SingleFieldSubscriptionsRule = __webpack_require__(/*! ./rules/SingleFieldSubscriptionsRule.mjs */ "../../../node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs"); -var _StreamDirectiveOnListFieldRule = __webpack_require__(/*! ./rules/StreamDirectiveOnListFieldRule.mjs */ "../../../node_modules/graphql/validation/rules/StreamDirectiveOnListFieldRule.mjs"); var _UniqueArgumentNamesRule = __webpack_require__(/*! ./rules/UniqueArgumentNamesRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs"); var _UniqueDirectivesPerLocationRule = __webpack_require__(/*! ./rules/UniqueDirectivesPerLocationRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs"); var _UniqueFragmentNamesRule = __webpack_require__(/*! ./rules/UniqueFragmentNamesRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueFragmentNamesRule.mjs"); @@ -38629,182 +37930,6 @@ var _NoSchemaIntrospectionCustomRule = __webpack_require__(/*! ./rules/custom/No /***/ }), -/***/ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveLabelRule.mjs": -/*!****************************************************************************************!*\ - !*** ../../../node_modules/graphql/validation/rules/DeferStreamDirectiveLabelRule.mjs ***! - \****************************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.DeferStreamDirectiveLabelRule = DeferStreamDirectiveLabelRule; -var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); -var _kinds = __webpack_require__(/*! ../../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); -var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); -/** - * Defer and stream directive labels are unique - * - * A GraphQL document is only valid if defer and stream directives' label argument is static and unique. - */ -function DeferStreamDirectiveLabelRule(context) { - const knownLabels = new Map(); - return { - Directive(node) { - if (node.name.value === _directives.GraphQLDeferDirective.name || node.name.value === _directives.GraphQLStreamDirective.name) { - var _node$arguments; - const labelArgument = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments.find(arg => arg.name.value === 'label'); - const labelValue = labelArgument === null || labelArgument === void 0 ? void 0 : labelArgument.value; - if (!labelValue) { - return; - } - if (labelValue.kind !== _kinds.Kind.STRING) { - context.reportError(new _GraphQLError.GraphQLError(`Directive "${node.name.value}"'s label argument must be a static string.`, { - nodes: node - })); - return; - } - const knownLabel = knownLabels.get(labelValue.value); - if (knownLabel != null) { - context.reportError(new _GraphQLError.GraphQLError('Defer/Stream directive label argument must be unique.', { - nodes: [knownLabel, node] - })); - } else { - knownLabels.set(labelValue.value, node); - } - } - } - }; -} - -/***/ }), - -/***/ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs": -/*!**********************************************************************************************!*\ - !*** ../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs ***! - \**********************************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.DeferStreamDirectiveOnRootFieldRule = DeferStreamDirectiveOnRootFieldRule; -var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); -var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); -/** - * Defer and stream directives are used on valid root field - * - * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. - */ -function DeferStreamDirectiveOnRootFieldRule(context) { - return { - Directive(node) { - const mutationType = context.getSchema().getMutationType(); - const subscriptionType = context.getSchema().getSubscriptionType(); - const parentType = context.getParentType(); - if (parentType && node.name.value === _directives.GraphQLDeferDirective.name) { - if (mutationType && parentType === mutationType) { - context.reportError(new _GraphQLError.GraphQLError(`Defer directive cannot be used on root mutation type "${parentType.name}".`, { - nodes: node - })); - } - if (subscriptionType && parentType === subscriptionType) { - context.reportError(new _GraphQLError.GraphQLError(`Defer directive cannot be used on root subscription type "${parentType.name}".`, { - nodes: node - })); - } - } - if (parentType && node.name.value === _directives.GraphQLStreamDirective.name) { - if (mutationType && parentType === mutationType) { - context.reportError(new _GraphQLError.GraphQLError(`Stream directive cannot be used on root mutation type "${parentType.name}".`, { - nodes: node - })); - } - if (subscriptionType && parentType === subscriptionType) { - context.reportError(new _GraphQLError.GraphQLError(`Stream directive cannot be used on root subscription type "${parentType.name}".`, { - nodes: node - })); - } - } - } - }; -} - -/***/ }), - -/***/ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs": -/*!****************************************************************************************************!*\ - !*** ../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs ***! - \****************************************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.DeferStreamDirectiveOnValidOperationsRule = DeferStreamDirectiveOnValidOperationsRule; -var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); -var _ast = __webpack_require__(/*! ../../language/ast.mjs */ "../../../node_modules/graphql/language/ast.mjs"); -var _kinds = __webpack_require__(/*! ../../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); -var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); -function ifArgumentCanBeFalse(node) { - var _node$arguments; - const ifArgument = (_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments.find(arg => arg.name.value === 'if'); - if (!ifArgument) { - return false; - } - if (ifArgument.value.kind === _kinds.Kind.BOOLEAN) { - if (ifArgument.value.value) { - return false; - } - } else if (ifArgument.value.kind !== _kinds.Kind.VARIABLE) { - return false; - } - return true; -} -/** - * Defer And Stream Directives Are Used On Valid Operations - * - * A GraphQL document is only valid if defer directives are not used on root mutation or subscription types. - */ -function DeferStreamDirectiveOnValidOperationsRule(context) { - const fragmentsUsedOnSubscriptions = new Set(); - return { - OperationDefinition(operation) { - if (operation.operation === _ast.OperationTypeNode.SUBSCRIPTION) { - for (const fragment of context.getRecursivelyReferencedFragments(operation)) { - fragmentsUsedOnSubscriptions.add(fragment.name.value); - } - } - }, - Directive(node, _key, _parent, _path, ancestors) { - const definitionNode = ancestors[2]; - if ('kind' in definitionNode && (definitionNode.kind === _kinds.Kind.FRAGMENT_DEFINITION && fragmentsUsedOnSubscriptions.has(definitionNode.name.value) || definitionNode.kind === _kinds.Kind.OPERATION_DEFINITION && definitionNode.operation === _ast.OperationTypeNode.SUBSCRIPTION)) { - if (node.name.value === _directives.GraphQLDeferDirective.name) { - if (!ifArgumentCanBeFalse(node)) { - context.reportError(new _GraphQLError.GraphQLError('Defer directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.', { - nodes: node - })); - } - } else if (node.name.value === _directives.GraphQLStreamDirective.name) { - if (!ifArgumentCanBeFalse(node)) { - context.reportError(new _GraphQLError.GraphQLError('Stream directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.', { - nodes: node - })); - } - } - } - } - }; -} - -/***/ }), - /***/ "../../../node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs": /*!************************************************************************************!*\ !*** ../../../node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs ***! @@ -38880,14 +38005,14 @@ function FieldsOnCorrectTypeRule(context) { 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? + 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. + } // Report an error, including helpful suggestions. + context.reportError(new _GraphQLError.GraphQLError(`Cannot query field "${fieldName}" on type "${type.name}".` + suggestion, { nodes: node })); @@ -38901,6 +38026,7 @@ function FieldsOnCorrectTypeRule(context) { * 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. @@ -38909,18 +38035,18 @@ function getSuggestedTypeNames(schema, type, fieldName) { const suggestedTypes = new Set(); const usageCount = Object.create(null); for (const possibleType of schema.getPossibleTypes(type)) { - if (possibleType.getFields()[fieldName] == null) { + if (!possibleType.getFields()[fieldName]) { continue; - } - // This object type defines this field. + } // 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] == null) { + if (!possibleInterface.getFields()[fieldName]) { continue; - } - // This interface type defines this field. + } // 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; } @@ -38930,8 +38056,8 @@ function getSuggestedTypeNames(schema, type, fieldName) { const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; if (usageCountDiff !== 0) { return usageCountDiff; - } - // Suggest super types first followed by subtypes + } // Suggest super types first followed by subtypes + if ((0, _definition.isInterfaceType)(typeA) && schema.isSubType(typeA, typeB)) { return -1; } @@ -38945,12 +38071,13 @@ function getSuggestedTypeNames(schema, type, fieldName) { * 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. + } // Otherwise, must be a Union type, which does not define fields. + return []; } @@ -39058,28 +38185,31 @@ function KnownArgumentNamesRule(context) { /** * @internal */ + function KnownArgumentNamesOnDirectivesRule(context) { - const directiveArgs = new Map(); + const directiveArgs = Object.create(null); const schema = context.getSchema(); const definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives; for (const directive of definedDirectives) { - directiveArgs.set(directive.name, directive.args.map(arg => arg.name)); + 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.set(def.name.value, argsNodes.map(arg => arg.name.value)); + directiveArgs[def.name.value] = argsNodes.map(arg => arg.name.value); } } return { Directive(directiveNode) { const directiveName = directiveNode.name.value; - const knownArgs = directiveArgs.get(directiveName); - if (directiveNode.arguments != null && knownArgs != null) { + const knownArgs = directiveArgs[directiveName]; + if (directiveNode.arguments && knownArgs) { for (const argNode of directiveNode.arguments) { const argName = argNode.name.value; if (!knownArgs.includes(argName)) { @@ -39125,30 +38255,30 @@ var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../.. * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined */ function KnownDirectivesRule(context) { - const locationsMap = new Map(); + const locationsMap = Object.create(null); const schema = context.getSchema(); const definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives; for (const directive of definedDirectives) { - locationsMap.set(directive.name, directive.locations); + locationsMap[directive.name] = directive.locations; } const astDefinitions = context.getDocument().definitions; for (const def of astDefinitions) { if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - locationsMap.set(def.name.value, def.locations.map(name => name.value)); + 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.get(name); - if (locations == null) { + const locations = locationsMap[name]; + if (!locations) { context.reportError(new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, { nodes: node })); return; } const candidateLocation = getDirectiveLocationForASTPath(ancestors); - if (candidateLocation != null && !locations.includes(candidateLocation)) { + if (candidateLocation && !locations.includes(candidateLocation)) { context.reportError(new _GraphQLError.GraphQLError(`Directive "@${name}" may not be used on ${candidateLocation}.`, { nodes: node })); @@ -39157,8 +38287,8 @@ function KnownDirectivesRule(context) { }; } function getDirectiveLocationForASTPath(ancestors) { - const appliedTo = ancestors.at(-1); - appliedTo != null && 'kind' in appliedTo || (0, _invariant.invariant)(false); + 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); @@ -39199,12 +38329,14 @@ function getDirectiveLocationForASTPath(ancestors) { return _directiveLocation.DirectiveLocation.INPUT_OBJECT; case _kinds.Kind.INPUT_VALUE_DEFINITION: { - const parentNode = ancestors.at(-3); - parentNode != null && 'kind' in parentNode || (0, _invariant.invariant)(false); + 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 2 */ + + /* c8 ignore next */ + default: false || (0, _invariant.invariant)(false, 'Unexpected kind: ' + (0, _inspect.inspect)(appliedTo.kind)); } @@ -39286,23 +38418,26 @@ var _scalars = __webpack_require__(/*! ../../type/scalars.mjs */ "../../../node_ * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence */ function KnownTypeNamesRule(context) { - var _context$getSchema$ge, _context$getSchema; - const { - definitions - } = context.getDocument(); - const existingTypesMap = (_context$getSchema$ge = (_context$getSchema = context.getSchema()) === null || _context$getSchema === void 0 ? void 0 : _context$getSchema.getTypeMap()) !== null && _context$getSchema$ge !== void 0 ? _context$getSchema$ge : {}; - const typeNames = new Set([...Object.keys(existingTypesMap), ...definitions.filter(_predicates.isTypeDefinitionNode).map(def => def.name.value)]); + 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 (!typeNames.has(typeName)) { + 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.has(typeName)) { + if (isSDL && standardTypeNames.includes(typeName)) { return; } - const suggestedTypes = (0, _suggestionList.suggestionList)(typeName, isSDL ? [...standardTypeNames, ...typeNames] : [...typeNames]); + 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 })); @@ -39310,7 +38445,7 @@ function KnownTypeNamesRule(context) { } }; } -const standardTypeNames = new Set([..._scalars.specifiedScalarTypes, ..._introspection.introspectionTypes].map(type => type.name)); +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)); } @@ -39429,14 +38564,14 @@ function MaxIntrospectionDepthRule(context) { } const fragment = context.getFragment(fragmentName); if (!fragment) { - // Missing fragments checks are handled by the `KnownFragmentNamesRule`. + // Missing fragments checks are handled by `KnownFragmentNamesRule`. return false; - } - // Rather than following an immutable programming pattern which has + } // Rather than following an immutable programming pattern which has // significant memory and garbage collection overhead, we've opted to // take a mutable approach for efficiency's sake. Importantly visiting a // fragment twice is fine, so long as you don't do one visit inside the // other. + try { visitedFragments[fragmentName] = true; return checkDepth(fragment, visitedFragments, depth); @@ -39446,15 +38581,14 @@ function MaxIntrospectionDepthRule(context) { } if (node.kind === _kinds.Kind.FIELD && ( // check all introspection lists - // TODO: instead of relying on field names, check whether the type is a list node.name.value === 'fields' || node.name.value === 'interfaces' || node.name.value === 'possibleTypes' || node.name.value === 'inputFields')) { // eslint-disable-next-line no-param-reassign depth++; if (depth >= MAX_LISTS_DEPTH) { return true; } - } - // handles fields and inline fragments + } // handles fields and inline fragments + if ('selectionSet' in node && node.selectionSet) { for (const child of node.selectionSet.selections) { if (checkDepth(child, visitedFragments, depth)) { @@ -39504,10 +38638,10 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ function NoFragmentCyclesRule(context) { // Tracks already visited fragments to maintain O(N) and to ensure that cycles // are not redundantly reported. - const visitedFrags = new Set(); - // Array of AST nodes used to produce meaningful errors - const spreadPath = []; - // Position in the spread path + 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, @@ -39515,16 +38649,16 @@ function NoFragmentCyclesRule(context) { detectCycleRecursive(node); return false; } - }; - // This does a straight-forward DFS to find cycles. + }; // 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.has(fragment.name.value)) { + if (visitedFrags[fragment.name.value]) { return; } const fragmentName = fragment.name.value; - visitedFrags.add(fragmentName); + visitedFrags[fragmentName] = true; const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); if (spreadNodes.length === 0) { return; @@ -39576,21 +38710,28 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined */ function NoUndefinedVariablesRule(context) { + let variableNameDefined = Object.create(null); return { - OperationDefinition(operation) { - var _operation$variableDe; - const variableNameDefined = new Set((_operation$variableDe = operation.variableDefinitions) === null || _operation$variableDe === void 0 ? void 0 : _operation$variableDe.map(node => node.variable.name.value)); - const usages = context.getRecursiveVariableUsages(operation); - for (const { - node - } of usages) { - const varName = node.name.value; - if (!variableNameDefined.has(varName)) { - 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] - })); + 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; } }; } @@ -39619,13 +38760,11 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used */ function NoUnusedFragmentsRule(context) { - const fragmentNameUsed = new Set(); + const operationDefs = []; const fragmentDefs = []; return { - OperationDefinition(operation) { - for (const fragment of context.getRecursivelyReferencedFragments(operation)) { - fragmentNameUsed.add(fragment.name.value); - } + OperationDefinition(node) { + operationDefs.push(node); return false; }, FragmentDefinition(node) { @@ -39634,9 +38773,15 @@ function NoUnusedFragmentsRule(context) { }, 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.has(fragName)) { + if (fragmentNameUsed[fragName] !== true) { context.reportError(new _GraphQLError.GraphQLError(`Fragment "${fragName}" is never used.`, { nodes: fragmentDef })); @@ -39671,24 +38816,32 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * See https://spec.graphql.org/draft/#sec-All-Variables-Used */ function NoUnusedVariablesRule(context) { + let variableDefs = []; return { - OperationDefinition(operation) { - var _operation$variableDe; - const usages = context.getRecursiveVariableUsages(operation); - const variableNameUsed = new Set(usages.map(({ - node - }) => node.name.value)); - // 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 : []; - for (const variableDef of variableDefinitions) { - const variableName = variableDef.variable.name.value; - if (!variableNameUsed.has(variableName)) { - context.reportError(new _GraphQLError.GraphQLError(operation.name ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` : `Variable "$${variableName}" is never used.`, { - nodes: variableDef - })); + 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); } }; } @@ -39714,9 +38867,6 @@ var _printer = __webpack_require__(/*! ../../language/printer.mjs */ "../../../n var _definition = __webpack_require__(/*! ../../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); var _sortValueNode = __webpack_require__(/*! ../../utilities/sortValueNode.mjs */ "../../../node_modules/graphql/utilities/sortValueNode.mjs"); var _typeFromAST = __webpack_require__(/*! ../../utilities/typeFromAST.mjs */ "../../../node_modules/graphql/utilities/typeFromAST.mjs"); -/* eslint-disable max-params */ -// This file contains a lot of such errors but we plan to refactor it anyway -// so just disable it for entire file. function reasonMessage(reason) { if (Array.isArray(reason)) { return reason.map(([responseName, subReason]) => `subfields "${responseName}" conflict because ` + reasonMessage(subReason)).join(' and '); @@ -39732,14 +38882,15 @@ function reasonMessage(reason) { * * 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 + 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) { @@ -39753,6 +38904,7 @@ function OverlappingFieldsCanBeMergedRule(context) { } }; } + /** * Algorithm: * @@ -39812,43 +38964,43 @@ function OverlappingFieldsCanBeMergedRule(context) { // 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. + 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 + 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 +} // 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. + 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 + } // (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 + + 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)) { @@ -39857,15 +39009,15 @@ function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFiel comparedFragmentPairs.add(referencedFragmentName, fragmentName, areMutuallyExclusive); collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, referencedFragmentName); } -} -// Collect all conflicts found between two fragments, including via spreading in +} // 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. + } // Memoize so two fragments are not compared for conflicts more than once. + if (comparedFragmentPairs.has(fragmentName1, fragmentName2, areMutuallyExclusive)) { return; } @@ -39876,57 +39028,57 @@ function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFra 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 + 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 + + 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 + } // (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 +} // 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 + 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 + } // (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 + } // (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. +} // 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 fieldMap.entries()) { + 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. @@ -39943,21 +39095,21 @@ function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames } } } -} -// Collect all Conflicts between two collections of fields. This is similar to, +} // 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 fieldMap1.entries()) { - const fields2 = fieldMap2.get(responseName); - if (fields2 != null) { + 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); @@ -39968,14 +39120,12 @@ function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentName } } } -} -// Determines if there is a conflict between two particular fields, including +} // Determines if there is a conflict between two particular fields, including // comparing their sub-fields. + function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, field2) { - var _node1$directives, _node2$directives; const [parentType1, node1, def1] = field1; - const [parentType2, node2, def2] = field2; - // If it is known that two fields could not possibly apply at the same + 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. @@ -39983,6 +39133,7 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai // 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. @@ -39990,27 +39141,21 @@ function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPai 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. + } // Two field calls must have the same arguments. + if (!sameArguments(node1, node2)) { return [[responseName, 'they have differing arguments'], [node1], [node2]]; } - } - // FIXME https://github.com/graphql/graphql-js/issues/2203 - const directives1 = /* c8 ignore next */(_node1$directives = node1.directives) !== null && _node1$directives !== void 0 ? _node1$directives : []; - const directives2 = /* c8 ignore next */(_node2$directives = node2.directives) !== null && _node2$directives !== void 0 ? _node2$directives : []; - if (!sameStreams(directives1, directives2)) { - return [[responseName, 'they have differing stream directives'], [node1], [node2]]; - } - // The return type for each field. + } // 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 + } // 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) { @@ -40027,8 +39172,12 @@ function sameArguments(node1, node2) { if (args2 === undefined || args2.length === 0) { return false; } + /* c8 ignore next */ + if (args1.length !== args2.length) { + /* c8 ignore next */ return false; + /* c8 ignore next */ } const values2 = new Map(args2.map(({ name, @@ -40045,26 +39194,10 @@ function sameArguments(node1, node2) { } function stringifyValue(value) { return (0, _printer.print)((0, _sortValueNode.sortValueNode)(value)); -} -function getStreamDirective(directives) { - return directives.find(directive => directive.name.value === 'stream'); -} -function sameStreams(directives1, directives2) { - const stream1 = getStreamDirective(directives1); - const stream2 = getStreamDirective(directives2); - if (!stream1 && !stream2) { - // both fields do not have streams - return true; - } else if (stream1 && stream2) { - // check if both fields have equivalent streams - return sameArguments(stream1, stream2); - } - // fields have a mix of stream and no stream - return false; -} -// Two types conflict if both types could not apply to a value simultaneously. +} // 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; @@ -40082,24 +39215,24 @@ function doTypesConflict(type1, type2) { return type1 !== type2; } return false; -} -// Given a selection set, return the collection of fields (a mapping of response +} // 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 = new Map(); - const fragmentNames = new Set(); + const nodeAndDefs = Object.create(null); + const fragmentNames = Object.create(null); _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames); - const result = [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 +} // 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); @@ -40120,16 +39253,14 @@ function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeA fieldDef = parentType.getFields()[fieldName]; } const responseName = selection.alias ? selection.alias.value : fieldName; - let nodeAndDefsList = nodeAndDefs.get(responseName); - if (nodeAndDefsList == null) { - nodeAndDefsList = []; - nodeAndDefs.set(responseName, nodeAndDefsList); + if (!nodeAndDefs[responseName]) { + nodeAndDefs[responseName] = []; } - nodeAndDefsList.push([parentType, selection, fieldDef]); + nodeAndDefs[responseName].push([parentType, selection, fieldDef]); break; } case _kinds.Kind.FRAGMENT_SPREAD: - fragmentNames.add(selection.name.value); + fragmentNames[selection.name.value] = true; break; case _kinds.Kind.INLINE_FRAGMENT: { @@ -40140,9 +39271,9 @@ function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeA } } } -} -// Given a series of Conflicts which occurred between two sub-fields, generate +} // 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()]]; @@ -40151,6 +39282,7 @@ function subfieldConflicts(conflicts, responseName, node1, node2) { /** * 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(); @@ -40161,10 +39293,10 @@ class PairSet { 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 + } // 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) { @@ -40270,10 +39402,10 @@ var _definition = __webpack_require__(/*! ../../type/definition.mjs */ "../../.. */ function PossibleTypeExtensionsRule(context) { const schema = context.getSchema(); - const definedTypes = new Map(); + const definedTypes = Object.create(null); for (const def of context.getDocument().definitions) { if ((0, _predicates.isTypeDefinitionNode)(def)) { - definedTypes.set(def.name.value, def); + definedTypes[def.name.value] = def; } } return { @@ -40286,15 +39418,15 @@ function PossibleTypeExtensionsRule(context) { }; function checkExtension(node) { const typeName = node.name.value; - const defNode = definedTypes.get(typeName); + const defNode = definedTypes[typeName]; const existingType = schema === null || schema === void 0 ? void 0 : schema.getType(typeName); let expectedKind; - if (defNode != null) { + if (defNode) { expectedKind = defKindToExtKind[defNode.kind]; } else if (existingType) { expectedKind = typeToExtKind(existingType); } - if (expectedKind != null) { + if (expectedKind) { if (expectedKind !== node.kind) { const kindStr = extensionKindToTypeName(node.kind); context.reportError(new _GraphQLError.GraphQLError(`Cannot extend non-${kindStr} type "${typeName}".`, { @@ -40302,8 +39434,10 @@ function PossibleTypeExtensionsRule(context) { })); } } else { - var _schema$getTypeMap; - const allTypeNames = [...definedTypes.keys(), ...Object.keys((_schema$getTypeMap = schema === null || schema === void 0 ? void 0 : schema.getTypeMap()) !== null && _schema$getTypeMap !== void 0 ? _schema$getTypeMap : {})]; + 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 @@ -40340,6 +39474,7 @@ function typeToExtKind(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 extensionKindToTypeName(kind) { @@ -40357,7 +39492,9 @@ function extensionKindToTypeName(kind) { case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: return 'input object'; // Not reachable. All possible types have been considered - /* c8 ignore next 2 */ + + /* c8 ignore next */ + default: false || (0, _invariant.invariant)(false, 'Unexpected kind: ' + (0, _inspect.inspect)(kind)); } @@ -40379,6 +39516,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.ProvidedRequiredArgumentsOnDirectivesRule = ProvidedRequiredArgumentsOnDirectivesRule; exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; var _inspect = __webpack_require__(/*! ../../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); +var _keyMap = __webpack_require__(/*! ../../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _kinds = __webpack_require__(/*! ../../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _printer = __webpack_require__(/*! ../../language/printer.mjs */ "../../../node_modules/graphql/language/printer.mjs"); @@ -40402,7 +39540,8 @@ function ProvidedRequiredArgumentsRule(context) { if (!fieldDef) { return false; } - const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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) { @@ -40420,22 +39559,25 @@ function ProvidedRequiredArgumentsRule(context) { /** * @internal */ + function ProvidedRequiredArgumentsOnDirectivesRule(context) { var _schema$getDirectives; - const requiredArgsMap = new Map(); + 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.set(directive.name, new Map(directive.args.filter(_definition.isRequiredArgument).map(arg => [arg.name, arg]))); + 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.set(def.name.value, new Map(argNodes.filter(isRequiredArgumentNode).map(arg => [arg.name.value, arg]))); + requiredArgsMap[def.name.value] = (0, _keyMap.keyMap)(argNodes.filter(isRequiredArgumentNode), arg => arg.name.value); } } return { @@ -40443,14 +39585,16 @@ function ProvidedRequiredArgumentsOnDirectivesRule(context) { // Validate on leave to allow for deeper errors to appear first. leave(directiveNode) { const directiveName = directiveNode.name.value; - const requiredArgs = requiredArgsMap.get(directiveName); - if (requiredArgs != null) { + 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 requiredArgs.entries()) { + 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.`, { @@ -40533,9 +39677,6 @@ exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _kinds = __webpack_require__(/*! ../../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); var _collectFields = __webpack_require__(/*! ../../execution/collectFields.mjs */ "../../../node_modules/graphql/execution/collectFields.mjs"); -function toNodes(fieldGroup) { - return fieldGroup.map(fieldDetails => fieldDetails.node); -} /** * Subscriptions must only include a non-introspection field. * @@ -40560,22 +39701,21 @@ function SingleFieldSubscriptionsRule(context) { fragments[definition.name.value] = definition; } } - const { - groupedFieldSet - } = (0, _collectFields.collectFields)(schema, fragments, variableValues, subscriptionType, node); - if (groupedFieldSet.size > 1) { - const fieldGroups = [...groupedFieldSet.values()]; - const extraFieldGroups = fieldGroups.slice(1); - const extraFieldSelections = extraFieldGroups.flatMap(fieldGroup => toNodes(fieldGroup)); + 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 fieldGroup of groupedFieldSet.values()) { - const fieldName = toNodes(fieldGroup)[0].name.value; + 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: toNodes(fieldGroup) + nodes: fieldNodes })); } } @@ -40587,42 +39727,6 @@ function SingleFieldSubscriptionsRule(context) { /***/ }), -/***/ "../../../node_modules/graphql/validation/rules/StreamDirectiveOnListFieldRule.mjs": -/*!*****************************************************************************************!*\ - !*** ../../../node_modules/graphql/validation/rules/StreamDirectiveOnListFieldRule.mjs ***! - \*****************************************************************************************/ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.StreamDirectiveOnListFieldRule = StreamDirectiveOnListFieldRule; -var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); -var _definition = __webpack_require__(/*! ../../type/definition.mjs */ "../../../node_modules/graphql/type/definition.mjs"); -var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../../node_modules/graphql/type/directives.mjs"); -/** - * Stream directives are used on list fields - * - * A GraphQL document is only valid if stream directives are used on list fields. - */ -function StreamDirectiveOnListFieldRule(context) { - return { - Directive(node) { - const fieldDef = context.getFieldDef(); - const parentType = context.getParentType(); - if (fieldDef && parentType && node.name.value === _directives.GraphQLStreamDirective.name && !((0, _definition.isListType)(fieldDef.type) || (0, _definition.isWrappingType)(fieldDef.type) && (0, _definition.isListType)(fieldDef.type.ofType))) { - context.reportError(new _GraphQLError.GraphQLError(`Stream directive cannot be used on non-list field "${fieldDef.name}" on type "${parentType.name}".`, { - nodes: node - })); - } - } - }; -} - -/***/ }), - /***/ "../../../node_modules/graphql/validation/rules/UniqueArgumentDefinitionNamesRule.mjs": /*!********************************************************************************************!*\ !*** ../../../node_modules/graphql/validation/rules/UniqueArgumentDefinitionNamesRule.mjs ***! @@ -40647,7 +39751,9 @@ 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); @@ -40659,15 +39765,17 @@ function UniqueArgumentDefinitionNamesRule(context) { }; function checkArgUniquenessPerField(typeNode) { var _typeNode$fields; - const typeName = typeNode.name.value; - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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 + 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); } @@ -40717,7 +39825,9 @@ function UniqueArgumentNamesRule(context) { }; 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); @@ -40752,7 +39862,7 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * A GraphQL document is only valid if all defined directives have unique names. */ function UniqueDirectiveNamesRule(context) { - const knownDirectiveNames = new Map(); + const knownDirectiveNames = Object.create(null); const schema = context.getSchema(); return { DirectiveDefinition(node) { @@ -40763,13 +39873,12 @@ function UniqueDirectiveNamesRule(context) { })); return; } - const knownName = knownDirectiveNames.get(directiveName); - if (knownName) { + if (knownDirectiveNames[directiveName]) { context.reportError(new _GraphQLError.GraphQLError(`There can be only one directive named "@${directiveName}".`, { - nodes: [knownName, node.name] + nodes: [knownDirectiveNames[directiveName], node.name] })); } else { - knownDirectiveNames.set(directiveName, node.name); + knownDirectiveNames[directiveName] = node.name; } return false; } @@ -40803,20 +39912,20 @@ var _directives = __webpack_require__(/*! ../../type/directives.mjs */ "../../.. * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location */ function UniqueDirectivesPerLocationRule(context) { - const uniqueDirectiveMap = new Map(); + const uniqueDirectiveMap = Object.create(null); const schema = context.getSchema(); const definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives; for (const directive of definedDirectives) { - uniqueDirectiveMap.set(directive.name, !directive.isRepeatable); + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; } const astDefinitions = context.getDocument().definitions; for (const def of astDefinitions) { if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { - uniqueDirectiveMap.set(def.name.value, !def.repeatable); + uniqueDirectiveMap[def.name.value] = !def.repeatable; } } - const schemaDirectives = new Map(); - const typeDirectivesMap = new Map(); + 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 @@ -40830,24 +39939,22 @@ function UniqueDirectivesPerLocationRule(context) { seenDirectives = schemaDirectives; } else if ((0, _predicates.isTypeDefinitionNode)(node) || (0, _predicates.isTypeExtensionNode)(node)) { const typeName = node.name.value; - seenDirectives = typeDirectivesMap.get(typeName); + seenDirectives = typeDirectivesMap[typeName]; if (seenDirectives === undefined) { - seenDirectives = new Map(); - typeDirectivesMap.set(typeName, seenDirectives); + typeDirectivesMap[typeName] = seenDirectives = Object.create(null); } } else { - seenDirectives = new Map(); + seenDirectives = Object.create(null); } for (const directive of node.directives) { const directiveName = directive.name.value; - if (uniqueDirectiveMap.get(directiveName) === true) { - const seenDirective = seenDirectives.get(directiveName); - if (seenDirective != null) { + if (uniqueDirectiveMap[directiveName]) { + if (seenDirectives[directiveName]) { context.reportError(new _GraphQLError.GraphQLError(`The directive "@${directiveName}" can only be used once at this location.`, { - nodes: [seenDirective, directive] + nodes: [seenDirectives[directiveName], directive] })); } else { - seenDirectives.set(directiveName, directive); + seenDirectives[directiveName] = directive; } } } @@ -40879,7 +39986,7 @@ var _definition = __webpack_require__(/*! ../../type/definition.mjs */ "../../.. function UniqueEnumValueNamesRule(context) { const schema = context.getSchema(); const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownValueNames = new Map(); + const knownValueNames = Object.create(null); return { EnumTypeDefinition: checkValueUniqueness, EnumTypeExtension: checkValueUniqueness @@ -40887,14 +39994,14 @@ function UniqueEnumValueNamesRule(context) { function checkValueUniqueness(node) { var _node$values; const typeName = node.name.value; - let valueNames = knownValueNames.get(typeName); - if (valueNames == null) { - valueNames = new Map(); - knownValueNames.set(typeName, valueNames); - } - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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]; @@ -40902,15 +40009,12 @@ function UniqueEnumValueNamesRule(context) { 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 })); - continue; - } - const knownValueName = valueNames.get(valueName); - if (knownValueName != null) { + } else if (valueNames[valueName]) { context.reportError(new _GraphQLError.GraphQLError(`Enum value "${typeName}.${valueName}" can only be defined once.`, { - nodes: [knownValueName, valueDef.name] + nodes: [valueNames[valueName], valueDef.name] })); } else { - valueNames.set(valueName, valueDef.name); + valueNames[valueName] = valueDef.name; } } return false; @@ -40941,7 +40045,7 @@ var _definition = __webpack_require__(/*! ../../type/definition.mjs */ "../../.. function UniqueFieldDefinitionNamesRule(context) { const schema = context.getSchema(); const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); - const knownFieldNames = new Map(); + const knownFieldNames = Object.create(null); return { InputObjectTypeDefinition: checkFieldUniqueness, InputObjectTypeExtension: checkFieldUniqueness, @@ -40953,29 +40057,26 @@ function UniqueFieldDefinitionNamesRule(context) { function checkFieldUniqueness(node) { var _node$fields; const typeName = node.name.value; - let fieldNames = knownFieldNames.get(typeName); - if (fieldNames == null) { - fieldNames = new Map(); - knownFieldNames.set(typeName, fieldNames); - } - // FIXME: https://github.com/graphql/graphql-js/issues/2203 + 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 })); - continue; - } - const knownFieldName = fieldNames.get(fieldName); - if (knownFieldName != null) { + } else if (fieldNames[fieldName]) { context.reportError(new _GraphQLError.GraphQLError(`Field "${typeName}.${fieldName}" can only be defined once.`, { - nodes: [knownFieldName, fieldDef.name] + nodes: [fieldNames[fieldName], fieldDef.name] })); } else { - fieldNames.set(fieldName, fieldDef.name); + fieldNames[fieldName] = fieldDef.name; } } return false; @@ -41011,18 +40112,17 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness */ function UniqueFragmentNamesRule(context) { - const knownFragmentNames = new Map(); + const knownFragmentNames = Object.create(null); return { OperationDefinition: () => false, FragmentDefinition(node) { const fragmentName = node.name.value; - const knownFragmentName = knownFragmentNames.get(fragmentName); - if (knownFragmentName != null) { + if (knownFragmentNames[fragmentName]) { context.reportError(new _GraphQLError.GraphQLError(`There can be only one fragment named "${fragmentName}".`, { - nodes: [knownFragmentName, node.name] + nodes: [knownFragmentNames[fragmentName], node.name] })); } else { - knownFragmentNames.set(fragmentName, node.name); + knownFragmentNames[fragmentName] = node.name; } return false; } @@ -41055,28 +40155,27 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ */ function UniqueInputFieldNamesRule(context) { const knownNameStack = []; - let knownNames = new Map(); + let knownNames = Object.create(null); return { ObjectValue: { enter() { knownNameStack.push(knownNames); - knownNames = new Map(); + knownNames = Object.create(null); }, leave() { const prevKnownNames = knownNameStack.pop(); - prevKnownNames != null || (0, _invariant.invariant)(false); + prevKnownNames || (0, _invariant.invariant)(false); knownNames = prevKnownNames; } }, ObjectField(node) { const fieldName = node.name.value; - const knownName = knownNames.get(fieldName); - if (knownName != null) { + if (knownNames[fieldName]) { context.reportError(new _GraphQLError.GraphQLError(`There can be only one input field named "${fieldName}".`, { - nodes: [knownName, node.name] + nodes: [knownNames[fieldName], node.name] })); } else { - knownNames.set(fieldName, node.name); + knownNames[fieldName] = node.name; } } }; @@ -41105,18 +40204,17 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness */ function UniqueOperationNamesRule(context) { - const knownOperationNames = new Map(); + const knownOperationNames = Object.create(null); return { OperationDefinition(node) { const operationName = node.name; - if (operationName != null) { - const knownOperationName = knownOperationNames.get(operationName.value); - if (knownOperationName != null) { + if (operationName) { + if (knownOperationNames[operationName.value]) { context.reportError(new _GraphQLError.GraphQLError(`There can be only one operation named "${operationName.value}".`, { - nodes: [knownOperationName, operationName] + nodes: [knownOperationNames[operationName.value], operationName] })); } else { - knownOperationNames.set(operationName.value, operationName); + knownOperationNames[operationName.value] = operationName; } } return false; @@ -41147,7 +40245,7 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ */ function UniqueOperationTypesRule(context) { const schema = context.getSchema(); - const definedOperationTypes = new Map(); + const definedOperationTypes = Object.create(null); const existingOperationTypes = schema ? { query: schema.getQueryType(), mutation: schema.getMutationType(), @@ -41159,12 +40257,14 @@ function UniqueOperationTypesRule(context) { }; 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.get(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 @@ -41174,7 +40274,7 @@ function UniqueOperationTypesRule(context) { nodes: [alreadyDefinedOperationType, operationType] })); } else { - definedOperationTypes.set(operation, operationType); + definedOperationTypes[operation] = operationType; } } return false; @@ -41202,7 +40302,7 @@ var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../ * A GraphQL document is only valid if all defined types have unique names. */ function UniqueTypeNamesRule(context) { - const knownTypeNames = new Map(); + const knownTypeNames = Object.create(null); const schema = context.getSchema(); return { ScalarTypeDefinition: checkTypeName, @@ -41220,13 +40320,12 @@ function UniqueTypeNamesRule(context) { })); return; } - const knownNameNode = knownTypeNames.get(typeName); - if (knownNameNode != null) { + if (knownTypeNames[typeName]) { context.reportError(new _GraphQLError.GraphQLError(`There can be only one type named "${typeName}".`, { - nodes: [knownNameNode, node.name] + nodes: [knownTypeNames[typeName], node.name] })); } else { - knownTypeNames.set(typeName, node.name); + knownTypeNames[typeName] = node.name; } return false; } @@ -41257,7 +40356,9 @@ 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); @@ -41288,6 +40389,7 @@ Object.defineProperty(exports, "__esModule", ({ exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; var _didYouMean = __webpack_require__(/*! ../../jsutils/didYouMean.mjs */ "../../../node_modules/graphql/jsutils/didYouMean.mjs"); var _inspect = __webpack_require__(/*! ../../jsutils/inspect.mjs */ "../../../node_modules/graphql/jsutils/inspect.mjs"); +var _keyMap = __webpack_require__(/*! ../../jsutils/keyMap.mjs */ "../../../node_modules/graphql/jsutils/keyMap.mjs"); var _suggestionList = __webpack_require__(/*! ../../jsutils/suggestionList.mjs */ "../../../node_modules/graphql/jsutils/suggestionList.mjs"); var _GraphQLError = __webpack_require__(/*! ../../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _kinds = __webpack_require__(/*! ../../language/kinds.mjs */ "../../../node_modules/graphql/language/kinds.mjs"); @@ -41326,11 +40428,11 @@ function ValuesOfCorrectTypeRule(context) { if (!(0, _definition.isInputObjectType)(type)) { isValidValueNode(context, node); return false; // Don't traverse further. - } - // Ensure every required field exists. - const fieldNodeMap = new Map(node.fields.map(field => [field.name.value, field])); + } // 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.get(fieldDef.name); + 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.`, { @@ -41371,6 +40473,7 @@ function ValuesOfCorrectTypeRule(context) { * 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(); @@ -41384,11 +40487,12 @@ function isValidValueNode(context, node) { nodes: node })); return; - } - // Scalars and Enums determine if a literal value is valid via parseLiteral(), + } // 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 */); + 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)}.`, { @@ -41408,8 +40512,8 @@ function isValidValueNode(context, node) { } } function validateOneOfInputObject(context, node, type, fieldNodeMap, variableDefinitions) { - var _fieldNodeMap$get; - const keys = Array.from(fieldNodeMap.keys()); + var _fieldNodeMap$keys$; + const keys = Object.keys(fieldNodeMap); const isNotExactlyOneField = keys.length !== 1; if (isNotExactlyOneField) { context.reportError(new _GraphQLError.GraphQLError(`OneOf Input Object "${type.name}" must specify exactly one key.`, { @@ -41417,7 +40521,7 @@ function validateOneOfInputObject(context, node, type, fieldNodeMap, variableDef })); return; } - const value = (_fieldNodeMap$get = fieldNodeMap.get(keys[0])) === null || _fieldNodeMap$get === void 0 ? void 0 : _fieldNodeMap$get.value; + const value = (_fieldNodeMap$keys$ = fieldNodeMap[keys[0]]) === null || _fieldNodeMap$keys$ === void 0 ? void 0 : _fieldNodeMap$keys$.value; const isNullLiteral = !value || value.kind === _kinds.Kind.NULL; const isVariable = (value === null || value === void 0 ? void 0 : value.kind) === _kinds.Kind.VARIABLE; if (isNullLiteral) { @@ -41507,11 +40611,11 @@ var _typeFromAST = __webpack_require__(/*! ../../utilities/typeFromAST.mjs */ ". * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed */ function VariablesInAllowedPositionRule(context) { - let varDefMap; + let varDefMap = Object.create(null); return { OperationDefinition: { enter() { - varDefMap = new Map(); + varDefMap = Object.create(null); }, leave(operation) { const usages = context.getRecursiveVariableUsages(operation); @@ -41521,7 +40625,7 @@ function VariablesInAllowedPositionRule(context) { defaultValue } of usages) { const varName = node.name.value; - const varDef = varDefMap.get(varName); + 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 @@ -41542,7 +40646,7 @@ function VariablesInAllowedPositionRule(context) { } }, VariableDefinition(node) { - varDefMap.set(node.variable.name.value, node); + varDefMap[node.variable.name.value] = node; } }; } @@ -41551,6 +40655,7 @@ function VariablesInAllowedPositionRule(context) { * 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; @@ -41703,9 +40808,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.specifiedSDLRules = exports.specifiedRules = exports.recommendedRules = void 0; -var _DeferStreamDirectiveLabelRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveLabelRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveLabelRule.mjs"); -var _DeferStreamDirectiveOnRootFieldRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveOnRootFieldRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs"); -var _DeferStreamDirectiveOnValidOperationsRule = __webpack_require__(/*! ./rules/DeferStreamDirectiveOnValidOperationsRule.mjs */ "../../../node_modules/graphql/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs"); var _ExecutableDefinitionsRule = __webpack_require__(/*! ./rules/ExecutableDefinitionsRule.mjs */ "../../../node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs"); var _FieldsOnCorrectTypeRule = __webpack_require__(/*! ./rules/FieldsOnCorrectTypeRule.mjs */ "../../../node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs"); var _FragmentsOnCompositeTypesRule = __webpack_require__(/*! ./rules/FragmentsOnCompositeTypesRule.mjs */ "../../../node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs"); @@ -41726,7 +40828,6 @@ var _PossibleTypeExtensionsRule = __webpack_require__(/*! ./rules/PossibleTypeEx var _ProvidedRequiredArgumentsRule = __webpack_require__(/*! ./rules/ProvidedRequiredArgumentsRule.mjs */ "../../../node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs"); var _ScalarLeafsRule = __webpack_require__(/*! ./rules/ScalarLeafsRule.mjs */ "../../../node_modules/graphql/validation/rules/ScalarLeafsRule.mjs"); var _SingleFieldSubscriptionsRule = __webpack_require__(/*! ./rules/SingleFieldSubscriptionsRule.mjs */ "../../../node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs"); -var _StreamDirectiveOnListFieldRule = __webpack_require__(/*! ./rules/StreamDirectiveOnListFieldRule.mjs */ "../../../node_modules/graphql/validation/rules/StreamDirectiveOnListFieldRule.mjs"); var _UniqueArgumentDefinitionNamesRule = __webpack_require__(/*! ./rules/UniqueArgumentDefinitionNamesRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueArgumentDefinitionNamesRule.mjs"); var _UniqueArgumentNamesRule = __webpack_require__(/*! ./rules/UniqueArgumentNamesRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs"); var _UniqueDirectiveNamesRule = __webpack_require__(/*! ./rules/UniqueDirectiveNamesRule.mjs */ "../../../node_modules/graphql/validation/rules/UniqueDirectiveNamesRule.mjs"); @@ -41742,14 +40843,7 @@ var _UniqueVariableNamesRule = __webpack_require__(/*! ./rules/UniqueVariableNam var _ValuesOfCorrectTypeRule = __webpack_require__(/*! ./rules/ValuesOfCorrectTypeRule.mjs */ "../../../node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.mjs"); var _VariablesAreInputTypesRule = __webpack_require__(/*! ./rules/VariablesAreInputTypesRule.mjs */ "../../../node_modules/graphql/validation/rules/VariablesAreInputTypesRule.mjs"); var _VariablesInAllowedPositionRule = __webpack_require__(/*! ./rules/VariablesInAllowedPositionRule.mjs */ "../../../node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.mjs"); -// Spec Section: "Defer And Stream Directive Labels Are Unique" - -// Spec Section: "Defer And Stream Directives Are Used On Valid Root Field" - -// Spec Section: "Defer And Stream Directives Are Used On Valid Operations" - // Spec Section: "Executable Definitions" - // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" // Spec Section: "Fragments on Composite Types" @@ -41786,8 +40880,6 @@ var _VariablesInAllowedPositionRule = __webpack_require__(/*! ./rules/VariablesI // Spec Section: "Subscriptions with Single Root Field" -// Spec Section: "Stream Directives Are Used On List Fields" - // Spec Section: "Argument Uniqueness" // Spec Section: "Directives Are Unique Per Location" @@ -41817,10 +40909,12 @@ const recommendedRules = exports.recommendedRules = Object.freeze([_MaxIntrospec * 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 = exports.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, _DeferStreamDirectiveOnRootFieldRule.DeferStreamDirectiveOnRootFieldRule, _DeferStreamDirectiveOnValidOperationsRule.DeferStreamDirectiveOnValidOperationsRule, _DeferStreamDirectiveLabelRule.DeferStreamDirectiveLabelRule, _StreamDirectiveOnListFieldRule.StreamDirectiveOnListFieldRule, _KnownArgumentNamesRule.KnownArgumentNamesRule, _UniqueArgumentNamesRule.UniqueArgumentNamesRule, _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule, _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule, _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule, _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule, _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, ...recommendedRules]); + +const specifiedRules = exports.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, ...recommendedRules]); /** * @internal */ + const specifiedSDLRules = exports.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]); /***/ }), @@ -41840,6 +40934,7 @@ exports.assertValidSDL = assertValidSDL; exports.assertValidSDLExtension = assertValidSDLExtension; exports.validate = validate; exports.validateSDL = validateSDL; +var _devAssert = __webpack_require__(/*! ../jsutils/devAssert.mjs */ "../../../node_modules/graphql/jsutils/devAssert.mjs"); var _GraphQLError = __webpack_require__(/*! ../error/GraphQLError.mjs */ "../../../node_modules/graphql/error/GraphQLError.mjs"); var _visitor = __webpack_require__(/*! ../language/visitor.mjs */ "../../../node_modules/graphql/language/visitor.mjs"); var _validate = __webpack_require__(/*! ../type/validate.mjs */ "../../../node_modules/graphql/type/validate.mjs"); @@ -41866,30 +40961,32 @@ var _ValidationContext = __webpack_require__(/*! ./ValidationContext.mjs */ "../ * 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; - // If the schema used for validation is invalid, throw an error. + documentAST || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. + (0, _validate.assertValidSchema)(schema); - const abortError = new _GraphQLError.GraphQLError('Too many validation errors, error limit reached. Validation aborted.'); + const abortObj = Object.freeze({}); const errors = []; const context = new _ValidationContext.ValidationContext(schema, documentAST, typeInfo, error => { if (errors.length >= maxErrors) { - throw abortError; + 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, + }); // 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. + + 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 === abortError) { - errors.push(abortError); - } else { + if (e !== abortObj) { throw e; } } @@ -41898,6 +40995,7 @@ typeInfo = new _TypeInfo.TypeInfo(schema)) { /** * @internal */ + function validateSDL(documentAST, schemaToExtend, rules = _specifiedRules.specifiedSDLRules) { const errors = []; const context = new _ValidationContext.SDLValidationContext(documentAST, schemaToExtend, error => { @@ -41913,6 +41011,7 @@ function validateSDL(documentAST, schemaToExtend, rules = _specifiedRules.specif * * @internal */ + function assertValidSDL(documentAST) { const errors = validateSDL(documentAST); if (errors.length !== 0) { @@ -41925,6 +41024,7 @@ function assertValidSDL(documentAST) { * * @internal */ + function assertValidSDLExtension(documentAST, schema) { const errors = validateSDL(documentAST, schema); if (errors.length !== 0) { @@ -41948,18 +41048,20 @@ Object.defineProperty(exports, "__esModule", ({ 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 = exports.version = '17.0.0-alpha.7'; +const version = exports.version = '16.9.0'; /** * An object containing the components of the GraphQL.js version string */ + const versionInfo = exports.versionInfo = Object.freeze({ - major: 17, - minor: 0, + major: 16, + minor: 9, patch: 0, - preReleaseTag: 'alpha.7' + preReleaseTag: null }); /***/ }), @@ -69309,7 +68411,7 @@ function createContextHook(context) { var _a; const value = React.useContext(context); if (value === null && (options == null ? void 0 : options.nonNull)) { - throw new Error(`Tried to use \`${((_a = options.caller) == null ? void 0 : _a.name) || useGivenContext.caller.name}\` without the necessary context. Make sure to render the \`${context.displayName}Provider\` component higher up the tree.`); + throw new Error(`Tried to use \`${((_a = options.caller) == null ? void 0 : _a.name) || "a component"}\` without the necessary context. Make sure to render the \`${context.displayName}Provider\` component higher up the tree.`); } return value; } diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 5e24ee625..beee9c578 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index a05e8edb5..c30d6950f 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/netbox-graphiql/package.json b/netbox/project-static/netbox-graphiql/package.json index 27257e34c..c5b2f3077 100644 --- a/netbox/project-static/netbox-graphiql/package.json +++ b/netbox/project-static/netbox-graphiql/package.json @@ -1,13 +1,13 @@ { "name": "netbox-graphiql", - "version": "4.1.0", + "version": "4.2.0", "description": "NetBox GraphiQL Custom Front End", "main": "dist/graphiql.js", "license": "Apache-2.0", "private": true, "dependencies": { - "@graphiql/plugin-explorer": "3.2.2", - "graphiql": "3.7.1", + "@graphiql/plugin-explorer": "3.2.3", + "graphiql": "3.7.2", "graphql": "16.9.0", "js-cookie": "3.0.5", "react": "18.3.1", diff --git a/netbox/project-static/package.json b/netbox/project-static/package.json index 0750f397b..bbc9c6ff7 100644 --- a/netbox/project-static/package.json +++ b/netbox/project-static/package.json @@ -27,11 +27,11 @@ "bootstrap": "5.3.3", "clipboard": "2.0.11", "flatpickr": "4.6.13", - "gridstack": "10.3.1", + "gridstack": "11.1.1", "htmx.org": "1.9.12", "query-string": "9.1.1", - "sass": "1.80.5", - "tom-select": "2.3.1", + "sass": "1.81.0", + "tom-select": "2.4.1", "typeface-inter": "3.18.1", "typeface-roboto-mono": "1.1.13" }, diff --git a/netbox/project-static/src/select/classes/dynamicTomSelect.ts b/netbox/project-static/src/select/classes/dynamicTomSelect.ts index 72c9fe518..8e44ce6a7 100644 --- a/netbox/project-static/src/select/classes/dynamicTomSelect.ts +++ b/netbox/project-static/src/select/classes/dynamicTomSelect.ts @@ -1,18 +1,17 @@ -import { RecursivePartial, TomInput, TomOption, TomSettings } from 'tom-select/dist/types/types'; -import { addClasses } from 'tom-select/src/vanilla' +import { RecursivePartial, TomOption, TomSettings } from 'tom-select/dist/types/types'; +import { TomInput } from 'tom-select/dist/cjs/types/core'; +import { addClasses } from 'tom-select/src/vanilla.ts'; import queryString from 'query-string'; import TomSelect from 'tom-select'; import type { Stringifiable } from 'query-string'; import { DynamicParamsMap } from './dynamicParamsMap'; // Transitional -import { QueryFilter, PathFilter } from '../types' +import { QueryFilter, PathFilter } from '../types'; import { getElement, replaceAll } from '../../util'; - // Extends TomSelect to provide enhanced fetching of options via the REST API export class DynamicTomSelect extends TomSelect { - public readonly nullOption: Nullable = null; // Transitional code from APISelect @@ -25,7 +24,7 @@ export class DynamicTomSelect extends TomSelect { * Overrides */ - constructor( input_arg: string|TomInput, user_settings: RecursivePartial ) { + constructor(input_arg: string | TomInput, user_settings: RecursivePartial) { super(input_arg, user_settings); // Glean the REST API endpoint URL from the