Initial Save

This commit is contained in:
jackbeeby
2025-03-28 12:30:19 +11:00
parent e381994f19
commit d8773925e8
9910 changed files with 982718 additions and 0 deletions

21
node_modules/graphql/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 GraphQL Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

140
node_modules/graphql/README.md generated vendored Normal file
View File

@@ -0,0 +1,140 @@
# GraphQL.js
The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.
[![npm version](https://badge.fury.io/js/graphql.svg)](https://badge.fury.io/js/graphql)
[![Build Status](https://travis-ci.org/graphql/graphql-js.svg?branch=master)](https://travis-ci.org/graphql/graphql-js?branch=master)
[![Coverage Status](https://codecov.io/gh/graphql/graphql-js/branch/master/graph/badge.svg)](https://codecov.io/gh/graphql/graphql-js)
See more complete documentation at https://graphql.org/ and
https://graphql.org/graphql-js/.
Looking for help? Find resources [from the community](https://graphql.org/community/).
## Getting Started
An overview of GraphQL in general is available in the
[README](https://github.com/graphql/graphql-spec/blob/master/README.md) for the
[Specification for GraphQL](https://github.com/graphql/graphql-spec). That overview
describes a simple set of GraphQL examples that exist as [tests](src/__tests__)
in this repository. A good way to get started with this repository is to walk
through that README and the corresponding tests in parallel.
### Using GraphQL.js
Install GraphQL.js from npm
With yarn:
```sh
yarn add graphql
```
or alternatively using npm:
```sh
npm install --save graphql
```
GraphQL.js provides two important capabilities: building a type schema, and
serving queries against that type schema.
First, build a GraphQL type schema which maps to your code base.
```js
import {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
} from 'graphql';
var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
hello: {
type: GraphQLString,
resolve() {
return 'world';
},
},
},
}),
});
```
This defines a simple schema with one type and one field, that resolves
to a fixed value. The `resolve` function can return a value, a promise,
or an array of promises. A more complex example is included in the top
level [tests](src/__tests__) directory.
Then, serve the result of a query against that type schema.
```js
var query = '{ hello }';
graphql(schema, query).then(result => {
// Prints
// {
// data: { hello: "world" }
// }
console.log(result);
});
```
This runs a query fetching the one field defined. The `graphql` function will
first ensure the query is syntactically and semantically valid before executing
it, reporting errors otherwise.
```js
var query = '{ boyhowdy }';
graphql(schema, query).then(result => {
// Prints
// {
// errors: [
// { message: 'Cannot query field boyhowdy on RootQueryType',
// locations: [ { line: 1, column: 3 } ] }
// ]
// }
console.log(result);
});
```
### Want to ride the bleeding edge?
The `npm` branch in this repository is automatically maintained to be the last
commit to `master` to pass all tests, in the same form found on npm. It is
recommended to use builds deployed to npm for many reasons, but if you want to use
the latest not-yet-released version of graphql-js, you can do so by depending
directly on this branch:
```
npm install graphql@git://github.com/graphql/graphql-js.git#npm
```
### Using in a Browser
GraphQL.js is a general purpose library and can be used both in a Node server
and in the browser. As an example, the [GraphiQL](https://github.com/graphql/graphiql/)
tool is built with GraphQL.js!
Building a project using GraphQL.js with [webpack](https://webpack.js.org) or
[rollup](https://github.com/rollup/rollup) should just work and only include
the portions of the library you use. This works because GraphQL.js is distributed
with both CommonJS (`require()`) and ESModule (`import`) files. Ensure that any
custom build configurations look for `.mjs` files!
### Contributing
We actively welcome pull requests, learn how to
[contribute](https://github.com/graphql/graphql-js/blob/master/.github/CONTRIBUTING.md).
### Changelog
Changes are tracked as [GitHub releases](https://github.com/graphql/graphql-js/releases).
### License
GraphQL.js is [MIT-licensed](https://github.com/graphql/graphql-js/blob/master/LICENSE).

87
node_modules/graphql/error/GraphQLError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,87 @@
import Maybe from '../tsutils/Maybe';
import { ASTNode } from '../language/ast';
import { Source } from '../language/source';
import { SourceLocation, getLocation } from '../language/location';
/**
* 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.
*/
export class GraphQLError extends Error {
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
);
/**
* A message describing the Error for debugging purposes.
*
* Enumerable, and appears in the result of JSON.stringify().
*
* Note: should be treated as readonly, despite invariant usage.
*/
message: string;
/**
* 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().
*/
readonly locations: ReadonlyArray<SourceLocation> | undefined;
/**
* 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().
*/
readonly path: ReadonlyArray<string | number> | undefined;
/**
* An array of GraphQL AST Nodes corresponding to this error.
*/
readonly nodes: ReadonlyArray<ASTNode> | undefined;
/**
* The source GraphQL document corresponding to this error.
*
* Note that if this Error represents more than one node, the source may not
* represent nodes after the first node.
*/
readonly source: Source | undefined;
/**
* An array of character offsets within the source GraphQL document
* which correspond to this error.
*/
readonly positions: ReadonlyArray<number> | undefined;
/**
* The original error thrown from a field resolver during execution.
*/
readonly originalError: Maybe<Error>;
/**
* Extension fields to add to the formatted error.
*/
readonly extensions: { [key: string]: any } | undefined;
}
/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
export function printError(error: GraphQLError): string;

176
node_modules/graphql/error/GraphQLError.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLError = GraphQLError;
exports.printError = printError;
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike"));
var _location = require("../language/location");
var _printLocation = require("../language/printLocation");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function GraphQLError( // eslint-disable-line no-redeclare
message, nodes, source, positions, path, originalError, extensions) {
// Compute list of blame nodes.
var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
var _source = source;
if (!_source && _nodes) {
var node = _nodes[0];
_source = node && node.loc && node.loc.source;
}
var _positions = positions;
if (!_positions && _nodes) {
_positions = _nodes.reduce(function (list, node) {
if (node.loc) {
list.push(node.loc.start);
}
return list;
}, []);
}
if (_positions && _positions.length === 0) {
_positions = undefined;
}
var _locations;
if (positions && source) {
_locations = positions.map(function (pos) {
return (0, _location.getLocation)(source, pos);
});
} else if (_nodes) {
_locations = _nodes.reduce(function (list, node) {
if (node.loc) {
list.push((0, _location.getLocation)(node.loc.source, node.loc.start));
}
return list;
}, []);
}
var _extensions = extensions;
if (_extensions == null && originalError != null) {
var originalExtensions = originalError.extensions;
if ((0, _isObjectLike.default)(originalExtensions)) {
_extensions = originalExtensions;
}
}
Object.defineProperties(this, {
message: {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true
},
locations: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _locations || undefined,
// By being enumerable, JSON.stringify will include `locations` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_locations)
},
path: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: path || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(path)
},
nodes: {
value: _nodes || undefined
},
source: {
value: _source || undefined
},
positions: {
value: _positions || undefined
},
originalError: {
value: originalError
},
extensions: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _extensions || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_extensions)
}
}); // Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true
});
}
}
GraphQLError.prototype = Object.create(Error.prototype, {
constructor: {
value: GraphQLError
},
name: {
value: 'GraphQLError'
},
toString: {
value: function toString() {
return printError(this);
}
}
});
/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
function printError(error) {
var output = error.message;
if (error.nodes) {
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
var node = _error$nodes2[_i2];
if (node.loc) {
output += '\n\n' + (0, _printLocation.printLocation)(node.loc);
}
}
} else if (error.source && error.locations) {
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
var location = _error$locations2[_i4];
output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location);
}
}
return output;
}

242
node_modules/graphql/error/GraphQLError.js.flow generated vendored Normal file
View File

@@ -0,0 +1,242 @@
// @flow strict
import isObjectLike from '../jsutils/isObjectLike';
import { type ASTNode } from '../language/ast';
import { type Source } from '../language/source';
import { type SourceLocation, getLocation } from '../language/location';
import { printLocation, printSourceLocation } from '../language/printLocation';
/**
* 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.
*/
declare class GraphQLError extends Error {
constructor(
message: string,
nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void | null,
source?: ?Source,
positions?: ?$ReadOnlyArray<number>,
path?: ?$ReadOnlyArray<string | number>,
originalError?: ?Error,
extensions?: ?{ [key: string]: mixed, ... },
): void;
/**
* A message describing the Error for debugging purposes.
*
* Enumerable, and appears in the result of JSON.stringify().
*
* Note: should be treated as readonly, despite invariant usage.
*/
message: string;
/**
* 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().
*/
+locations: $ReadOnlyArray<SourceLocation> | void;
/**
* 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().
*/
+path: $ReadOnlyArray<string | number> | void;
/**
* An array of GraphQL AST Nodes corresponding to this error.
*/
+nodes: $ReadOnlyArray<ASTNode> | void;
/**
* 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.
*/
+source: Source | void;
/**
* An array of character offsets within the source GraphQL document
* which correspond to this error.
*/
+positions: $ReadOnlyArray<number> | void;
/**
* The original error thrown from a field resolver during execution.
*/
+originalError: ?Error;
/**
* Extension fields to add to the formatted error.
*/
+extensions: { [key: string]: mixed, ... } | void;
}
export function GraphQLError( // eslint-disable-line no-redeclare
message: string,
nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void,
source?: ?Source,
positions?: ?$ReadOnlyArray<number>,
path?: ?$ReadOnlyArray<string | number>,
originalError?: ?Error & { +extensions: mixed, ... },
extensions?: ?{ [key: string]: mixed, ... },
) {
// Compute list of blame nodes.
const _nodes = Array.isArray(nodes)
? nodes.length !== 0
? nodes
: undefined
: nodes
? [nodes]
: undefined;
// Compute locations in the source for the given nodes/positions.
let _source = source;
if (!_source && _nodes) {
const node = _nodes[0];
_source = node && node.loc && node.loc.source;
}
let _positions = positions;
if (!_positions && _nodes) {
_positions = _nodes.reduce((list, node) => {
if (node.loc) {
list.push(node.loc.start);
}
return list;
}, []);
}
if (_positions && _positions.length === 0) {
_positions = undefined;
}
let _locations;
if (positions && source) {
_locations = positions.map(pos => getLocation(source, pos));
} else if (_nodes) {
_locations = _nodes.reduce((list, node) => {
if (node.loc) {
list.push(getLocation(node.loc.source, node.loc.start));
}
return list;
}, []);
}
let _extensions = extensions;
if (_extensions == null && originalError != null) {
const originalExtensions = originalError.extensions;
if (isObjectLike(originalExtensions)) {
_extensions = originalExtensions;
}
}
Object.defineProperties(this, {
message: {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true,
},
locations: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _locations || undefined,
// By being enumerable, JSON.stringify will include `locations` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_locations),
},
path: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: path || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(path),
},
nodes: {
value: _nodes || undefined,
},
source: {
value: _source || undefined,
},
positions: {
value: _positions || undefined,
},
originalError: {
value: originalError,
},
extensions: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _extensions || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_extensions),
},
});
// Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true,
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true,
});
}
}
(GraphQLError: any).prototype = Object.create(Error.prototype, {
constructor: { value: GraphQLError },
name: { value: 'GraphQLError' },
toString: {
value: function toString() {
return printError(this);
},
},
});
/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
export function printError(error: GraphQLError): string {
let output = error.message;
if (error.nodes) {
for (const node of error.nodes) {
if (node.loc) {
output += '\n\n' + printLocation(node.loc);
}
}
} else if (error.source && error.locations) {
for (const location of error.locations) {
output += '\n\n' + printSourceLocation(error.source, location);
}
}
return output;
}

169
node_modules/graphql/error/GraphQLError.mjs generated vendored Normal file
View File

@@ -0,0 +1,169 @@
import isObjectLike from '../jsutils/isObjectLike';
import { getLocation } from '../language/location';
import { printLocation, printSourceLocation } from '../language/printLocation';
/**
* 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.
*/
export function GraphQLError( // eslint-disable-line no-redeclare
message, nodes, source, positions, path, originalError, extensions) {
// Compute list of blame nodes.
var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
var _source = source;
if (!_source && _nodes) {
var node = _nodes[0];
_source = node && node.loc && node.loc.source;
}
var _positions = positions;
if (!_positions && _nodes) {
_positions = _nodes.reduce(function (list, node) {
if (node.loc) {
list.push(node.loc.start);
}
return list;
}, []);
}
if (_positions && _positions.length === 0) {
_positions = undefined;
}
var _locations;
if (positions && source) {
_locations = positions.map(function (pos) {
return getLocation(source, pos);
});
} else if (_nodes) {
_locations = _nodes.reduce(function (list, node) {
if (node.loc) {
list.push(getLocation(node.loc.source, node.loc.start));
}
return list;
}, []);
}
var _extensions = extensions;
if (_extensions == null && originalError != null) {
var originalExtensions = originalError.extensions;
if (isObjectLike(originalExtensions)) {
_extensions = originalExtensions;
}
}
Object.defineProperties(this, {
message: {
value: message,
// By being enumerable, JSON.stringify will include `message` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: true,
writable: true
},
locations: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _locations || undefined,
// By being enumerable, JSON.stringify will include `locations` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_locations)
},
path: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: path || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(path)
},
nodes: {
value: _nodes || undefined
},
source: {
value: _source || undefined
},
positions: {
value: _positions || undefined
},
originalError: {
value: originalError
},
extensions: {
// Coercing falsey values to undefined ensures they will not be included
// in JSON.stringify() when not provided.
value: _extensions || undefined,
// By being enumerable, JSON.stringify will include `path` in the
// resulting output. This ensures that the simplest possible GraphQL
// service adheres to the spec.
enumerable: Boolean(_extensions)
}
}); // Include (non-enumerable) stack trace.
if (originalError && originalError.stack) {
Object.defineProperty(this, 'stack', {
value: originalError.stack,
writable: true,
configurable: true
});
} else if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
value: Error().stack,
writable: true,
configurable: true
});
}
}
GraphQLError.prototype = Object.create(Error.prototype, {
constructor: {
value: GraphQLError
},
name: {
value: 'GraphQLError'
},
toString: {
value: function toString() {
return printError(this);
}
}
});
/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
export function printError(error) {
var output = error.message;
if (error.nodes) {
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
var node = _error$nodes2[_i2];
if (node.loc) {
output += '\n\n' + printLocation(node.loc);
}
}
} else if (error.source && error.locations) {
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
var location = _error$locations2[_i4];
output += '\n\n' + printSourceLocation(error.source, location);
}
}
return output;
}

39
node_modules/graphql/error/formatError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { SourceLocation } from '../language/location';
import { GraphQLError } from './GraphQLError';
/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*/
export function formatError(error: GraphQLError): GraphQLFormattedError;
/**
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/
export interface GraphQLFormattedError<
TExtensions extends Record<string, any> = Record<string, any>
> {
/**
* A short, human-readable summary of the problem that **SHOULD NOT** change
* from occurrence to occurrence of the problem, except for purposes of
* localization.
*/
readonly message: string;
/**
* If an error can be associated to a particular point in the requested
* GraphQL document, it should contain a list of locations.
*/
readonly locations?: ReadonlyArray<SourceLocation>;
/**
* If an error can be associated to a particular field in the GraphQL result,
* it _must_ contain an entry with the key `path` that details the path of
* the response field which experienced the error. This allows clients to
* identify whether a null result is intentional or caused by a runtime error.
*/
readonly path?: ReadonlyArray<string | number>;
/**
* Reserved for implementors to extend the protocol however they see fit,
* and hence there are no additional restrictions on its contents.
*/
readonly extensions?: TExtensions;
}

35
node_modules/graphql/error/formatError.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatError = formatError;
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*/
function formatError(error) {
error || (0, _devAssert.default)(0, 'Received null or undefined error.');
var message = error.message || 'An unknown error occurred.';
var locations = error.locations;
var path = error.path;
var extensions = error.extensions;
return extensions ? {
message: message,
locations: locations,
path: path,
extensions: extensions
} : {
message: message,
locations: locations,
path: path
};
}
/**
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/

52
node_modules/graphql/error/formatError.js.flow generated vendored Normal file
View File

@@ -0,0 +1,52 @@
// @flow strict
import devAssert from '../jsutils/devAssert';
import { type SourceLocation } from '../language/location';
import { type GraphQLError } from './GraphQLError';
/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*/
export function formatError(error: GraphQLError): GraphQLFormattedError {
devAssert(error, 'Received null or undefined error.');
const message = error.message || 'An unknown error occurred.';
const locations = error.locations;
const path = error.path;
const extensions = error.extensions;
return extensions
? { message, locations, path, extensions }
: { message, locations, path };
}
/**
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/
export type GraphQLFormattedError = {|
/**
* A short, human-readable summary of the problem that **SHOULD NOT** change
* from occurrence to occurrence of the problem, except for purposes of
* localization.
*/
+message: string,
/**
* If an error can be associated to a particular point in the requested
* GraphQL document, it should contain a list of locations.
*/
+locations: $ReadOnlyArray<SourceLocation> | void,
/**
* If an error can be associated to a particular field in the GraphQL result,
* it _must_ contain an entry with the key `path` that details the path of
* the response field which experienced the error. This allows clients to
* identify whether a null result is intentional or caused by a runtime error.
*/
+path: $ReadOnlyArray<string | number> | void,
/**
* Reserved for implementors to extend the protocol however they see fit,
* and hence there are no additional restrictions on its contents.
*/
+extensions?: { [key: string]: mixed, ... },
|};

26
node_modules/graphql/error/formatError.mjs generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import devAssert from '../jsutils/devAssert';
/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*/
export function formatError(error) {
error || devAssert(0, 'Received null or undefined error.');
var message = error.message || 'An unknown error occurred.';
var locations = error.locations;
var path = error.path;
var extensions = error.extensions;
return extensions ? {
message: message,
locations: locations,
path: path,
extensions: extensions
} : {
message: message,
locations: locations,
path: path
};
}
/**
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/

4
node_modules/graphql/error/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export { GraphQLError, printError } from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export { formatError, GraphQLFormattedError } from './formatError';

43
node_modules/graphql/error/index.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "GraphQLError", {
enumerable: true,
get: function get() {
return _GraphQLError.GraphQLError;
}
});
Object.defineProperty(exports, "printError", {
enumerable: true,
get: function get() {
return _GraphQLError.printError;
}
});
Object.defineProperty(exports, "syntaxError", {
enumerable: true,
get: function get() {
return _syntaxError.syntaxError;
}
});
Object.defineProperty(exports, "locatedError", {
enumerable: true,
get: function get() {
return _locatedError.locatedError;
}
});
Object.defineProperty(exports, "formatError", {
enumerable: true,
get: function get() {
return _formatError.formatError;
}
});
var _GraphQLError = require("./GraphQLError");
var _syntaxError = require("./syntaxError");
var _locatedError = require("./locatedError");
var _formatError = require("./formatError");

10
node_modules/graphql/error/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,10 @@
// @flow strict
export { GraphQLError, printError } from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export { formatError } from './formatError';
export type { GraphQLFormattedError } from './formatError';

4
node_modules/graphql/error/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export { GraphQLError, printError } from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export { formatError } from './formatError';

13
node_modules/graphql/error/locatedError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { ASTNode } from '../language/ast';
import { GraphQLError } from './GraphQLError';
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
export function locatedError(
originalError: Error | GraphQLError,
nodes: ReadonlyArray<ASTNode>,
path: ReadonlyArray<string | number>,
): GraphQLError;

23
node_modules/graphql/error/locatedError.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.locatedError = locatedError;
var _GraphQLError = require("./GraphQLError");
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
function locatedError(originalError, nodes, path) {
// Note: this uses a brand-check to support GraphQL errors originating from
// other contexts.
if (originalError && Array.isArray(originalError.path)) {
return originalError;
}
return new _GraphQLError.GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
}

31
node_modules/graphql/error/locatedError.js.flow generated vendored Normal file
View File

@@ -0,0 +1,31 @@
// @flow strict
import { type ASTNode } from '../language/ast';
import { GraphQLError } from './GraphQLError';
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
export function locatedError(
originalError: Error | GraphQLError,
nodes: $ReadOnlyArray<ASTNode>,
path: $ReadOnlyArray<string | number>,
): GraphQLError {
// Note: this uses a brand-check to support GraphQL errors originating from
// other contexts.
if (originalError && Array.isArray(originalError.path)) {
return (originalError: any);
}
return new GraphQLError(
originalError && originalError.message,
(originalError && (originalError: any).nodes) || nodes,
originalError && (originalError: any).source,
originalError && (originalError: any).positions,
path,
originalError,
);
}

16
node_modules/graphql/error/locatedError.mjs generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { GraphQLError } from './GraphQLError';
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
export function locatedError(originalError, nodes, path) {
// Note: this uses a brand-check to support GraphQL errors originating from
// other contexts.
if (originalError && Array.isArray(originalError.path)) {
return originalError;
}
return new GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
}

12
node_modules/graphql/error/syntaxError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Source } from '../language/source';
import { GraphQLError } from './GraphQLError';
/**
* Produces a GraphQLError representing a syntax error, containing useful
* descriptive information about the syntax error's position in the source.
*/
export function syntaxError(
source: Source,
position: number,
description: string,
): GraphQLError;

16
node_modules/graphql/error/syntaxError.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.syntaxError = syntaxError;
var _GraphQLError = require("./GraphQLError");
/**
* 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: ".concat(description), undefined, source, [position]);
}

19
node_modules/graphql/error/syntaxError.js.flow generated vendored Normal file
View File

@@ -0,0 +1,19 @@
// @flow strict
import { type Source } from '../language/source';
import { GraphQLError } from './GraphQLError';
/**
* Produces a GraphQLError representing a syntax error, containing useful
* descriptive information about the syntax error's position in the source.
*/
export function syntaxError(
source: Source,
position: number,
description: string,
): GraphQLError {
return new GraphQLError(`Syntax Error: ${description}`, undefined, source, [
position,
]);
}

9
node_modules/graphql/error/syntaxError.mjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { GraphQLError } from './GraphQLError';
/**
* Produces a GraphQLError representing a syntax error, containing useful
* descriptive information about the syntax error's position in the source.
*/
export function syntaxError(source, position, description) {
return new GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
}

198
node_modules/graphql/execution/execute.d.ts generated vendored Normal file
View File

@@ -0,0 +1,198 @@
import Maybe from '../tsutils/Maybe';
import { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { Path, addPath, pathToArray } from '../jsutils/Path';
import { GraphQLError } from '../error/GraphQLError';
import { GraphQLFormattedError } from '../error/formatError';
import {
DirectiveNode,
DocumentNode,
OperationDefinitionNode,
SelectionSetNode,
FieldNode,
InlineFragmentNode,
FragmentDefinitionNode,
} from '../language/ast';
import { GraphQLSchema } from '../type/schema';
import {
GraphQLField,
GraphQLFieldResolver,
GraphQLResolveInfo,
GraphQLTypeResolver,
GraphQLObjectType,
} from '../type/definition';
/**
* 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
*/
export interface ExecutionContext {
schema: GraphQLSchema;
fragments: { [key: string]: FragmentDefinitionNode };
rootValue: any;
contextValue: any;
operation: OperationDefinitionNode;
variableValues: { [key: string]: any };
fieldResolver: GraphQLFieldResolver<any, any>;
errors: GraphQLError[];
}
export interface ExecutionResultDataDefault {
[key: string]: any;
}
/**
* The result of GraphQL execution.
*
* - `errors` is included when any errors occurred as a non-empty array.
* - `data` is the result of a successful execution of the query.
*/
// TS_SPECIFIC: TData and ExecutionResultDataDefault
export interface ExecutionResult<TData = ExecutionResultDataDefault> {
errors?: ReadonlyArray<GraphQLError>;
data?: TData | null;
}
export interface FormattedExecutionResult<TData = ExecutionResultDataDefault> {
errors?: ReadonlyArray<GraphQLFormattedError>;
// TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
data?: TData | null;
}
export type ExecutionArgs = {
schema: GraphQLSchema;
document: DocumentNode;
rootValue?: any;
contextValue?: any;
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
};
/**
* Implements the "Evaluating requests" section of the GraphQL specification.
*
* Returns either a synchronous ExecutionResult (if all encountered resolvers
* are synchronous), or a Promise of an ExecutionResult that will eventually be
* resolved and never rejected.
*
* If the arguments to this function do not result in a legal execution context,
* a GraphQLError will be thrown immediately explaining the invalid input.
*
* Accepts either an object with named arguments, or individual arguments.
*/
export function execute<TData = ExecutionResultDataDefault>(
args: ExecutionArgs,
): PromiseOrValue<ExecutionResult<TData>>;
export function execute<TData = ExecutionResultDataDefault>(
schema: GraphQLSchema,
document: DocumentNode,
rootValue?: any,
contextValue?: any,
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): PromiseOrValue<ExecutionResult<TData>>;
/**
* Essential assertions before executing to provide developer feedback for
* improper use of the GraphQL library.
*/
export function assertValidExecutionArguments(
schema: GraphQLSchema,
document: DocumentNode,
rawVariableValues: Maybe<{ [key: string]: any }>,
): void;
/**
* 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.
*/
export function buildExecutionContext(
schema: GraphQLSchema,
document: DocumentNode,
rootValue: any,
contextValue: any,
rawVariableValues: Maybe<{ [key: string]: any }>,
operationName: Maybe<string>,
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): ReadonlyArray<GraphQLError> | ExecutionContext;
/**
* Given a selectionSet, adds all of the fields in that selection to
* the passed in map of fields, and returns it at the end.
*
* CollectFields requires the "runtime type" of an object. For a field which
* returns an Interface or Union type, the "runtime type" will be the actual
* Object type returned by that field.
*/
export function collectFields(
exeContext: ExecutionContext,
runtimeType: GraphQLObjectType,
selectionSet: SelectionSetNode,
fields: { [key: string]: Array<FieldNode> },
visitedFragmentNames: { [key: string]: boolean },
): { [key: string]: Array<FieldNode> };
export function buildResolveInfo(
exeContext: ExecutionContext,
fieldDef: GraphQLField<any, any>,
fieldNodes: ReadonlyArray<FieldNode>,
parentType: GraphQLObjectType,
path: Path,
): GraphQLResolveInfo;
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
// TS_SPECIFIC: TSource
export function resolveFieldValueOrError<TSource>(
exeContext: ExecutionContext,
fieldDef: GraphQLField<TSource, any>,
fieldNodes: ReadonlyArray<FieldNode>,
resolveFn: GraphQLFieldResolver<TSource, any>,
source: TSource,
info: GraphQLResolveInfo,
): Error | any;
/**
* If a resolveType function is not given, then a default resolve behavior is
* used which attempts two strategies:
*
* First, See if the provided value has a `__typename` field defined, if so, use
* that value as name of the resolved type.
*
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export const defaultTypeResolver: GraphQLTypeResolver<any, any>;
/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context.
*/
export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
/**
* This method looks up the field on the given type defintion.
* It has special casing for the two introspection fields, __schema
* 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 could get automatically
* added to the query type, but that would require mutating type
* definitions, which would cause issues.
*/
export function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLObjectType,
fieldName: string,
): Maybe<GraphQLField<any, any>>;

829
node_modules/graphql/execution/execute.js generated vendored Normal file
View File

@@ -0,0 +1,829 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.execute = execute;
exports.assertValidExecutionArguments = assertValidExecutionArguments;
exports.buildExecutionContext = buildExecutionContext;
exports.collectFields = collectFields;
exports.buildResolveInfo = buildResolveInfo;
exports.resolveFieldValueOrError = resolveFieldValueOrError;
exports.getFieldDef = getFieldDef;
exports.defaultFieldResolver = exports.defaultTypeResolver = void 0;
var _iterall = require("iterall");
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
var _memoize = _interopRequireDefault(require("../jsutils/memoize3"));
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike"));
var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce"));
var _promiseForObject = _interopRequireDefault(require("../jsutils/promiseForObject"));
var _Path = require("../jsutils/Path");
var _GraphQLError = require("../error/GraphQLError");
var _locatedError = require("../error/locatedError");
var _kinds = require("../language/kinds");
var _validate = require("../type/validate");
var _introspection = require("../type/introspection");
var _directives = require("../type/directives");
var _definition = require("../type/definition");
var _typeFromAST = require("../utilities/typeFromAST");
var _getOperationRootType = require("../utilities/getOperationRootType");
var _values = require("./values");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function execute(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
/* eslint-enable no-redeclare */
// Extract arguments from object args if provided.
return arguments.length === 1 ? executeImpl(argsOrSchema) : executeImpl({
schema: argsOrSchema,
document: document,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
});
}
function executeImpl(args) {
var schema = args.schema,
document = args.document,
rootValue = args.rootValue,
contextValue = args.contextValue,
variableValues = args.variableValues,
operationName = args.operationName,
fieldResolver = args.fieldResolver,
typeResolver = args.typeResolver; // 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.
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Return early errors if execution context failed.
if (Array.isArray(exeContext)) {
return {
errors: exeContext
};
} // Return a Promise that will eventually resolve to the data described by
// The "Response" section of the GraphQL specification.
//
// If errors are encountered while executing a GraphQL field, only that
// field and its descendants will be omitted, and sibling fields will still
// be executed. An execution which encounters errors will still result in a
// resolved Promise.
var data = executeOperation(exeContext, exeContext.operation, rootValue);
return buildResponse(exeContext, data);
}
/**
* Given a completed execution context and data, build the { errors, data }
* response defined by the "Response" section of the GraphQL specification.
*/
function buildResponse(exeContext, data) {
if ((0, _isPromise.default)(data)) {
return data.then(function (resolved) {
return buildResponse(exeContext, resolved);
});
}
return exeContext.errors.length === 0 ? {
data: data
} : {
errors: exeContext.errors,
data: data
};
}
/**
* Essential assertions before executing to provide developer feedback for
* improper use of the GraphQL library.
*/
function assertValidExecutionArguments(schema, document, rawVariableValues) {
document || (0, _devAssert.default)(0, '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.default)(rawVariableValues) || (0, _devAssert.default)(0, '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.
*/
function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
var operation;
var hasMultipleAssumedOperations = false;
var fragments = Object.create(null);
for (var _i2 = 0, _document$definitions2 = document.definitions; _i2 < _document$definitions2.length; _i2++) {
var definition = _document$definitions2[_i2];
switch (definition.kind) {
case _kinds.Kind.OPERATION_DEFINITION:
if (!operationName && operation) {
hasMultipleAssumedOperations = true;
} else if (!operationName || definition.name && definition.name.value === operationName) {
operation = definition;
}
break;
case _kinds.Kind.FRAGMENT_DEFINITION:
fragments[definition.name.value] = definition;
break;
}
}
if (!operation) {
if (operationName) {
return [new _GraphQLError.GraphQLError("Unknown operation named \"".concat(operationName, "\"."))];
}
return [new _GraphQLError.GraphQLError('Must provide an operation.')];
}
if (hasMultipleAssumedOperations) {
return [new _GraphQLError.GraphQLError('Must provide operation name if query contains multiple operations.')];
}
var coercedVariableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {}, {
maxErrors: 50
});
if (coercedVariableValues.errors) {
return coercedVariableValues.errors;
}
return {
schema: schema,
fragments: fragments,
rootValue: rootValue,
contextValue: contextValue,
operation: operation,
variableValues: coercedVariableValues.coerced,
fieldResolver: fieldResolver || defaultFieldResolver,
typeResolver: typeResolver || defaultTypeResolver,
errors: []
};
}
/**
* Implements the "Evaluating operations" section of the spec.
*/
function executeOperation(exeContext, operation, rootValue) {
var type = (0, _getOperationRootType.getOperationRootType)(exeContext.schema, operation);
var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
var path = undefined; // 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.
//
// Similar to completeValueCatchingError.
try {
var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
if ((0, _isPromise.default)(result)) {
return result.then(undefined, function (error) {
exeContext.errors.push(error);
return Promise.resolve(null);
});
}
return result;
} catch (error) {
exeContext.errors.push(error);
return null;
}
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "write" mode.
*/
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
return (0, _promiseReduce.default)(Object.keys(fields), function (results, responseName) {
var fieldNodes = fields[responseName];
var fieldPath = (0, _Path.addPath)(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result === undefined) {
return results;
}
if ((0, _isPromise.default)(result)) {
return result.then(function (resolvedResult) {
results[responseName] = resolvedResult;
return results;
});
}
results[responseName] = result;
return results;
}, Object.create(null));
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "read" mode.
*/
function executeFields(exeContext, parentType, sourceValue, path, fields) {
var results = Object.create(null);
var containsPromise = false;
for (var _i4 = 0, _Object$keys2 = Object.keys(fields); _i4 < _Object$keys2.length; _i4++) {
var responseName = _Object$keys2[_i4];
var fieldNodes = fields[responseName];
var fieldPath = (0, _Path.addPath)(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result !== undefined) {
results[responseName] = result;
if (!containsPromise && (0, _isPromise.default)(result)) {
containsPromise = true;
}
}
} // If there are no promises, we can just return the object
if (!containsPromise) {
return results;
} // Otherwise, results is a map from field name to the result of resolving that
// field, which is possibly a promise. Return a promise that will return this
// same map, but with any promises replaced with the values they resolved to.
return (0, _promiseForObject.default)(results);
}
/**
* Given a selectionSet, adds all of the fields in that selection to
* the passed in map of fields, and returns it at the end.
*
* CollectFields requires the "runtime type" of an object. For a field which
* returns an Interface or Union type, the "runtime type" will be the actual
* Object type returned by that field.
*/
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
var selection = _selectionSet$selecti2[_i6];
switch (selection.kind) {
case _kinds.Kind.FIELD:
{
if (!shouldIncludeNode(exeContext, selection)) {
continue;
}
var name = getFieldEntryKey(selection);
if (!fields[name]) {
fields[name] = [];
}
fields[name].push(selection);
break;
}
case _kinds.Kind.INLINE_FRAGMENT:
{
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
break;
}
case _kinds.Kind.FRAGMENT_SPREAD:
{
var fragName = selection.name.value;
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
continue;
}
visitedFragmentNames[fragName] = true;
var fragment = exeContext.fragments[fragName];
if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
break;
}
}
}
return fields;
}
/**
* Determines if a field should be included based on the @include and @skip
* directives, where @skip has higher precedence than @include.
*/
function shouldIncludeNode(exeContext, node) {
var skip = (0, _values.getDirectiveValues)(_directives.GraphQLSkipDirective, node, exeContext.variableValues);
if (skip && skip.if === true) {
return false;
}
var include = (0, _values.getDirectiveValues)(_directives.GraphQLIncludeDirective, node, exeContext.variableValues);
if (include && include.if === false) {
return false;
}
return true;
}
/**
* Determines if a fragment is applicable to the given type.
*/
function doesFragmentConditionMatch(exeContext, fragment, type) {
var typeConditionNode = fragment.typeCondition;
if (!typeConditionNode) {
return true;
}
var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
if (conditionalType === type) {
return true;
}
if ((0, _definition.isAbstractType)(conditionalType)) {
return exeContext.schema.isPossibleType(conditionalType, type);
}
return false;
}
/**
* Implements the logic to compute the key of a given field's entry
*/
function getFieldEntryKey(node) {
return node.alias ? node.alias.value : node.name.value;
}
/**
* Resolves the field on the given source object. In particular, this
* figures out the value that the field returns by calling its resolve function,
* then calls completeValue to complete promises, serialize scalars, or execute
* the sub-selection-set for objects.
*/
function resolveField(exeContext, parentType, source, fieldNodes, path) {
var fieldNode = fieldNodes[0];
var fieldName = fieldNode.name.value;
var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
if (!fieldDef) {
return;
}
var resolveFn = fieldDef.resolve || exeContext.fieldResolver;
var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
// or abrupt (error).
var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
}
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
// The resolve function's optional fourth argument is a collection of
// information about the current execution state.
return {
fieldName: fieldDef.name,
fieldNodes: fieldNodes,
returnType: fieldDef.type,
parentType: parentType,
path: path,
schema: exeContext.schema,
fragments: exeContext.fragments,
rootValue: exeContext.rootValue,
operation: exeContext.operation,
variableValues: exeContext.variableValues
};
} // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
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.
var 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.
var _contextValue = exeContext.contextValue;
var result = resolveFn(source, args, _contextValue, info);
return (0, _isPromise.default)(result) ? result.then(undefined, asErrorInstance) : result;
} catch (error) {
return asErrorInstance(error);
}
} // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
// consistent Error interface.
function asErrorInstance(error) {
if (error instanceof Error) {
return error;
}
return new Error('Unexpected error value: ' + (0, _inspect.default)(error));
} // This is a small wrapper around completeValue which detects and logs errors
// in the execution context.
function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
try {
var completed;
if ((0, _isPromise.default)(result)) {
completed = result.then(function (resolved) {
return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
});
} else {
completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
}
if ((0, _isPromise.default)(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, function (error) {
return handleFieldError(error, fieldNodes, path, returnType, exeContext);
});
}
return completed;
} catch (error) {
return handleFieldError(error, fieldNodes, path, returnType, exeContext);
}
}
function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
var error = (0, _locatedError.locatedError)(asErrorInstance(rawError), fieldNodes, (0, _Path.pathToArray)(path)); // If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
if ((0, _definition.isNonNullType)(returnType)) {
throw error;
} // Otherwise, error protection is applied, logging the error and resolving
// a null value for this field if one is encountered.
exeContext.errors.push(error);
return null;
}
/**
* Implements the instructions for completeValue as defined in the
* "Field entries" section of the spec.
*
* If the field type is Non-Null, then this recursively completes the value
* for the inner type. It throws a field error if that completion returns null,
* as per the "Nullability" section of the spec.
*
* If the field type is a List, then this recursively completes the value
* for the inner type on each item in the list.
*
* If the field type is a Scalar or Enum, ensures the completed value is a legal
* value of the type by calling the `serialize` method of GraphQL type
* definition.
*
* If the field is an abstract type, determine the runtime type of the value
* and then complete based on that type
*
* Otherwise, the field type expects a sub-selection set, and will complete the
* value by evaluating all sub-selections.
*/
function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
// If result is an Error, throw a located error.
if (result instanceof Error) {
throw result;
} // If field type is NonNull, complete for inner type, and throw field error
// if result is null.
if ((0, _definition.isNonNullType)(returnType)) {
var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
if (completed === null) {
throw new Error("Cannot return null for non-nullable field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
}
return completed;
} // If result value is null-ish (null, undefined, or NaN) then return null.
if ((0, _isNullish.default)(result)) {
return null;
} // If field type is List, complete each item in the list with the inner type
if ((0, _definition.isListType)(returnType)) {
return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
} // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if ((0, _definition.isLeafType)(returnType)) {
return completeLeafValue(returnType, result);
} // If field type is an abstract type, Interface or Union, determine the
// runtime Object type and complete for that type.
if ((0, _definition.isAbstractType)(returnType)) {
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
} // If field type is Object, execute and complete all sub-selections.
/* istanbul ignore else */
if ((0, _definition.isObjectType)(returnType)) {
return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
} // Not reachable. All possible output types have been considered.
/* istanbul ignore next */
(0, _invariant.default)(false, 'Cannot complete value of unexpected output type: ' + (0, _inspect.default)(returnType));
}
/**
* Complete a list value by completing each item in the list with the
* inner type
*/
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
if (!(0, _iterall.isCollection)(result)) {
throw new _GraphQLError.GraphQLError("Expected Iterable, but did not find one for field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
} // This is specified as a simple map, however we're optimizing the path
// where the list contains no Promises by avoiding creating another Promise.
var itemType = returnType.ofType;
var containsPromise = false;
var completedResults = [];
(0, _iterall.forEach)(result, function (item, index) {
// No need to modify the info object containing the path,
// since from here on it is not ever accessed by resolver functions.
var fieldPath = (0, _Path.addPath)(path, index);
var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
if (!containsPromise && (0, _isPromise.default)(completedItem)) {
containsPromise = true;
}
completedResults.push(completedItem);
});
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) {
var serializedResult = returnType.serialize(result);
if ((0, _isInvalid.default)(serializedResult)) {
throw new Error("Expected a value of type \"".concat((0, _inspect.default)(returnType), "\" but ") + "received: ".concat((0, _inspect.default)(result)));
}
return serializedResult;
}
/**
* Complete a value of an abstract type by determining the runtime object type
* of that value, then complete the value for that type.
*/
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
var resolveTypeFn = returnType.resolveType || exeContext.typeResolver;
var contextValue = exeContext.contextValue;
var runtimeType = resolveTypeFn(result, contextValue, info, returnType);
if ((0, _isPromise.default)(runtimeType)) {
return runtimeType.then(function (resolvedRuntimeType) {
return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
});
}
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
}
function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
if (!(0, _definition.isObjectType)(runtimeType)) {
throw new _GraphQLError.GraphQLError("Abstract type ".concat(returnType.name, " must resolve to an Object type at runtime for field ").concat(info.parentType.name, ".").concat(info.fieldName, " with ") + "value ".concat((0, _inspect.default)(result), ", received \"").concat((0, _inspect.default)(runtimeType), "\". ") + "Either the ".concat(returnType.name, " type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."), fieldNodes);
}
if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
throw new _GraphQLError.GraphQLError("Runtime Object type \"".concat(runtimeType.name, "\" is not a possible type for \"").concat(returnType.name, "\"."), fieldNodes);
}
return runtimeType;
}
/**
* Complete an Object value by executing all sub-selections.
*/
function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
// 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) {
var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
if ((0, _isPromise.default)(isTypeOf)) {
return isTypeOf.then(function (resolvedIsTypeOf) {
if (!resolvedIsTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
});
}
if (!isTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
}
function invalidReturnTypeError(returnType, result, fieldNodes) {
return new _GraphQLError.GraphQLError("Expected value of type \"".concat(returnType.name, "\" but got: ").concat((0, _inspect.default)(result), "."), fieldNodes);
}
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result) {
// Collect sub-fields to execute to complete this value.
var subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
return executeFields(exeContext, returnType, result, path, subFieldNodes);
}
/**
* 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.
*/
var collectSubfields = (0, _memoize.default)(_collectSubfields);
function _collectSubfields(exeContext, returnType, fieldNodes) {
var subFieldNodes = Object.create(null);
var visitedFragmentNames = Object.create(null);
for (var _i8 = 0; _i8 < fieldNodes.length; _i8++) {
var node = fieldNodes[_i8];
if (node.selectionSet) {
subFieldNodes = collectFields(exeContext, returnType, node.selectionSet, subFieldNodes, visitedFragmentNames);
}
}
return subFieldNodes;
}
/**
* If a resolveType function is not given, then a default resolve behavior is
* used which attempts two strategies:
*
* First, See if the provided value has a `__typename` field defined, if so, use
* that value as name of the resolved type.
*
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info, abstractType) {
// First, look for `__typename`.
if ((0, _isObjectLike.default)(value) && typeof value.__typename === 'string') {
return value.__typename;
} // Otherwise, test each possible type.
var possibleTypes = info.schema.getPossibleTypes(abstractType);
var promisedIsTypeOfResults = [];
for (var i = 0; i < possibleTypes.length; i++) {
var type = possibleTypes[i];
if (type.isTypeOf) {
var isTypeOfResult = type.isTypeOf(value, contextValue, info);
if ((0, _isPromise.default)(isTypeOfResult)) {
promisedIsTypeOfResults[i] = isTypeOfResult;
} else if (isTypeOfResult) {
return type;
}
}
}
if (promisedIsTypeOfResults.length) {
return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
for (var _i9 = 0; _i9 < isTypeOfResults.length; _i9++) {
if (isTypeOfResults[_i9]) {
return possibleTypes[_i9];
}
}
});
}
};
/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context value.
*/
exports.defaultTypeResolver = defaultTypeResolver;
var defaultFieldResolver = function defaultFieldResolver(source, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if ((0, _isObjectLike.default)(source) || typeof source === 'function') {
var property = source[info.fieldName];
if (typeof property === 'function') {
return source[info.fieldName](args, contextValue, info);
}
return property;
}
};
/**
* This method looks up the field on the given type definition.
* It has special casing for the two introspection fields, __schema
* 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 could get automatically
* added to the query type, but that would require mutating type
* definitions, which would cause issues.
*/
exports.defaultFieldResolver = defaultFieldResolver;
function getFieldDef(schema, parentType, fieldName) {
if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.SchemaMetaFieldDef;
} else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
return _introspection.TypeMetaFieldDef;
} else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
return _introspection.TypeNameMetaFieldDef;
}
return parentType.getFields()[fieldName];
}

1227
node_modules/graphql/execution/execute.js.flow generated vendored Normal file

File diff suppressed because it is too large Load Diff

807
node_modules/graphql/execution/execute.mjs generated vendored Normal file
View File

@@ -0,0 +1,807 @@
import { forEach, isCollection } from 'iterall';
import inspect from '../jsutils/inspect';
import memoize3 from '../jsutils/memoize3';
import invariant from '../jsutils/invariant';
import devAssert from '../jsutils/devAssert';
import isInvalid from '../jsutils/isInvalid';
import isNullish from '../jsutils/isNullish';
import isPromise from '../jsutils/isPromise';
import isObjectLike from '../jsutils/isObjectLike';
import promiseReduce from '../jsutils/promiseReduce';
import promiseForObject from '../jsutils/promiseForObject';
import { addPath, pathToArray } from '../jsutils/Path';
import { GraphQLError } from '../error/GraphQLError';
import { locatedError } from '../error/locatedError';
import { Kind } from '../language/kinds';
import { assertValidSchema } from '../type/validate';
import { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from '../type/introspection';
import { GraphQLIncludeDirective, GraphQLSkipDirective } from '../type/directives';
import { isObjectType, isAbstractType, isLeafType, isListType, isNonNullType } from '../type/definition';
import { typeFromAST } from '../utilities/typeFromAST';
import { getOperationRootType } from '../utilities/getOperationRootType';
import { getVariableValues, getArgumentValues, getDirectiveValues } from './values';
/**
* 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
*/
export function execute(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
/* eslint-enable no-redeclare */
// Extract arguments from object args if provided.
return arguments.length === 1 ? executeImpl(argsOrSchema) : executeImpl({
schema: argsOrSchema,
document: document,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
});
}
function executeImpl(args) {
var schema = args.schema,
document = args.document,
rootValue = args.rootValue,
contextValue = args.contextValue,
variableValues = args.variableValues,
operationName = args.operationName,
fieldResolver = args.fieldResolver,
typeResolver = args.typeResolver; // 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.
var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Return early errors if execution context failed.
if (Array.isArray(exeContext)) {
return {
errors: exeContext
};
} // Return a Promise that will eventually resolve to the data described by
// The "Response" section of the GraphQL specification.
//
// If errors are encountered while executing a GraphQL field, only that
// field and its descendants will be omitted, and sibling fields will still
// be executed. An execution which encounters errors will still result in a
// resolved Promise.
var data = executeOperation(exeContext, exeContext.operation, rootValue);
return buildResponse(exeContext, data);
}
/**
* Given a completed execution context and data, build the { errors, data }
* response defined by the "Response" section of the GraphQL specification.
*/
function buildResponse(exeContext, data) {
if (isPromise(data)) {
return data.then(function (resolved) {
return buildResponse(exeContext, resolved);
});
}
return exeContext.errors.length === 0 ? {
data: data
} : {
errors: exeContext.errors,
data: data
};
}
/**
* Essential assertions before executing to provide developer feedback for
* improper use of the GraphQL library.
*/
export function assertValidExecutionArguments(schema, document, rawVariableValues) {
document || devAssert(0, 'Must provide document'); // If the schema used for execution is invalid, throw an error.
assertValidSchema(schema); // Variables, if provided, must be an object.
rawVariableValues == null || isObjectLike(rawVariableValues) || devAssert(0, '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.
*/
export function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
var operation;
var hasMultipleAssumedOperations = false;
var fragments = Object.create(null);
for (var _i2 = 0, _document$definitions2 = document.definitions; _i2 < _document$definitions2.length; _i2++) {
var definition = _document$definitions2[_i2];
switch (definition.kind) {
case Kind.OPERATION_DEFINITION:
if (!operationName && operation) {
hasMultipleAssumedOperations = true;
} else if (!operationName || definition.name && definition.name.value === operationName) {
operation = definition;
}
break;
case Kind.FRAGMENT_DEFINITION:
fragments[definition.name.value] = definition;
break;
}
}
if (!operation) {
if (operationName) {
return [new GraphQLError("Unknown operation named \"".concat(operationName, "\"."))];
}
return [new GraphQLError('Must provide an operation.')];
}
if (hasMultipleAssumedOperations) {
return [new GraphQLError('Must provide operation name if query contains multiple operations.')];
}
var coercedVariableValues = getVariableValues(schema, operation.variableDefinitions || [], rawVariableValues || {}, {
maxErrors: 50
});
if (coercedVariableValues.errors) {
return coercedVariableValues.errors;
}
return {
schema: schema,
fragments: fragments,
rootValue: rootValue,
contextValue: contextValue,
operation: operation,
variableValues: coercedVariableValues.coerced,
fieldResolver: fieldResolver || defaultFieldResolver,
typeResolver: typeResolver || defaultTypeResolver,
errors: []
};
}
/**
* Implements the "Evaluating operations" section of the spec.
*/
function executeOperation(exeContext, operation, rootValue) {
var type = getOperationRootType(exeContext.schema, operation);
var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
var path = undefined; // 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.
//
// Similar to completeValueCatchingError.
try {
var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
if (isPromise(result)) {
return result.then(undefined, function (error) {
exeContext.errors.push(error);
return Promise.resolve(null);
});
}
return result;
} catch (error) {
exeContext.errors.push(error);
return null;
}
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "write" mode.
*/
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
return promiseReduce(Object.keys(fields), function (results, responseName) {
var fieldNodes = fields[responseName];
var fieldPath = addPath(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result === undefined) {
return results;
}
if (isPromise(result)) {
return result.then(function (resolvedResult) {
results[responseName] = resolvedResult;
return results;
});
}
results[responseName] = result;
return results;
}, Object.create(null));
}
/**
* Implements the "Evaluating selection sets" section of the spec
* for "read" mode.
*/
function executeFields(exeContext, parentType, sourceValue, path, fields) {
var results = Object.create(null);
var containsPromise = false;
for (var _i4 = 0, _Object$keys2 = Object.keys(fields); _i4 < _Object$keys2.length; _i4++) {
var responseName = _Object$keys2[_i4];
var fieldNodes = fields[responseName];
var fieldPath = addPath(path, responseName);
var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
if (result !== undefined) {
results[responseName] = result;
if (!containsPromise && isPromise(result)) {
containsPromise = true;
}
}
} // If there are no promises, we can just return the object
if (!containsPromise) {
return results;
} // Otherwise, results is a map from field name to the result of resolving that
// field, which is possibly a promise. Return a promise that will return this
// same map, but with any promises replaced with the values they resolved to.
return promiseForObject(results);
}
/**
* Given a selectionSet, adds all of the fields in that selection to
* the passed in map of fields, and returns it at the end.
*
* CollectFields requires the "runtime type" of an object. For a field which
* returns an Interface or Union type, the "runtime type" will be the actual
* Object type returned by that field.
*/
export function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
var selection = _selectionSet$selecti2[_i6];
switch (selection.kind) {
case Kind.FIELD:
{
if (!shouldIncludeNode(exeContext, selection)) {
continue;
}
var name = getFieldEntryKey(selection);
if (!fields[name]) {
fields[name] = [];
}
fields[name].push(selection);
break;
}
case Kind.INLINE_FRAGMENT:
{
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
break;
}
case Kind.FRAGMENT_SPREAD:
{
var fragName = selection.name.value;
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
continue;
}
visitedFragmentNames[fragName] = true;
var fragment = exeContext.fragments[fragName];
if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
continue;
}
collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
break;
}
}
}
return fields;
}
/**
* Determines if a field should be included based on the @include and @skip
* directives, where @skip has higher precedence than @include.
*/
function shouldIncludeNode(exeContext, node) {
var skip = getDirectiveValues(GraphQLSkipDirective, node, exeContext.variableValues);
if (skip && skip.if === true) {
return false;
}
var include = getDirectiveValues(GraphQLIncludeDirective, node, exeContext.variableValues);
if (include && include.if === false) {
return false;
}
return true;
}
/**
* Determines if a fragment is applicable to the given type.
*/
function doesFragmentConditionMatch(exeContext, fragment, type) {
var typeConditionNode = fragment.typeCondition;
if (!typeConditionNode) {
return true;
}
var conditionalType = typeFromAST(exeContext.schema, typeConditionNode);
if (conditionalType === type) {
return true;
}
if (isAbstractType(conditionalType)) {
return exeContext.schema.isPossibleType(conditionalType, type);
}
return false;
}
/**
* Implements the logic to compute the key of a given field's entry
*/
function getFieldEntryKey(node) {
return node.alias ? node.alias.value : node.name.value;
}
/**
* Resolves the field on the given source object. In particular, this
* figures out the value that the field returns by calling its resolve function,
* then calls completeValue to complete promises, serialize scalars, or execute
* the sub-selection-set for objects.
*/
function resolveField(exeContext, parentType, source, fieldNodes, path) {
var fieldNode = fieldNodes[0];
var fieldName = fieldNode.name.value;
var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
if (!fieldDef) {
return;
}
var resolveFn = fieldDef.resolve || exeContext.fieldResolver;
var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
// or abrupt (error).
var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
}
export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
// The resolve function's optional fourth argument is a collection of
// information about the current execution state.
return {
fieldName: fieldDef.name,
fieldNodes: fieldNodes,
returnType: fieldDef.type,
parentType: parentType,
path: path,
schema: exeContext.schema,
fragments: exeContext.fragments,
rootValue: exeContext.rootValue,
operation: exeContext.operation,
variableValues: exeContext.variableValues
};
} // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
export function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
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.
var args = 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.
var _contextValue = exeContext.contextValue;
var result = resolveFn(source, args, _contextValue, info);
return isPromise(result) ? result.then(undefined, asErrorInstance) : result;
} catch (error) {
return asErrorInstance(error);
}
} // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
// consistent Error interface.
function asErrorInstance(error) {
if (error instanceof Error) {
return error;
}
return new Error('Unexpected error value: ' + inspect(error));
} // This is a small wrapper around completeValue which detects and logs errors
// in the execution context.
function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
try {
var completed;
if (isPromise(result)) {
completed = result.then(function (resolved) {
return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
});
} else {
completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
}
if (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, function (error) {
return handleFieldError(error, fieldNodes, path, returnType, exeContext);
});
}
return completed;
} catch (error) {
return handleFieldError(error, fieldNodes, path, returnType, exeContext);
}
}
function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
var error = locatedError(asErrorInstance(rawError), fieldNodes, pathToArray(path)); // If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
if (isNonNullType(returnType)) {
throw error;
} // Otherwise, error protection is applied, logging the error and resolving
// a null value for this field if one is encountered.
exeContext.errors.push(error);
return null;
}
/**
* Implements the instructions for completeValue as defined in the
* "Field entries" section of the spec.
*
* If the field type is Non-Null, then this recursively completes the value
* for the inner type. It throws a field error if that completion returns null,
* as per the "Nullability" section of the spec.
*
* If the field type is a List, then this recursively completes the value
* for the inner type on each item in the list.
*
* If the field type is a Scalar or Enum, ensures the completed value is a legal
* value of the type by calling the `serialize` method of GraphQL type
* definition.
*
* If the field is an abstract type, determine the runtime type of the value
* and then complete based on that type
*
* Otherwise, the field type expects a sub-selection set, and will complete the
* value by evaluating all sub-selections.
*/
function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
// If result is an Error, throw a located error.
if (result instanceof Error) {
throw result;
} // If field type is NonNull, complete for inner type, and throw field error
// if result is null.
if (isNonNullType(returnType)) {
var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
if (completed === null) {
throw new Error("Cannot return null for non-nullable field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
}
return completed;
} // If result value is null-ish (null, undefined, or NaN) then return null.
if (isNullish(result)) {
return null;
} // If field type is List, complete each item in the list with the inner type
if (isListType(returnType)) {
return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
} // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if (isLeafType(returnType)) {
return completeLeafValue(returnType, result);
} // If field type is an abstract type, Interface or Union, determine the
// runtime Object type and complete for that type.
if (isAbstractType(returnType)) {
return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
} // If field type is Object, execute and complete all sub-selections.
/* istanbul ignore else */
if (isObjectType(returnType)) {
return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
} // Not reachable. All possible output types have been considered.
/* istanbul ignore next */
invariant(false, 'Cannot complete value of unexpected output type: ' + inspect(returnType));
}
/**
* Complete a list value by completing each item in the list with the
* inner type
*/
function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
if (!isCollection(result)) {
throw new GraphQLError("Expected Iterable, but did not find one for field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
} // This is specified as a simple map, however we're optimizing the path
// where the list contains no Promises by avoiding creating another Promise.
var itemType = returnType.ofType;
var containsPromise = false;
var completedResults = [];
forEach(result, function (item, index) {
// No need to modify the info object containing the path,
// since from here on it is not ever accessed by resolver functions.
var fieldPath = addPath(path, index);
var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
if (!containsPromise && isPromise(completedItem)) {
containsPromise = true;
}
completedResults.push(completedItem);
});
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) {
var serializedResult = returnType.serialize(result);
if (isInvalid(serializedResult)) {
throw new Error("Expected a value of type \"".concat(inspect(returnType), "\" but ") + "received: ".concat(inspect(result)));
}
return serializedResult;
}
/**
* Complete a value of an abstract type by determining the runtime object type
* of that value, then complete the value for that type.
*/
function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
var resolveTypeFn = returnType.resolveType || exeContext.typeResolver;
var contextValue = exeContext.contextValue;
var runtimeType = resolveTypeFn(result, contextValue, info, returnType);
if (isPromise(runtimeType)) {
return runtimeType.then(function (resolvedRuntimeType) {
return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
});
}
return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
}
function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
if (!isObjectType(runtimeType)) {
throw new GraphQLError("Abstract type ".concat(returnType.name, " must resolve to an Object type at runtime for field ").concat(info.parentType.name, ".").concat(info.fieldName, " with ") + "value ".concat(inspect(result), ", received \"").concat(inspect(runtimeType), "\". ") + "Either the ".concat(returnType.name, " type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."), fieldNodes);
}
if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
throw new GraphQLError("Runtime Object type \"".concat(runtimeType.name, "\" is not a possible type for \"").concat(returnType.name, "\"."), fieldNodes);
}
return runtimeType;
}
/**
* Complete an Object value by executing all sub-selections.
*/
function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
// 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) {
var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
if (isPromise(isTypeOf)) {
return isTypeOf.then(function (resolvedIsTypeOf) {
if (!resolvedIsTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
});
}
if (!isTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
}
return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
}
function invalidReturnTypeError(returnType, result, fieldNodes) {
return new GraphQLError("Expected value of type \"".concat(returnType.name, "\" but got: ").concat(inspect(result), "."), fieldNodes);
}
function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result) {
// Collect sub-fields to execute to complete this value.
var subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
return executeFields(exeContext, returnType, result, path, subFieldNodes);
}
/**
* 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.
*/
var collectSubfields = memoize3(_collectSubfields);
function _collectSubfields(exeContext, returnType, fieldNodes) {
var subFieldNodes = Object.create(null);
var visitedFragmentNames = Object.create(null);
for (var _i8 = 0; _i8 < fieldNodes.length; _i8++) {
var node = fieldNodes[_i8];
if (node.selectionSet) {
subFieldNodes = collectFields(exeContext, returnType, node.selectionSet, subFieldNodes, visitedFragmentNames);
}
}
return subFieldNodes;
}
/**
* If a resolveType function is not given, then a default resolve behavior is
* used which attempts two strategies:
*
* First, See if the provided value has a `__typename` field defined, if so, use
* that value as name of the resolved type.
*
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info, abstractType) {
// First, look for `__typename`.
if (isObjectLike(value) && typeof value.__typename === 'string') {
return value.__typename;
} // Otherwise, test each possible type.
var possibleTypes = info.schema.getPossibleTypes(abstractType);
var promisedIsTypeOfResults = [];
for (var i = 0; i < possibleTypes.length; i++) {
var type = possibleTypes[i];
if (type.isTypeOf) {
var isTypeOfResult = type.isTypeOf(value, contextValue, info);
if (isPromise(isTypeOfResult)) {
promisedIsTypeOfResults[i] = isTypeOfResult;
} else if (isTypeOfResult) {
return type;
}
}
}
if (promisedIsTypeOfResults.length) {
return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
for (var _i9 = 0; _i9 < isTypeOfResults.length; _i9++) {
if (isTypeOfResults[_i9]) {
return possibleTypes[_i9];
}
}
});
}
};
/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context value.
*/
export var defaultFieldResolver = function defaultFieldResolver(source, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if (isObjectLike(source) || typeof source === 'function') {
var property = source[info.fieldName];
if (typeof property === 'function') {
return source[info.fieldName](args, contextValue, info);
}
return property;
}
};
/**
* This method looks up the field on the given type definition.
* It has special casing for the two introspection fields, __schema
* 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 could get automatically
* added to the query type, but that would require mutating type
* definitions, which would cause issues.
*/
export function getFieldDef(schema, parentType, fieldName) {
if (fieldName === SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
return SchemaMetaFieldDef;
} else if (fieldName === TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
return TypeMetaFieldDef;
} else if (fieldName === TypeNameMetaFieldDef.name) {
return TypeNameMetaFieldDef;
}
return parentType.getFields()[fieldName];
}

12
node_modules/graphql/execution/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
export { pathToArray as responsePathAsArray } from '../jsutils/Path';
export {
execute,
defaultFieldResolver,
defaultTypeResolver,
ExecutionArgs,
ExecutionResult,
FormattedExecutionResult,
} from './execute';
export { getDirectiveValues } from './values';

41
node_modules/graphql/execution/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "responsePathAsArray", {
enumerable: true,
get: function get() {
return _Path.pathToArray;
}
});
Object.defineProperty(exports, "execute", {
enumerable: true,
get: function get() {
return _execute.execute;
}
});
Object.defineProperty(exports, "defaultFieldResolver", {
enumerable: true,
get: function get() {
return _execute.defaultFieldResolver;
}
});
Object.defineProperty(exports, "defaultTypeResolver", {
enumerable: true,
get: function get() {
return _execute.defaultTypeResolver;
}
});
Object.defineProperty(exports, "getDirectiveValues", {
enumerable: true,
get: function get() {
return _values.getDirectiveValues;
}
});
var _Path = require("../jsutils/Path");
var _execute = require("./execute");
var _values = require("./values");

12
node_modules/graphql/execution/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,12 @@
// @flow strict
export { pathToArray as responsePathAsArray } from '../jsutils/Path';
export { execute, defaultFieldResolver, defaultTypeResolver } from './execute';
export type {
ExecutionArgs,
ExecutionResult,
FormattedExecutionResult,
} from './execute';
export { getDirectiveValues } from './values';

3
node_modules/graphql/execution/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export { pathToArray as responsePathAsArray } from '../jsutils/Path';
export { execute, defaultFieldResolver, defaultTypeResolver } from './execute';
export { getDirectiveValues } from './values';

68
node_modules/graphql/execution/values.d.ts generated vendored Normal file
View File

@@ -0,0 +1,68 @@
import Maybe from '../tsutils/Maybe';
import { GraphQLError } from '../error/GraphQLError';
import {
FieldNode,
DirectiveNode,
VariableDefinitionNode,
} from '../language/ast';
import { GraphQLDirective } from '../type/directives';
import { GraphQLSchema } from '../type/schema';
import {
GraphQLInputType,
GraphQLField,
GraphQLArgument,
} from '../type/definition';
type CoercedVariableValues =
| { errors: ReadonlyArray<GraphQLError>; coerced?: never }
| { errors?: never; coerced: { [key: string]: any } };
/**
* Prepares an object map of variableValues of the correct type based on the
* provided variable definitions and arbitrary input. If the input cannot be
* parsed to match the variable definitions, a GraphQLError will be thrown.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getVariableValues(
schema: GraphQLSchema,
varDefNodes: VariableDefinitionNode[],
inputs: { [key: string]: any },
options?: { maxErrors?: number },
): CoercedVariableValues;
/**
* Prepares an object map of argument values given a list of argument
* definitions and list of argument AST nodes.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getArgumentValues(
def: GraphQLField<any, any> | GraphQLDirective,
node: FieldNode | DirectiveNode,
variableValues?: Maybe<{ [key: string]: any }>,
): { [key: string]: any };
/**
* Prepares an object map of argument values given a directive definition
* and a AST node which may contain directives. Optionally also accepts a map
* of variable values.
*
* If the directive does not exist on the node, returns undefined.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getDirectiveValues(
directiveDef: GraphQLDirective,
node: {
readonly directives?: ReadonlyArray<DirectiveNode>;
},
variableValues?: Maybe<{ [key: string]: any }>,
): undefined | { [key: string]: any };

220
node_modules/graphql/execution/values.js generated vendored Normal file
View File

@@ -0,0 +1,220 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getVariableValues = getVariableValues;
exports.getArgumentValues = getArgumentValues;
exports.getDirectiveValues = getDirectiveValues;
var _find = _interopRequireDefault(require("../polyfills/find"));
var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
var _printPathArray = _interopRequireDefault(require("../jsutils/printPathArray"));
var _GraphQLError = require("../error/GraphQLError");
var _kinds = require("../language/kinds");
var _printer = require("../language/printer");
var _definition = require("../type/definition");
var _typeFromAST = require("../utilities/typeFromAST");
var _valueFromAST = require("../utilities/valueFromAST");
var _coerceInputValue = require("../utilities/coerceInputValue");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Prepares an object map of variableValues of the correct type based on the
* provided variable definitions and arbitrary input. If the input cannot be
* parsed to match the variable definitions, a GraphQLError will be thrown.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
function getVariableValues(schema, varDefNodes, inputs, options) {
var maxErrors = options && options.maxErrors;
var errors = [];
try {
var coerced = coerceVariableValues(schema, varDefNodes, inputs, function (error) {
if (maxErrors != null && errors.length >= maxErrors) {
throw new _GraphQLError.GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.');
}
errors.push(error);
});
if (errors.length === 0) {
return {
coerced: coerced
};
}
} catch (error) {
errors.push(error);
}
return {
errors: errors
};
}
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
var coercedValues = {};
var _loop = function _loop(_i2) {
var varDefNode = varDefNodes[_i2];
var varName = varDefNode.variable.name.value;
var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
if (!(0, _definition.isInputType)(varType)) {
// Must use input types for variables. This should be caught during
// validation, however is checked again here for safety.
var varTypeStr = (0, _printer.print)(varDefNode.type);
onError(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" expected value of type \"").concat(varTypeStr, "\" which cannot be used as an input type."), varDefNode.type));
return "continue";
}
if (!hasOwnProperty(inputs, varName)) {
if (varDefNode.defaultValue) {
coercedValues[varName] = (0, _valueFromAST.valueFromAST)(varDefNode.defaultValue, varType);
} else if ((0, _definition.isNonNullType)(varType)) {
var _varTypeStr = (0, _inspect.default)(varType);
onError(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" of required type \"").concat(_varTypeStr, "\" was not provided."), varDefNode));
}
return "continue";
}
var value = inputs[varName];
if (value === null && (0, _definition.isNonNullType)(varType)) {
var _varTypeStr2 = (0, _inspect.default)(varType);
onError(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" of non-null type \"").concat(_varTypeStr2, "\" must not be null."), varDefNode));
return "continue";
}
coercedValues[varName] = (0, _coerceInputValue.coerceInputValue)(value, varType, function (path, invalidValue, error) {
var prefix = "Variable \"$".concat(varName, "\" got invalid value ") + (0, _inspect.default)(invalidValue);
if (path.length > 0) {
prefix += " at \"".concat(varName).concat((0, _printPathArray.default)(path), "\"");
}
onError(new _GraphQLError.GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));
});
};
for (var _i2 = 0; _i2 < varDefNodes.length; _i2++) {
var _ret = _loop(_i2);
if (_ret === "continue") continue;
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a list of argument
* definitions and list of argument AST nodes.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
function getArgumentValues(def, node, variableValues) {
var coercedValues = {};
var argNodeMap = (0, _keyMap.default)(node.arguments || [], function (arg) {
return arg.name.value;
});
for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
var argDef = _def$args2[_i4];
var name = argDef.name;
var argType = argDef.type;
var argumentNode = argNodeMap[name];
if (!argumentNode) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if ((0, _definition.isNonNullType)(argType)) {
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + 'was not provided.', node);
}
continue;
}
var valueNode = argumentNode.value;
var isNull = valueNode.kind === _kinds.Kind.NULL;
if (valueNode.kind === _kinds.Kind.VARIABLE) {
var variableName = valueNode.name.value;
if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if ((0, _definition.isNonNullType)(argType)) {
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
}
continue;
}
isNull = variableValues[variableName] == null;
}
if (isNull && (0, _definition.isNonNullType)(argType)) {
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat((0, _inspect.default)(argType), "\" ") + 'must not be null.', valueNode);
}
var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
if (coercedValue === undefined) {
// Note: ValuesOfCorrectType validation should catch this before
// execution. This is a runtime check to ensure execution does not
// continue with an invalid argument value.
throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat((0, _printer.print)(valueNode), "."), valueNode);
}
coercedValues[name] = coercedValue;
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a directive definition
* and a AST node which may contain directives. Optionally also accepts a map
* of variable values.
*
* If the directive does not exist on the node, returns undefined.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
function getDirectiveValues(directiveDef, node, variableValues) {
var directiveNode = node.directives && (0, _find.default)(node.directives, function (directive) {
return directive.name.value === directiveDef.name;
});
if (directiveNode) {
return getArgumentValues(directiveDef, directiveNode, variableValues);
}
}
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

259
node_modules/graphql/execution/values.js.flow generated vendored Normal file
View File

@@ -0,0 +1,259 @@
// @flow strict
import find from '../polyfills/find';
import keyMap from '../jsutils/keyMap';
import inspect from '../jsutils/inspect';
import { type ObjMap } from '../jsutils/ObjMap';
import printPathArray from '../jsutils/printPathArray';
import { GraphQLError } from '../error/GraphQLError';
import { Kind } from '../language/kinds';
import { print } from '../language/printer';
import {
type FieldNode,
type DirectiveNode,
type VariableDefinitionNode,
} from '../language/ast';
import { type GraphQLSchema } from '../type/schema';
import { type GraphQLDirective } from '../type/directives';
import {
type GraphQLField,
isInputType,
isNonNullType,
} from '../type/definition';
import { typeFromAST } from '../utilities/typeFromAST';
import { valueFromAST } from '../utilities/valueFromAST';
import { coerceInputValue } from '../utilities/coerceInputValue';
type CoercedVariableValues =
| {| errors: $ReadOnlyArray<GraphQLError> |}
| {| coerced: { [variable: string]: mixed, ... } |};
/**
* Prepares an object map of variableValues of the correct type based on the
* provided variable definitions and arbitrary input. If the input cannot be
* parsed to match the variable definitions, a GraphQLError will be thrown.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getVariableValues(
schema: GraphQLSchema,
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
inputs: { +[variable: string]: mixed, ... },
options?: {| maxErrors?: number |},
): CoercedVariableValues {
const maxErrors = options && options.maxErrors;
const errors = [];
try {
const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {
if (maxErrors != null && errors.length >= maxErrors) {
throw new GraphQLError(
'Too many errors processing variables, error limit reached. Execution aborted.',
);
}
errors.push(error);
});
if (errors.length === 0) {
return { coerced };
}
} catch (error) {
errors.push(error);
}
return { errors };
}
function coerceVariableValues(
schema: GraphQLSchema,
varDefNodes: $ReadOnlyArray<VariableDefinitionNode>,
inputs: { +[variable: string]: mixed, ... },
onError: GraphQLError => void,
): { [variable: string]: mixed, ... } {
const coercedValues = {};
for (const varDefNode of varDefNodes) {
const varName = varDefNode.variable.name.value;
const varType = typeFromAST(schema, varDefNode.type);
if (!isInputType(varType)) {
// Must use input types for variables. This should be caught during
// validation, however is checked again here for safety.
const varTypeStr = print(varDefNode.type);
onError(
new GraphQLError(
`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`,
varDefNode.type,
),
);
continue;
}
if (!hasOwnProperty(inputs, varName)) {
if (varDefNode.defaultValue) {
coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType);
} else if (isNonNullType(varType)) {
const varTypeStr = inspect(varType);
onError(
new GraphQLError(
`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`,
varDefNode,
),
);
}
continue;
}
const value = inputs[varName];
if (value === null && isNonNullType(varType)) {
const varTypeStr = inspect(varType);
onError(
new GraphQLError(
`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`,
varDefNode,
),
);
continue;
}
coercedValues[varName] = coerceInputValue(
value,
varType,
(path, invalidValue, error) => {
let prefix =
`Variable "$${varName}" got invalid value ` + inspect(invalidValue);
if (path.length > 0) {
prefix += ` at "${varName}${printPathArray(path)}"`;
}
onError(
new GraphQLError(
prefix + '; ' + error.message,
varDefNode,
undefined,
undefined,
undefined,
error.originalError,
),
);
},
);
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a list of argument
* definitions and list of argument AST nodes.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getArgumentValues(
def: GraphQLField<mixed, mixed> | GraphQLDirective,
node: FieldNode | DirectiveNode,
variableValues?: ?ObjMap<mixed>,
): { [argument: string]: mixed, ... } {
const coercedValues = {};
const argNodeMap = keyMap(node.arguments || [], arg => arg.name.value);
for (const argDef of def.args) {
const name = argDef.name;
const argType = argDef.type;
const argumentNode = argNodeMap[name];
if (!argumentNode) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if (isNonNullType(argType)) {
throw new GraphQLError(
`Argument "${name}" of required type "${inspect(argType)}" ` +
'was not provided.',
node,
);
}
continue;
}
const valueNode = argumentNode.value;
let isNull = valueNode.kind === Kind.NULL;
if (valueNode.kind === Kind.VARIABLE) {
const variableName = valueNode.name.value;
if (
variableValues == null ||
!hasOwnProperty(variableValues, variableName)
) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if (isNonNullType(argType)) {
throw new GraphQLError(
`Argument "${name}" of required type "${inspect(argType)}" ` +
`was provided the variable "$${variableName}" which was not provided a runtime value.`,
valueNode,
);
}
continue;
}
isNull = variableValues[variableName] == null;
}
if (isNull && isNonNullType(argType)) {
throw new GraphQLError(
`Argument "${name}" of non-null type "${inspect(argType)}" ` +
'must not be null.',
valueNode,
);
}
const coercedValue = valueFromAST(valueNode, argType, variableValues);
if (coercedValue === undefined) {
// Note: ValuesOfCorrectType validation should catch this before
// execution. This is a runtime check to ensure execution does not
// continue with an invalid argument value.
throw new GraphQLError(
`Argument "${name}" has invalid value ${print(valueNode)}.`,
valueNode,
);
}
coercedValues[name] = coercedValue;
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a directive definition
* and a AST node which may contain directives. Optionally also accepts a map
* of variable values.
*
* If the directive does not exist on the node, returns undefined.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getDirectiveValues(
directiveDef: GraphQLDirective,
node: { +directives?: $ReadOnlyArray<DirectiveNode>, ... },
variableValues?: ?ObjMap<mixed>,
): void | { [argument: string]: mixed, ... } {
const directiveNode =
node.directives &&
find(
node.directives,
directive => directive.name.value === directiveDef.name,
);
if (directiveNode) {
return getArgumentValues(directiveDef, directiveNode, variableValues);
}
}
function hasOwnProperty(obj: mixed, prop: string): boolean {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

198
node_modules/graphql/execution/values.mjs generated vendored Normal file
View File

@@ -0,0 +1,198 @@
import find from '../polyfills/find';
import keyMap from '../jsutils/keyMap';
import inspect from '../jsutils/inspect';
import printPathArray from '../jsutils/printPathArray';
import { GraphQLError } from '../error/GraphQLError';
import { Kind } from '../language/kinds';
import { print } from '../language/printer';
import { isInputType, isNonNullType } from '../type/definition';
import { typeFromAST } from '../utilities/typeFromAST';
import { valueFromAST } from '../utilities/valueFromAST';
import { coerceInputValue } from '../utilities/coerceInputValue';
/**
* Prepares an object map of variableValues of the correct type based on the
* provided variable definitions and arbitrary input. If the input cannot be
* parsed to match the variable definitions, a GraphQLError will be thrown.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getVariableValues(schema, varDefNodes, inputs, options) {
var maxErrors = options && options.maxErrors;
var errors = [];
try {
var coerced = coerceVariableValues(schema, varDefNodes, inputs, function (error) {
if (maxErrors != null && errors.length >= maxErrors) {
throw new GraphQLError('Too many errors processing variables, error limit reached. Execution aborted.');
}
errors.push(error);
});
if (errors.length === 0) {
return {
coerced: coerced
};
}
} catch (error) {
errors.push(error);
}
return {
errors: errors
};
}
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
var coercedValues = {};
var _loop = function _loop(_i2) {
var varDefNode = varDefNodes[_i2];
var varName = varDefNode.variable.name.value;
var varType = typeFromAST(schema, varDefNode.type);
if (!isInputType(varType)) {
// Must use input types for variables. This should be caught during
// validation, however is checked again here for safety.
var varTypeStr = print(varDefNode.type);
onError(new GraphQLError("Variable \"$".concat(varName, "\" expected value of type \"").concat(varTypeStr, "\" which cannot be used as an input type."), varDefNode.type));
return "continue";
}
if (!hasOwnProperty(inputs, varName)) {
if (varDefNode.defaultValue) {
coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType);
} else if (isNonNullType(varType)) {
var _varTypeStr = inspect(varType);
onError(new GraphQLError("Variable \"$".concat(varName, "\" of required type \"").concat(_varTypeStr, "\" was not provided."), varDefNode));
}
return "continue";
}
var value = inputs[varName];
if (value === null && isNonNullType(varType)) {
var _varTypeStr2 = inspect(varType);
onError(new GraphQLError("Variable \"$".concat(varName, "\" of non-null type \"").concat(_varTypeStr2, "\" must not be null."), varDefNode));
return "continue";
}
coercedValues[varName] = coerceInputValue(value, varType, function (path, invalidValue, error) {
var prefix = "Variable \"$".concat(varName, "\" got invalid value ") + inspect(invalidValue);
if (path.length > 0) {
prefix += " at \"".concat(varName).concat(printPathArray(path), "\"");
}
onError(new GraphQLError(prefix + '; ' + error.message, varDefNode, undefined, undefined, undefined, error.originalError));
});
};
for (var _i2 = 0; _i2 < varDefNodes.length; _i2++) {
var _ret = _loop(_i2);
if (_ret === "continue") continue;
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a list of argument
* definitions and list of argument AST nodes.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getArgumentValues(def, node, variableValues) {
var coercedValues = {};
var argNodeMap = keyMap(node.arguments || [], function (arg) {
return arg.name.value;
});
for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
var argDef = _def$args2[_i4];
var name = argDef.name;
var argType = argDef.type;
var argumentNode = argNodeMap[name];
if (!argumentNode) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if (isNonNullType(argType)) {
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
}
continue;
}
var valueNode = argumentNode.value;
var isNull = valueNode.kind === Kind.NULL;
if (valueNode.kind === Kind.VARIABLE) {
var variableName = valueNode.name.value;
if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
if (argDef.defaultValue !== undefined) {
coercedValues[name] = argDef.defaultValue;
} else if (isNonNullType(argType)) {
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
}
continue;
}
isNull = variableValues[variableName] == null;
}
if (isNull && isNonNullType(argType)) {
throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', valueNode);
}
var coercedValue = valueFromAST(valueNode, argType, variableValues);
if (coercedValue === undefined) {
// Note: ValuesOfCorrectType validation should catch this before
// execution. This is a runtime check to ensure execution does not
// continue with an invalid argument value.
throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), valueNode);
}
coercedValues[name] = coercedValue;
}
return coercedValues;
}
/**
* Prepares an object map of argument values given a directive definition
* and a AST node which may contain directives. Optionally also accepts a map
* of variable values.
*
* If the directive does not exist on the node, returns undefined.
*
* Note: The returned value is a plain Object with a prototype, since it is
* exposed to user code. Care should be taken to not pull values from the
* Object prototype.
*/
export function getDirectiveValues(directiveDef, node, variableValues) {
var directiveNode = node.directives && find(node.directives, function (directive) {
return directive.name.value === directiveDef.name;
});
if (directiveNode) {
return getArgumentValues(directiveDef, directiveNode, variableValues);
}
}
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

88
node_modules/graphql/graphql.d.ts generated vendored Normal file
View File

@@ -0,0 +1,88 @@
import Maybe from './tsutils/Maybe';
import { Source } from './language/source';
import { GraphQLSchema } from './type/schema';
import { GraphQLFieldResolver, GraphQLTypeResolver } from './type/definition';
import {
ExecutionResult,
ExecutionResultDataDefault,
} from './execution/execute';
/**
* 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).
*/
export interface GraphQLArgs {
schema: GraphQLSchema;
source: string | Source;
rootValue?: any;
contextValue?: any;
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
}
export function graphql<TData = ExecutionResultDataDefault>(
args: GraphQLArgs,
): Promise<ExecutionResult<TData>>;
export function graphql<TData = ExecutionResultDataDefault>(
schema: GraphQLSchema,
source: Source | string,
rootValue?: any,
contextValue?: any,
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): Promise<ExecutionResult<TData>>;
/**
* The graphqlSync function also fulfills GraphQL operations by parsing,
* validating, and executing a GraphQL document along side a GraphQL schema.
* However, it guarantees to complete synchronously (or throw an error) assuming
* that all field resolvers are also synchronous.
*/
export function graphqlSync<TData = ExecutionResultDataDefault>(
args: GraphQLArgs,
): ExecutionResult<TData>;
export function graphqlSync<TData = ExecutionResultDataDefault>(
schema: GraphQLSchema,
source: Source | string,
rootValue?: any,
contextValue?: any,
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): ExecutionResult<TData>;

118
node_modules/graphql/graphql.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.graphql = graphql;
exports.graphqlSync = graphqlSync;
var _isPromise = _interopRequireDefault(require("./jsutils/isPromise"));
var _parser = require("./language/parser");
var _validate = require("./validation/validate");
var _validate2 = require("./type/validate");
var _execute = require("./execution/execute");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
var _arguments = arguments;
/* eslint-enable no-redeclare */
// Always return a Promise for a consistent API.
return new Promise(function (resolve) {
return resolve( // Extract arguments from object args if provided.
_arguments.length === 1 ? graphqlImpl(argsOrSchema) : graphqlImpl({
schema: argsOrSchema,
source: source,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
}));
});
}
/**
* The graphqlSync function also fulfills GraphQL operations by parsing,
* validating, and executing a GraphQL document along side a GraphQL schema.
* However, it guarantees to complete synchronously (or throw an error) assuming
* that all field resolvers are also synchronous.
*/
function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
/* eslint-enable no-redeclare */
// Extract arguments from object args if provided.
var result = arguments.length === 1 ? graphqlImpl(argsOrSchema) : graphqlImpl({
schema: argsOrSchema,
source: source,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
}); // Assert that the execution was synchronous.
if ((0, _isPromise.default)(result)) {
throw new Error('GraphQL execution failed to complete synchronously.');
}
return result;
}
function graphqlImpl(args) {
var schema = args.schema,
source = args.source,
rootValue = args.rootValue,
contextValue = args.contextValue,
variableValues = args.variableValues,
operationName = args.operationName,
fieldResolver = args.fieldResolver,
typeResolver = args.typeResolver; // Validate Schema
var schemaValidationErrors = (0, _validate2.validateSchema)(schema);
if (schemaValidationErrors.length > 0) {
return {
errors: schemaValidationErrors
};
} // Parse
var document;
try {
document = (0, _parser.parse)(source);
} catch (syntaxError) {
return {
errors: [syntaxError]
};
} // Validate
var validationErrors = (0, _validate.validate)(schema, document);
if (validationErrors.length > 0) {
return {
errors: validationErrors
};
} // Execute
return (0, _execute.execute)({
schema: schema,
document: document,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
});
}

207
node_modules/graphql/graphql.js.flow generated vendored Normal file
View File

@@ -0,0 +1,207 @@
// @flow strict
import isPromise from './jsutils/isPromise';
import { type PromiseOrValue } from './jsutils/PromiseOrValue';
import { parse } from './language/parser';
import { type Source } from './language/source';
import { validate } from './validation/validate';
import { validateSchema } from './type/validate';
import { type GraphQLSchema } from './type/schema';
import {
type GraphQLFieldResolver,
type GraphQLTypeResolver,
} from './type/definition';
import { type ExecutionResult, execute } from './execution/execute';
/**
* 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).
*/
export type GraphQLArgs = {|
schema: GraphQLSchema,
source: string | Source,
rootValue?: mixed,
contextValue?: mixed,
variableValues?: ?{ +[variable: string]: mixed, ... },
operationName?: ?string,
fieldResolver?: ?GraphQLFieldResolver<any, any>,
typeResolver?: ?GraphQLTypeResolver<any, any>,
|};
declare function graphql(GraphQLArgs, ..._: []): Promise<ExecutionResult>;
/* eslint-disable no-redeclare */
declare function graphql(
schema: GraphQLSchema,
source: Source | string,
rootValue?: mixed,
contextValue?: mixed,
variableValues?: ?{ +[variable: string]: mixed, ... },
operationName?: ?string,
fieldResolver?: ?GraphQLFieldResolver<any, any>,
typeResolver?: ?GraphQLTypeResolver<any, any>,
): Promise<ExecutionResult>;
export function graphql(
argsOrSchema,
source,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
) {
/* eslint-enable no-redeclare */
// Always return a Promise for a consistent API.
return new Promise(resolve =>
resolve(
// Extract arguments from object args if provided.
arguments.length === 1
? graphqlImpl(argsOrSchema)
: graphqlImpl({
schema: argsOrSchema,
source,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
}),
),
);
}
/**
* The graphqlSync function also fulfills GraphQL operations by parsing,
* validating, and executing a GraphQL document along side a GraphQL schema.
* However, it guarantees to complete synchronously (or throw an error) assuming
* that all field resolvers are also synchronous.
*/
declare function graphqlSync(GraphQLArgs, ..._: []): ExecutionResult;
/* eslint-disable no-redeclare */
declare function graphqlSync(
schema: GraphQLSchema,
source: Source | string,
rootValue?: mixed,
contextValue?: mixed,
variableValues?: ?{ +[variable: string]: mixed, ... },
operationName?: ?string,
fieldResolver?: ?GraphQLFieldResolver<any, any>,
typeResolver?: ?GraphQLTypeResolver<any, any>,
): ExecutionResult;
export function graphqlSync(
argsOrSchema,
source,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
) {
/* eslint-enable no-redeclare */
// Extract arguments from object args if provided.
const result =
arguments.length === 1
? graphqlImpl(argsOrSchema)
: graphqlImpl({
schema: argsOrSchema,
source,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
});
// Assert that the execution was synchronous.
if (isPromise(result)) {
throw new Error('GraphQL execution failed to complete synchronously.');
}
return result;
}
function graphqlImpl(args: GraphQLArgs): PromiseOrValue<ExecutionResult> {
const {
schema,
source,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
} = args;
// Validate Schema
const schemaValidationErrors = validateSchema(schema);
if (schemaValidationErrors.length > 0) {
return { errors: schemaValidationErrors };
}
// Parse
let document;
try {
document = parse(source);
} catch (syntaxError) {
return { errors: [syntaxError] };
}
// Validate
const validationErrors = validate(schema, document);
if (validationErrors.length > 0) {
return { errors: validationErrors };
}
// Execute
return execute({
schema,
document,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
typeResolver,
});
}

142
node_modules/graphql/graphql.mjs generated vendored Normal file
View File

@@ -0,0 +1,142 @@
import isPromise from './jsutils/isPromise';
import { parse } from './language/parser';
import { validate } from './validation/validate';
import { validateSchema } from './type/validate';
import { execute } from './execution/execute';
/**
* 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).
*/
export function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
var _arguments = arguments;
/* eslint-enable no-redeclare */
// Always return a Promise for a consistent API.
return new Promise(function (resolve) {
return resolve( // Extract arguments from object args if provided.
_arguments.length === 1 ? graphqlImpl(argsOrSchema) : graphqlImpl({
schema: argsOrSchema,
source: source,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
}));
});
}
/**
* The graphqlSync function also fulfills GraphQL operations by parsing,
* validating, and executing a GraphQL document along side a GraphQL schema.
* However, it guarantees to complete synchronously (or throw an error) assuming
* that all field resolvers are also synchronous.
*/
export function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
/* eslint-enable no-redeclare */
// Extract arguments from object args if provided.
var result = arguments.length === 1 ? graphqlImpl(argsOrSchema) : graphqlImpl({
schema: argsOrSchema,
source: source,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
}); // Assert that the execution was synchronous.
if (isPromise(result)) {
throw new Error('GraphQL execution failed to complete synchronously.');
}
return result;
}
function graphqlImpl(args) {
var schema = args.schema,
source = args.source,
rootValue = args.rootValue,
contextValue = args.contextValue,
variableValues = args.variableValues,
operationName = args.operationName,
fieldResolver = args.fieldResolver,
typeResolver = args.typeResolver; // Validate Schema
var schemaValidationErrors = validateSchema(schema);
if (schemaValidationErrors.length > 0) {
return {
errors: schemaValidationErrors
};
} // Parse
var document;
try {
document = parse(source);
} catch (syntaxError) {
return {
errors: [syntaxError]
};
} // Validate
var validationErrors = validate(schema, document);
if (validationErrors.length > 0) {
return {
errors: validationErrors
};
} // Execute
return execute({
schema: schema,
document: document,
rootValue: rootValue,
contextValue: contextValue,
variableValues: variableValues,
operationName: operationName,
fieldResolver: fieldResolver,
typeResolver: typeResolver
});
}

456
node_modules/graphql/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,456 @@
// TypeScript Version: 2.6
/**
* GraphQL.js provides a reference implementation for the GraphQL specification
* but is also a useful utility for operating on GraphQL files and building
* sophisticated tools.
*
* This primary module exports a general purpose function for fulfilling all
* steps of the GraphQL specification in a single operation, but also includes
* utilities for every part of the GraphQL specification:
*
* - Parsing the GraphQL language.
* - Building a GraphQL type schema.
* - Validating a GraphQL request against a type schema.
* - Executing a GraphQL request against a type schema.
*
* This also includes utility functions for operating on GraphQL types and
* GraphQL documents to facilitate building tools.
*
* You may also import from each sub-directory directly. For example, the
* following two import statements are equivalent:
*
* import { parse } from 'graphql';
* import { parse } from 'graphql/language';
*/
// The GraphQL.js version info.
export { version, versionInfo } from './version';
// The primary entry point into fulfilling a GraphQL request.
export { GraphQLArgs, graphql, graphqlSync } from './graphql';
// Create and operate on GraphQL type definitions and schema.
export {
// Definitions
GraphQLSchema,
GraphQLDirective,
GraphQLScalarType,
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLEnumType,
GraphQLInputObjectType,
GraphQLList,
GraphQLNonNull,
// Standard GraphQL Scalars
specifiedScalarTypes,
GraphQLInt,
GraphQLFloat,
GraphQLString,
GraphQLBoolean,
GraphQLID,
// Built-in Directives defined by the Spec
specifiedDirectives,
GraphQLIncludeDirective,
GraphQLSkipDirective,
GraphQLDeprecatedDirective,
// "Enum" of Type Kinds
TypeKind,
// Constant Deprecation Reason
DEFAULT_DEPRECATION_REASON,
// GraphQL Types for introspection.
introspectionTypes,
__Schema,
__Directive,
__DirectiveLocation,
__Type,
__Field,
__InputValue,
__EnumValue,
__TypeKind,
// Meta-field definitions.
SchemaMetaFieldDef,
TypeMetaFieldDef,
TypeNameMetaFieldDef,
// Predicates
isSchema,
isDirective,
isType,
isScalarType,
isObjectType,
isInterfaceType,
isUnionType,
isEnumType,
isInputObjectType,
isListType,
isNonNullType,
isInputType,
isOutputType,
isLeafType,
isCompositeType,
isAbstractType,
isWrappingType,
isNullableType,
isNamedType,
isRequiredArgument,
isRequiredInputField,
isSpecifiedScalarType,
isIntrospectionType,
isSpecifiedDirective,
// Assertions
assertSchema,
assertDirective,
assertType,
assertScalarType,
assertObjectType,
assertInterfaceType,
assertUnionType,
assertEnumType,
assertInputObjectType,
assertListType,
assertNonNullType,
assertInputType,
assertOutputType,
assertLeafType,
assertCompositeType,
assertAbstractType,
assertWrappingType,
assertNullableType,
assertNamedType,
// Un-modifiers
getNullableType,
getNamedType,
// Validate GraphQL schema.
validateSchema,
assertValidSchema,
} from './type';
export {
GraphQLType,
GraphQLInputType,
GraphQLOutputType,
GraphQLLeafType,
GraphQLCompositeType,
GraphQLAbstractType,
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLSchemaConfig,
GraphQLDirectiveConfig,
GraphQLArgument,
GraphQLArgumentConfig,
GraphQLEnumTypeConfig,
GraphQLEnumValue,
GraphQLEnumValueConfig,
GraphQLEnumValueConfigMap,
GraphQLField,
GraphQLFieldConfig,
GraphQLFieldConfigArgumentMap,
GraphQLFieldConfigMap,
GraphQLFieldMap,
GraphQLFieldResolver,
GraphQLInputField,
GraphQLInputFieldConfig,
GraphQLInputFieldConfigMap,
GraphQLInputFieldMap,
GraphQLInputObjectTypeConfig,
GraphQLInterfaceTypeConfig,
GraphQLIsTypeOfFn,
GraphQLObjectTypeConfig,
GraphQLResolveInfo,
ResponsePath,
GraphQLScalarTypeConfig,
GraphQLTypeResolver,
GraphQLUnionTypeConfig,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLScalarLiteralParser,
} from './type';
// Parse and operate on GraphQL language source files.
export {
Source,
getLocation,
// Print source location
printLocation,
printSourceLocation,
// Lex
createLexer,
TokenKind,
// Parse
parse,
parseValue,
parseType,
// Print
print,
// Visit
visit,
visitInParallel,
visitWithTypeInfo,
getVisitFn,
BREAK,
Kind,
DirectiveLocation,
// Predicates
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isValueNode,
isTypeNode,
isTypeSystemDefinitionNode,
isTypeDefinitionNode,
isTypeSystemExtensionNode,
isTypeExtensionNode,
} from './language';
export {
Lexer,
ParseOptions,
SourceLocation,
Location,
Token,
TokenKindEnum,
KindEnum,
DirectiveLocationEnum,
// Visitor utilities
ASTVisitor,
Visitor,
VisitFn,
VisitorKeyMap,
// AST nodes
ASTNode,
ASTKindToNode,
// Each kind of AST node
NameNode,
DocumentNode,
DefinitionNode,
ExecutableDefinitionNode,
OperationDefinitionNode,
OperationTypeNode,
VariableDefinitionNode,
VariableNode,
SelectionSetNode,
SelectionNode,
FieldNode,
ArgumentNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
ValueNode,
IntValueNode,
FloatValueNode,
StringValueNode,
BooleanValueNode,
NullValueNode,
EnumValueNode,
ListValueNode,
ObjectValueNode,
ObjectFieldNode,
DirectiveNode,
TypeNode,
NamedTypeNode,
ListTypeNode,
NonNullTypeNode,
TypeSystemDefinitionNode,
SchemaDefinitionNode,
OperationTypeDefinitionNode,
TypeDefinitionNode,
ScalarTypeDefinitionNode,
ObjectTypeDefinitionNode,
FieldDefinitionNode,
InputValueDefinitionNode,
InterfaceTypeDefinitionNode,
UnionTypeDefinitionNode,
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
DirectiveDefinitionNode,
TypeSystemExtensionNode,
SchemaExtensionNode,
TypeExtensionNode,
ScalarTypeExtensionNode,
ObjectTypeExtensionNode,
InterfaceTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
} from './language';
// Execute GraphQL queries.
export {
execute,
defaultFieldResolver,
defaultTypeResolver,
responsePathAsArray,
getDirectiveValues,
ExecutionArgs,
ExecutionResult,
FormattedExecutionResult,
} from './execution';
export {
subscribe,
createSourceEventStream,
SubscriptionArgs,
} from './subscription';
// Validate GraphQL documents.
export {
validate,
ValidationContext,
// All validation rules in the GraphQL Specification.
specifiedRules,
// Individual validation rules.
ExecutableDefinitionsRule,
FieldsOnCorrectTypeRule,
FragmentsOnCompositeTypesRule,
KnownArgumentNamesRule,
KnownDirectivesRule,
KnownFragmentNamesRule,
KnownTypeNamesRule,
LoneAnonymousOperationRule,
NoFragmentCyclesRule,
NoUndefinedVariablesRule,
NoUnusedFragmentsRule,
NoUnusedVariablesRule,
OverlappingFieldsCanBeMergedRule,
PossibleFragmentSpreadsRule,
ProvidedRequiredArgumentsRule,
ScalarLeafsRule,
SingleFieldSubscriptionsRule,
UniqueArgumentNamesRule,
UniqueDirectivesPerLocationRule,
UniqueFragmentNamesRule,
UniqueInputFieldNamesRule,
UniqueOperationNamesRule,
UniqueVariableNamesRule,
ValuesOfCorrectTypeRule,
VariablesAreInputTypesRule,
VariablesInAllowedPositionRule,
// SDL-specific validation rules
LoneSchemaDefinitionRule,
UniqueOperationTypesRule,
UniqueTypeNamesRule,
UniqueEnumValueNamesRule,
UniqueFieldDefinitionNamesRule,
UniqueDirectiveNamesRule,
PossibleTypeExtensionsRule,
ValidationRule,
} from './validation';
// Create, format, and print GraphQL errors.
export {
GraphQLError,
syntaxError,
locatedError,
printError,
formatError,
GraphQLFormattedError,
} from './error';
// Utilities for operating on GraphQL type schema and parsed sources.
export {
// Produce the GraphQL query recommended for a full schema introspection.
// Accepts optional IntrospectionOptions.
getIntrospectionQuery,
// @deprecated: use getIntrospectionQuery - will be removed in v15.
introspectionQuery,
// Gets the target Operation from a Document.
getOperationAST,
// Gets the Type for the target Operation AST.
getOperationRootType,
// Convert a GraphQLSchema to an IntrospectionQuery.
introspectionFromSchema,
// Build a GraphQLSchema from an introspection result.
buildClientSchema,
// Build a GraphQLSchema from a parsed GraphQL Schema language AST.
buildASTSchema,
// Build a GraphQLSchema from a GraphQL schema language document.
buildSchema,
// @deprecated: Get the description from a schema AST node and supports legacy
// syntax for specifying descriptions - will be removed in v16.
getDescription,
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
extendSchema,
// Sort a GraphQLSchema.
lexicographicSortSchema,
// Print a GraphQLSchema to GraphQL Schema language.
printSchema,
// Print a GraphQLType to GraphQL Schema language.
printType,
// Prints the built-in introspection schema in the Schema Language
// format.
printIntrospectionSchema,
// Create a GraphQLType from a GraphQL language AST.
typeFromAST,
// Create a JavaScript value from a GraphQL language AST with a Type.
valueFromAST,
// Create a JavaScript value from a GraphQL language AST without a Type.
valueFromASTUntyped,
// Create a GraphQL language AST from a JavaScript value.
astFromValue,
// A helper to use within recursive-descent visitors which need to be aware of
// the GraphQL type system.
TypeInfo,
// Coerces a JavaScript value to a GraphQL type, or produces errors.
coerceInputValue,
// @deprecated use coerceInputValue - will be removed in v15
coerceValue,
// @deprecated use coerceInputValue - will be removed in v15
isValidJSValue,
// @deprecated use validation - will be removed in v15
isValidLiteralValue,
// Concatenates multiple AST together.
concatAST,
// Separates an AST into an AST per Operation.
separateOperations,
// Strips characters that are not significant to the validity or execution
// of a GraphQL document.
stripIgnoredCharacters,
// Comparators for types
isEqualType,
isTypeSubTypeOf,
doTypesOverlap,
// Asserts a string is a valid GraphQL name.
assertValidName,
// Determine if a string is a valid GraphQL name.
isValidNameError,
// Compares two GraphQLSchemas and detects breaking changes.
BreakingChangeType,
DangerousChangeType,
findBreakingChanges,
findDangerousChanges,
// Report all deprecated usage within a GraphQL document.
findDeprecatedUsages,
} from './utilities';
export {
IntrospectionOptions,
IntrospectionQuery,
IntrospectionSchema,
IntrospectionType,
IntrospectionInputType,
IntrospectionOutputType,
IntrospectionScalarType,
IntrospectionObjectType,
IntrospectionInterfaceType,
IntrospectionUnionType,
IntrospectionEnumType,
IntrospectionInputObjectType,
IntrospectionTypeRef,
IntrospectionInputTypeRef,
IntrospectionOutputTypeRef,
IntrospectionNamedTypeRef,
IntrospectionListTypeRef,
IntrospectionNonNullTypeRef,
IntrospectionField,
IntrospectionInputValue,
IntrospectionEnumValue,
IntrospectionDirective,
BuildSchemaOptions,
BreakingChange,
DangerousChange,
} from './utilities';

1193
node_modules/graphql/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

459
node_modules/graphql/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,459 @@
// @flow strict
/**
* GraphQL.js provides a reference implementation for the GraphQL specification
* but is also a useful utility for operating on GraphQL files and building
* sophisticated tools.
*
* This primary module exports a general purpose function for fulfilling all
* steps of the GraphQL specification in a single operation, but also includes
* utilities for every part of the GraphQL specification:
*
* - Parsing the GraphQL language.
* - Building a GraphQL type schema.
* - Validating a GraphQL request against a type schema.
* - Executing a GraphQL request against a type schema.
*
* This also includes utility functions for operating on GraphQL types and
* GraphQL documents to facilitate building tools.
*
* You may also import from each sub-directory directly. For example, the
* following two import statements are equivalent:
*
* import { parse } from 'graphql';
* import { parse } from 'graphql/language';
*/
// The GraphQL.js version info.
export { version, versionInfo } from './version';
// The primary entry point into fulfilling a GraphQL request.
export type { GraphQLArgs } from './graphql';
export { graphql, graphqlSync } from './graphql';
// Create and operate on GraphQL type definitions and schema.
export {
// Definitions
GraphQLSchema,
GraphQLDirective,
GraphQLScalarType,
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLEnumType,
GraphQLInputObjectType,
GraphQLList,
GraphQLNonNull,
// Standard GraphQL Scalars
specifiedScalarTypes,
GraphQLInt,
GraphQLFloat,
GraphQLString,
GraphQLBoolean,
GraphQLID,
// Built-in Directives defined by the Spec
specifiedDirectives,
GraphQLIncludeDirective,
GraphQLSkipDirective,
GraphQLDeprecatedDirective,
// "Enum" of Type Kinds
TypeKind,
// Constant Deprecation Reason
DEFAULT_DEPRECATION_REASON,
// GraphQL Types for introspection.
introspectionTypes,
__Schema,
__Directive,
__DirectiveLocation,
__Type,
__Field,
__InputValue,
__EnumValue,
__TypeKind,
// Meta-field definitions.
SchemaMetaFieldDef,
TypeMetaFieldDef,
TypeNameMetaFieldDef,
// Predicates
isSchema,
isDirective,
isType,
isScalarType,
isObjectType,
isInterfaceType,
isUnionType,
isEnumType,
isInputObjectType,
isListType,
isNonNullType,
isInputType,
isOutputType,
isLeafType,
isCompositeType,
isAbstractType,
isWrappingType,
isNullableType,
isNamedType,
isRequiredArgument,
isRequiredInputField,
isSpecifiedScalarType,
isIntrospectionType,
isSpecifiedDirective,
// Assertions
assertSchema,
assertDirective,
assertType,
assertScalarType,
assertObjectType,
assertInterfaceType,
assertUnionType,
assertEnumType,
assertInputObjectType,
assertListType,
assertNonNullType,
assertInputType,
assertOutputType,
assertLeafType,
assertCompositeType,
assertAbstractType,
assertWrappingType,
assertNullableType,
assertNamedType,
// Un-modifiers
getNullableType,
getNamedType,
// Validate GraphQL schema.
validateSchema,
assertValidSchema,
} from './type';
export type {
GraphQLType,
GraphQLInputType,
GraphQLOutputType,
GraphQLLeafType,
GraphQLCompositeType,
GraphQLAbstractType,
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLSchemaConfig,
GraphQLDirectiveConfig,
GraphQLArgument,
GraphQLArgumentConfig,
GraphQLEnumTypeConfig,
GraphQLEnumValue,
GraphQLEnumValueConfig,
GraphQLEnumValueConfigMap,
GraphQLField,
GraphQLFieldConfig,
GraphQLFieldConfigArgumentMap,
GraphQLFieldConfigMap,
GraphQLFieldMap,
GraphQLFieldResolver,
GraphQLInputField,
GraphQLInputFieldConfig,
GraphQLInputFieldConfigMap,
GraphQLInputFieldMap,
GraphQLInputObjectTypeConfig,
GraphQLInterfaceTypeConfig,
GraphQLIsTypeOfFn,
GraphQLObjectTypeConfig,
GraphQLResolveInfo,
ResponsePath,
GraphQLScalarTypeConfig,
GraphQLTypeResolver,
GraphQLUnionTypeConfig,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLScalarLiteralParser,
} from './type';
// Parse and operate on GraphQL language source files.
export {
Source,
getLocation,
// Print source location
printLocation,
printSourceLocation,
// Lex
createLexer,
TokenKind,
// Parse
parse,
parseValue,
parseType,
// Print
print,
// Visit
visit,
visitInParallel,
visitWithTypeInfo,
getVisitFn,
BREAK,
Kind,
DirectiveLocation,
// Predicates
isDefinitionNode,
isExecutableDefinitionNode,
isSelectionNode,
isValueNode,
isTypeNode,
isTypeSystemDefinitionNode,
isTypeDefinitionNode,
isTypeSystemExtensionNode,
isTypeExtensionNode,
} from './language';
export type {
Lexer,
ParseOptions,
SourceLocation,
Location,
Token,
TokenKindEnum,
KindEnum,
DirectiveLocationEnum,
// Visitor utilities
ASTVisitor,
Visitor,
VisitFn,
VisitorKeyMap,
// AST nodes
ASTNode,
ASTKindToNode,
// Each kind of AST node
NameNode,
DocumentNode,
DefinitionNode,
ExecutableDefinitionNode,
OperationDefinitionNode,
OperationTypeNode,
VariableDefinitionNode,
VariableNode,
SelectionSetNode,
SelectionNode,
FieldNode,
ArgumentNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
ValueNode,
IntValueNode,
FloatValueNode,
StringValueNode,
BooleanValueNode,
NullValueNode,
EnumValueNode,
ListValueNode,
ObjectValueNode,
ObjectFieldNode,
DirectiveNode,
TypeNode,
NamedTypeNode,
ListTypeNode,
NonNullTypeNode,
TypeSystemDefinitionNode,
SchemaDefinitionNode,
OperationTypeDefinitionNode,
TypeDefinitionNode,
ScalarTypeDefinitionNode,
ObjectTypeDefinitionNode,
FieldDefinitionNode,
InputValueDefinitionNode,
InterfaceTypeDefinitionNode,
UnionTypeDefinitionNode,
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
DirectiveDefinitionNode,
TypeSystemExtensionNode,
SchemaExtensionNode,
TypeExtensionNode,
ScalarTypeExtensionNode,
ObjectTypeExtensionNode,
InterfaceTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
} from './language';
// Execute GraphQL queries.
export {
execute,
defaultFieldResolver,
defaultTypeResolver,
responsePathAsArray,
getDirectiveValues,
} from './execution';
export type {
ExecutionArgs,
ExecutionResult,
FormattedExecutionResult,
} from './execution';
export { subscribe, createSourceEventStream } from './subscription';
export type { SubscriptionArgs } from './subscription';
// Validate GraphQL documents.
export {
validate,
ValidationContext,
// All validation rules in the GraphQL Specification.
specifiedRules,
// Individual validation rules.
ExecutableDefinitionsRule,
FieldsOnCorrectTypeRule,
FragmentsOnCompositeTypesRule,
KnownArgumentNamesRule,
KnownDirectivesRule,
KnownFragmentNamesRule,
KnownTypeNamesRule,
LoneAnonymousOperationRule,
NoFragmentCyclesRule,
NoUndefinedVariablesRule,
NoUnusedFragmentsRule,
NoUnusedVariablesRule,
OverlappingFieldsCanBeMergedRule,
PossibleFragmentSpreadsRule,
ProvidedRequiredArgumentsRule,
ScalarLeafsRule,
SingleFieldSubscriptionsRule,
UniqueArgumentNamesRule,
UniqueDirectivesPerLocationRule,
UniqueFragmentNamesRule,
UniqueInputFieldNamesRule,
UniqueOperationNamesRule,
UniqueVariableNamesRule,
ValuesOfCorrectTypeRule,
VariablesAreInputTypesRule,
VariablesInAllowedPositionRule,
// SDL-specific validation rules
LoneSchemaDefinitionRule,
UniqueOperationTypesRule,
UniqueTypeNamesRule,
UniqueEnumValueNamesRule,
UniqueFieldDefinitionNamesRule,
UniqueDirectiveNamesRule,
PossibleTypeExtensionsRule,
} from './validation';
export type { ValidationRule } from './validation';
// Create, format, and print GraphQL errors.
export {
GraphQLError,
syntaxError,
locatedError,
printError,
formatError,
} from './error';
export type { GraphQLFormattedError } from './error';
// Utilities for operating on GraphQL type schema and parsed sources.
export {
// Produce the GraphQL query recommended for a full schema introspection.
// Accepts optional IntrospectionOptions.
getIntrospectionQuery,
// @deprecated: use getIntrospectionQuery - will be removed in v15.
introspectionQuery,
// Gets the target Operation from a Document.
getOperationAST,
// Gets the Type for the target Operation AST.
getOperationRootType,
// Convert a GraphQLSchema to an IntrospectionQuery.
introspectionFromSchema,
// Build a GraphQLSchema from an introspection result.
buildClientSchema,
// Build a GraphQLSchema from a parsed GraphQL Schema language AST.
buildASTSchema,
// Build a GraphQLSchema from a GraphQL schema language document.
buildSchema,
// @deprecated: Get the description from a schema AST node and supports legacy
// syntax for specifying descriptions - will be removed in v16.
getDescription,
// Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
extendSchema,
// Sort a GraphQLSchema.
lexicographicSortSchema,
// Print a GraphQLSchema to GraphQL Schema language.
printSchema,
// Print a GraphQLType to GraphQL Schema language.
printType,
// Prints the built-in introspection schema in the Schema Language
// format.
printIntrospectionSchema,
// Create a GraphQLType from a GraphQL language AST.
typeFromAST,
// Create a JavaScript value from a GraphQL language AST with a Type.
valueFromAST,
// Create a JavaScript value from a GraphQL language AST without a Type.
valueFromASTUntyped,
// Create a GraphQL language AST from a JavaScript value.
astFromValue,
// A helper to use within recursive-descent visitors which need to be aware of
// the GraphQL type system.
TypeInfo,
// Coerces a JavaScript value to a GraphQL type, or produces errors.
coerceInputValue,
// @deprecated use coerceInputValue - will be removed in v15
coerceValue,
// @deprecated use coerceInputValue - will be removed in v15
isValidJSValue,
// @deprecated use validation - will be removed in v15
isValidLiteralValue,
// Concatenates multiple AST together.
concatAST,
// Separates an AST into an AST per Operation.
separateOperations,
// Strips characters that are not significant to the validity or execution
// of a GraphQL document.
stripIgnoredCharacters,
// Comparators for types
isEqualType,
isTypeSubTypeOf,
doTypesOverlap,
// Asserts a string is a valid GraphQL name.
assertValidName,
// Determine if a string is a valid GraphQL name.
isValidNameError,
// Compares two GraphQLSchemas and detects breaking changes.
BreakingChangeType,
DangerousChangeType,
findBreakingChanges,
findDangerousChanges,
// Report all deprecated usage within a GraphQL document.
findDeprecatedUsages,
} from './utilities';
export type {
IntrospectionOptions,
IntrospectionQuery,
IntrospectionSchema,
IntrospectionType,
IntrospectionInputType,
IntrospectionOutputType,
IntrospectionScalarType,
IntrospectionObjectType,
IntrospectionInterfaceType,
IntrospectionUnionType,
IntrospectionEnumType,
IntrospectionInputObjectType,
IntrospectionTypeRef,
IntrospectionInputTypeRef,
IntrospectionOutputTypeRef,
IntrospectionNamedTypeRef,
IntrospectionListTypeRef,
IntrospectionNonNullTypeRef,
IntrospectionField,
IntrospectionInputValue,
IntrospectionEnumValue,
IntrospectionDirective,
BuildSchemaOptions,
BreakingChange,
DangerousChange,
} from './utilities';

97
node_modules/graphql/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,97 @@
/**
* GraphQL.js provides a reference implementation for the GraphQL specification
* but is also a useful utility for operating on GraphQL files and building
* sophisticated tools.
*
* This primary module exports a general purpose function for fulfilling all
* steps of the GraphQL specification in a single operation, but also includes
* utilities for every part of the GraphQL specification:
*
* - Parsing the GraphQL language.
* - Building a GraphQL type schema.
* - Validating a GraphQL request against a type schema.
* - Executing a GraphQL request against a type schema.
*
* This also includes utility functions for operating on GraphQL types and
* GraphQL documents to facilitate building tools.
*
* You may also import from each sub-directory directly. For example, the
* following two import statements are equivalent:
*
* import { parse } from 'graphql';
* import { parse } from 'graphql/language';
*/
// The GraphQL.js version info.
export { version, versionInfo } from './version'; // The primary entry point into fulfilling a GraphQL request.
export { graphql, graphqlSync } from './graphql'; // Create and operate on GraphQL type definitions and schema.
export { // Definitions
GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, // Standard GraphQL Scalars
specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID, // Built-in Directives defined by the Spec
specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, // "Enum" of Type Kinds
TypeKind, // Constant Deprecation Reason
DEFAULT_DEPRECATION_REASON, // GraphQL Types for introspection.
introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, // Meta-field definitions.
SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, // Predicates
isSchema, isDirective, isType, isScalarType, isObjectType, isInterfaceType, isUnionType, isEnumType, isInputObjectType, isListType, isNonNullType, isInputType, isOutputType, isLeafType, isCompositeType, isAbstractType, isWrappingType, isNullableType, isNamedType, isRequiredArgument, isRequiredInputField, isSpecifiedScalarType, isIntrospectionType, isSpecifiedDirective, // Assertions
assertSchema, assertDirective, assertType, assertScalarType, assertObjectType, assertInterfaceType, assertUnionType, assertEnumType, assertInputObjectType, assertListType, assertNonNullType, assertInputType, assertOutputType, assertLeafType, assertCompositeType, assertAbstractType, assertWrappingType, assertNullableType, assertNamedType, // Un-modifiers
getNullableType, getNamedType, // Validate GraphQL schema.
validateSchema, assertValidSchema } from './type';
// Parse and operate on GraphQL language source files.
export { Source, getLocation, // Print source location
printLocation, printSourceLocation, // Lex
createLexer, TokenKind, // Parse
parse, parseValue, parseType, // Print
print, // Visit
visit, visitInParallel, visitWithTypeInfo, getVisitFn, BREAK, Kind, DirectiveLocation, // Predicates
isDefinitionNode, isExecutableDefinitionNode, isSelectionNode, isValueNode, isTypeNode, isTypeSystemDefinitionNode, isTypeDefinitionNode, isTypeSystemExtensionNode, isTypeExtensionNode } from './language';
// Execute GraphQL queries.
export { execute, defaultFieldResolver, defaultTypeResolver, responsePathAsArray, getDirectiveValues } from './execution';
export { subscribe, createSourceEventStream } from './subscription';
// Validate GraphQL documents.
export { validate, ValidationContext, // All validation rules in the GraphQL Specification.
specifiedRules, // Individual validation rules.
ExecutableDefinitionsRule, FieldsOnCorrectTypeRule, FragmentsOnCompositeTypesRule, KnownArgumentNamesRule, KnownDirectivesRule, KnownFragmentNamesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, NoFragmentCyclesRule, NoUndefinedVariablesRule, NoUnusedFragmentsRule, NoUnusedVariablesRule, OverlappingFieldsCanBeMergedRule, PossibleFragmentSpreadsRule, ProvidedRequiredArgumentsRule, ScalarLeafsRule, SingleFieldSubscriptionsRule, UniqueArgumentNamesRule, UniqueDirectivesPerLocationRule, UniqueFragmentNamesRule, UniqueInputFieldNamesRule, UniqueOperationNamesRule, UniqueVariableNamesRule, ValuesOfCorrectTypeRule, VariablesAreInputTypesRule, VariablesInAllowedPositionRule, // SDL-specific validation rules
LoneSchemaDefinitionRule, UniqueOperationTypesRule, UniqueTypeNamesRule, UniqueEnumValueNamesRule, UniqueFieldDefinitionNamesRule, UniqueDirectiveNamesRule, PossibleTypeExtensionsRule } from './validation';
// Create, format, and print GraphQL errors.
export { GraphQLError, syntaxError, locatedError, printError, formatError } from './error';
// Utilities for operating on GraphQL type schema and parsed sources.
export { // Produce the GraphQL query recommended for a full schema introspection.
// Accepts optional IntrospectionOptions.
getIntrospectionQuery, // @deprecated: use getIntrospectionQuery - will be removed in v15.
introspectionQuery, // Gets the target Operation from a Document.
getOperationAST, // Gets the Type for the target Operation AST.
getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery.
introspectionFromSchema, // Build a GraphQLSchema from an introspection result.
buildClientSchema, // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
buildASTSchema, // Build a GraphQLSchema from a GraphQL schema language document.
buildSchema, // @deprecated: Get the description from a schema AST node and supports legacy
// syntax for specifying descriptions - will be removed in v16.
getDescription, // Extends an existing GraphQLSchema from a parsed GraphQL Schema
// language AST.
extendSchema, // Sort a GraphQLSchema.
lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language.
printSchema, // Print a GraphQLType to GraphQL Schema language.
printType, // Prints the built-in introspection schema in the Schema Language
// format.
printIntrospectionSchema, // Create a GraphQLType from a GraphQL language AST.
typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type.
valueFromAST, // Create a JavaScript value from a GraphQL language AST without a Type.
valueFromASTUntyped, // Create a GraphQL language AST from a JavaScript value.
astFromValue, // A helper to use within recursive-descent visitors which need to be aware of
// the GraphQL type system.
TypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors.
coerceInputValue, // @deprecated use coerceInputValue - will be removed in v15
coerceValue, // @deprecated use coerceInputValue - will be removed in v15
isValidJSValue, // @deprecated use validation - will be removed in v15
isValidLiteralValue, // Concatenates multiple AST together.
concatAST, // Separates an AST into an AST per Operation.
separateOperations, // Strips characters that are not significant to the validity or execution
// of a GraphQL document.
stripIgnoredCharacters, // Comparators for types
isEqualType, isTypeSubTypeOf, doTypesOverlap, // Asserts a string is a valid GraphQL name.
assertValidName, // Determine if a string is a valid GraphQL name.
isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.
BreakingChangeType, DangerousChangeType, findBreakingChanges, findDangerousChanges, // Report all deprecated usage within a GraphQL document.
findDeprecatedUsages } from './utilities';

1
node_modules/graphql/jsutils/ObjMap.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";

9
node_modules/graphql/jsutils/ObjMap.js.flow generated vendored Normal file
View File

@@ -0,0 +1,9 @@
// @flow strict
export type ObjMap<T> = { [key: string]: T, __proto__: null, ... };
export type ObjMapLike<T> = ObjMap<T> | { [key: string]: T, ... };
export type ReadOnlyObjMap<T> = { +[key: string]: T, __proto__: null, ... };
export type ReadOnlyObjMapLike<T> =
| ReadOnlyObjMap<T>
| { +[key: string]: T, ... };

1
node_modules/graphql/jsutils/ObjMap.mjs generated vendored Normal file
View File

@@ -0,0 +1 @@

14
node_modules/graphql/jsutils/Path.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export type Path = {
prev: Path | undefined;
key: string | number;
};
/**
* Given a Path and a key, return a new Path containing the new key.
*/
export function addPath(prev: Path | undefined, key: string | number): Path;
/**
* Given a Path, return an Array of the path keys.
*/
export function pathToArray(path: Path): Array<string | number>;

33
node_modules/graphql/jsutils/Path.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addPath = addPath;
exports.pathToArray = pathToArray;
/**
* Given a Path and a key, return a new Path containing the new key.
*/
function addPath(prev, key) {
return {
prev: prev,
key: key
};
}
/**
* Given a Path, return an Array of the path keys.
*/
function pathToArray(path) {
var flattened = [];
var curr = path;
while (curr) {
flattened.push(curr.key);
curr = curr.prev;
}
return flattened.reverse();
}

26
node_modules/graphql/jsutils/Path.js.flow generated vendored Normal file
View File

@@ -0,0 +1,26 @@
// @flow strict
export type Path = {|
+prev: Path | void,
+key: string | number,
|};
/**
* Given a Path and a key, return a new Path containing the new key.
*/
export function addPath(prev: $ReadOnly<Path> | void, key: string | number) {
return { prev, key };
}
/**
* Given a Path, return an Array of the path keys.
*/
export function pathToArray(path: ?$ReadOnly<Path>): Array<string | number> {
const flattened = [];
let curr = path;
while (curr) {
flattened.push(curr.key);
curr = curr.prev;
}
return flattened.reverse();
}

24
node_modules/graphql/jsutils/Path.mjs generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/**
* Given a Path and a key, return a new Path containing the new key.
*/
export function addPath(prev, key) {
return {
prev: prev,
key: key
};
}
/**
* Given a Path, return an Array of the path keys.
*/
export function pathToArray(path) {
var flattened = [];
var curr = path;
while (curr) {
flattened.push(curr.key);
curr = curr.prev;
}
return flattened.reverse();
}

1
node_modules/graphql/jsutils/PromiseOrValue.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export type PromiseOrValue<T> = Promise<T> | T;

1
node_modules/graphql/jsutils/PromiseOrValue.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";

3
node_modules/graphql/jsutils/PromiseOrValue.js.flow generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// @flow strict
export type PromiseOrValue<+T> = Promise<T> | T;

1
node_modules/graphql/jsutils/PromiseOrValue.mjs generated vendored Normal file
View File

@@ -0,0 +1 @@

48
node_modules/graphql/jsutils/dedent.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = dedent;
/**
* An ES6 string tag that fixes indentation. Also removes leading newlines
* and trailing spaces and tabs, but keeps trailing newlines.
*
* Example usage:
* const str = dedent`
* {
* test
* }
* `;
* str === "{\n test\n}\n";
*/
function dedent(strings) {
var str = '';
for (var i = 0; i < strings.length; ++i) {
str += strings[i];
if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
str += i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]; // interpolation
}
}
var trimmedStr = str.replace(/^\n*/m, '') // remove leading newline
.replace(/[ \t]*$/, ''); // remove trailing spaces and tabs
// fixes indentation by removing leading spaces and tabs from each line
var indent = '';
for (var _i2 = 0; _i2 < trimmedStr.length; _i2++) {
var char = trimmedStr[_i2];
if (char !== ' ' && char !== '\t') {
break;
}
indent += char;
}
return trimmedStr.replace(RegExp('^' + indent, 'mg'), ''); // remove indent
}

41
node_modules/graphql/jsutils/dedent.js.flow generated vendored Normal file
View File

@@ -0,0 +1,41 @@
// @flow strict
/**
* An ES6 string tag that fixes indentation. Also removes leading newlines
* and trailing spaces and tabs, but keeps trailing newlines.
*
* Example usage:
* const str = dedent`
* {
* test
* }
* `;
* str === "{\n test\n}\n";
*/
export default function dedent(
strings: $ReadOnlyArray<string>,
...values: $ReadOnlyArray<string>
): string {
let str = '';
for (let i = 0; i < strings.length; ++i) {
str += strings[i];
if (i < values.length) {
str += values[i]; // interpolation
}
}
const trimmedStr = str
.replace(/^\n*/m, '') // remove leading newline
.replace(/[ \t]*$/, ''); // remove trailing spaces and tabs
// fixes indentation by removing leading spaces and tabs from each line
let indent = '';
for (const char of trimmedStr) {
if (char !== ' ' && char !== '\t') {
break;
}
indent += char;
}
return trimmedStr.replace(RegExp('^' + indent, 'mg'), ''); // remove indent
}

41
node_modules/graphql/jsutils/dedent.mjs generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/**
* An ES6 string tag that fixes indentation. Also removes leading newlines
* and trailing spaces and tabs, but keeps trailing newlines.
*
* Example usage:
* const str = dedent`
* {
* test
* }
* `;
* str === "{\n test\n}\n";
*/
export default function dedent(strings) {
var str = '';
for (var i = 0; i < strings.length; ++i) {
str += strings[i];
if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
str += i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]; // interpolation
}
}
var trimmedStr = str.replace(/^\n*/m, '') // remove leading newline
.replace(/[ \t]*$/, ''); // remove trailing spaces and tabs
// fixes indentation by removing leading spaces and tabs from each line
var indent = '';
for (var _i2 = 0; _i2 < trimmedStr.length; _i2++) {
var char = trimmedStr[_i2];
if (char !== ' ' && char !== '\t') {
break;
}
indent += char;
}
return trimmedStr.replace(RegExp('^' + indent, 'mg'), ''); // remove indent
}

24
node_modules/graphql/jsutils/defineToJSON.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = defineToJSON;
var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* The `defineToJSON()` function defines toJSON() and inspect() prototype
* methods, if no function provided they become aliases for toString().
*/
function defineToJSON(classObject) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : classObject.prototype.toString;
classObject.prototype.toJSON = fn;
classObject.prototype.inspect = fn;
if (_nodejsCustomInspectSymbol.default) {
classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
}
}

18
node_modules/graphql/jsutils/defineToJSON.js.flow generated vendored Normal file
View File

@@ -0,0 +1,18 @@
// @flow strict
import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
/**
* The `defineToJSON()` function defines toJSON() and inspect() prototype
* methods, if no function provided they become aliases for toString().
*/
export default function defineToJSON(
classObject: Class<any> | ((...args: Array<any>) => mixed),
fn?: () => mixed = classObject.prototype.toString,
): void {
classObject.prototype.toJSON = fn;
classObject.prototype.inspect = fn;
if (nodejsCustomInspectSymbol) {
classObject.prototype[nodejsCustomInspectSymbol] = fn;
}
}

15
node_modules/graphql/jsutils/defineToJSON.mjs generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
/**
* The `defineToJSON()` function defines toJSON() and inspect() prototype
* methods, if no function provided they become aliases for toString().
*/
export default function defineToJSON(classObject) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : classObject.prototype.toString;
classObject.prototype.toJSON = fn;
classObject.prototype.inspect = fn;
if (nodejsCustomInspectSymbol) {
classObject.prototype[nodejsCustomInspectSymbol] = fn;
}
}

29
node_modules/graphql/jsutils/defineToStringTag.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = defineToStringTag;
/**
* The `defineToStringTag()` function checks first to see if the runtime
* supports the `Symbol` class and then if the `Symbol.toStringTag` constant
* is defined as a `Symbol` instance. If both conditions are met, the
* Symbol.toStringTag property is defined as a getter that returns the
* supplied class constructor's name.
*
* @method defineToStringTag
*
* @param {Class<any>} classObject a class such as Object, String, Number but
* typically one of your own creation through the class keyword; `class A {}`,
* for example.
*/
function defineToStringTag(classObject) {
if (typeof Symbol === 'function' && Symbol.toStringTag) {
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
get: function get() {
return this.constructor.name;
}
});
}
}

24
node_modules/graphql/jsutils/defineToStringTag.js.flow generated vendored Normal file
View File

@@ -0,0 +1,24 @@
// @flow strict
/**
* The `defineToStringTag()` function checks first to see if the runtime
* supports the `Symbol` class and then if the `Symbol.toStringTag` constant
* is defined as a `Symbol` instance. If both conditions are met, the
* Symbol.toStringTag property is defined as a getter that returns the
* supplied class constructor's name.
*
* @method defineToStringTag
*
* @param {Class<any>} classObject a class such as Object, String, Number but
* typically one of your own creation through the class keyword; `class A {}`,
* for example.
*/
export default function defineToStringTag(classObject: Class<mixed>): void {
if (typeof Symbol === 'function' && Symbol.toStringTag) {
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
get() {
return this.constructor.name;
},
});
}
}

22
node_modules/graphql/jsutils/defineToStringTag.mjs generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* The `defineToStringTag()` function checks first to see if the runtime
* supports the `Symbol` class and then if the `Symbol.toStringTag` constant
* is defined as a `Symbol` instance. If both conditions are met, the
* Symbol.toStringTag property is defined as a getter that returns the
* supplied class constructor's name.
*
* @method defineToStringTag
*
* @param {Class<any>} classObject a class such as Object, String, Number but
* typically one of your own creation through the class keyword; `class A {}`,
* for example.
*/
export default function defineToStringTag(classObject) {
if (typeof Symbol === 'function' && Symbol.toStringTag) {
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
get: function get() {
return this.constructor.name;
}
});
}
}

14
node_modules/graphql/jsutils/devAssert.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = devAssert;
function devAssert(condition, message) {
var booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message);
}
}

8
node_modules/graphql/jsutils/devAssert.js.flow generated vendored Normal file
View File

@@ -0,0 +1,8 @@
// @flow strict
export default function devAssert(condition: mixed, message: string): void {
const booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message);
}
}

7
node_modules/graphql/jsutils/devAssert.mjs generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export default function devAssert(condition, message) {
var booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message);
}
}

38
node_modules/graphql/jsutils/didYouMean.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = didYouMean;
var MAX_SUGGESTIONS = 5;
/**
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
*/
// eslint-disable-next-line no-redeclare
function didYouMean(firstArg, secondArg) {
var _ref = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg],
subMessage = _ref[0],
suggestions = _ref[1];
var message = ' Did you mean ';
if (subMessage) {
message += subMessage + ' ';
}
switch (suggestions.length) {
case 0:
return '';
case 1:
return message + suggestions[0] + '?';
case 2:
return message + suggestions[0] + ' or ' + suggestions[1] + '?';
}
var selected = suggestions.slice(0, MAX_SUGGESTIONS);
var lastItem = selected.pop();
return message + selected.join(', ') + ', or ' + lastItem + '?';
}

39
node_modules/graphql/jsutils/didYouMean.js.flow generated vendored Normal file
View File

@@ -0,0 +1,39 @@
// @flow strict
const MAX_SUGGESTIONS = 5;
/**
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
*/
declare function didYouMean(suggestions: $ReadOnlyArray<string>): string;
// eslint-disable-next-line no-redeclare
declare function didYouMean(
subMessage: string,
suggestions: $ReadOnlyArray<string>,
): string;
// eslint-disable-next-line no-redeclare
export default function didYouMean(firstArg, secondArg) {
const [subMessage, suggestions] =
typeof firstArg === 'string'
? [firstArg, secondArg]
: [undefined, firstArg];
let message = ' Did you mean ';
if (subMessage) {
message += subMessage + ' ';
}
switch (suggestions.length) {
case 0:
return '';
case 1:
return message + suggestions[0] + '?';
case 2:
return message + suggestions[0] + ' or ' + suggestions[1] + '?';
}
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
const lastItem = selected.pop();
return message + selected.join(', ') + ', or ' + lastItem + '?';
}

32
node_modules/graphql/jsutils/didYouMean.mjs generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var MAX_SUGGESTIONS = 5;
/**
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
*/
// eslint-disable-next-line no-redeclare
export default function didYouMean(firstArg, secondArg) {
var _ref = typeof firstArg === 'string' ? [firstArg, secondArg] : [undefined, firstArg],
subMessage = _ref[0],
suggestions = _ref[1];
var message = ' Did you mean ';
if (subMessage) {
message += subMessage + ' ';
}
switch (suggestions.length) {
case 0:
return '';
case 1:
return message + suggestions[0] + '?';
case 2:
return message + suggestions[0] + ' or ' + suggestions[1] + '?';
}
var selected = suggestions.slice(0, MAX_SUGGESTIONS);
var lastItem = selected.pop();
return message + selected.join(', ') + ', or ' + lastItem + '?';
}

13
node_modules/graphql/jsutils/identityFunc.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = identityFunc;
/**
* Returns the first argument it receives.
*/
function identityFunc(x) {
return x;
}

8
node_modules/graphql/jsutils/identityFunc.js.flow generated vendored Normal file
View File

@@ -0,0 +1,8 @@
// @flow strict
/**
* Returns the first argument it receives.
*/
export default function identityFunc<T>(x: T): T {
return x;
}

6
node_modules/graphql/jsutils/identityFunc.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* Returns the first argument it receives.
*/
export default function identityFunc(x) {
return x;
}

134
node_modules/graphql/jsutils/inspect.js generated vendored Normal file
View File

@@ -0,0 +1,134 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = inspect;
var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var MAX_ARRAY_LENGTH = 10;
var MAX_RECURSIVE_DEPTH = 2;
/**
* Used to print values in error messages.
*/
function inspect(value) {
return formatValue(value, []);
}
function formatValue(value, seenValues) {
switch (_typeof(value)) {
case 'string':
return JSON.stringify(value);
case 'function':
return value.name ? "[function ".concat(value.name, "]") : '[function]';
case 'object':
if (value === null) {
return 'null';
}
return formatObjectValue(value, seenValues);
default:
return String(value);
}
}
function formatObjectValue(value, previouslySeenValues) {
if (previouslySeenValues.indexOf(value) !== -1) {
return '[Circular]';
}
var seenValues = [].concat(previouslySeenValues, [value]);
var customInspectFn = getCustomFn(value);
if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
var customValue = customInspectFn.call(value); // check for infinite recursion
if (customValue !== value) {
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
}
} else if (Array.isArray(value)) {
return formatArray(value, seenValues);
}
return formatObject(value, seenValues);
}
function formatObject(object, seenValues) {
var keys = Object.keys(object);
if (keys.length === 0) {
return '{}';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[' + getObjectTag(object) + ']';
}
var properties = keys.map(function (key) {
var value = formatValue(object[key], seenValues);
return key + ': ' + value;
});
return '{ ' + properties.join(', ') + ' }';
}
function formatArray(array, seenValues) {
if (array.length === 0) {
return '[]';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[Array]';
}
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
var remaining = array.length - len;
var items = [];
for (var i = 0; i < len; ++i) {
items.push(formatValue(array[i], seenValues));
}
if (remaining === 1) {
items.push('... 1 more item');
} else if (remaining > 1) {
items.push("... ".concat(remaining, " more items"));
}
return '[' + items.join(', ') + ']';
}
function getCustomFn(object) {
var customInspectFn = object[String(_nodejsCustomInspectSymbol.default)];
if (typeof customInspectFn === 'function') {
return customInspectFn;
}
if (typeof object.inspect === 'function') {
return object.inspect;
}
}
function getObjectTag(object) {
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
if (tag === 'Object' && typeof object.constructor === 'function') {
var name = object.constructor.name;
if (typeof name === 'string' && name !== '') {
return name;
}
}
return tag;
}

126
node_modules/graphql/jsutils/inspect.js.flow generated vendored Normal file
View File

@@ -0,0 +1,126 @@
// @flow strict
import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
const MAX_ARRAY_LENGTH = 10;
const MAX_RECURSIVE_DEPTH = 2;
/**
* Used to print values in error messages.
*/
export default function inspect(value: mixed): string {
return formatValue(value, []);
}
function formatValue(value, seenValues) {
switch (typeof value) {
case 'string':
return JSON.stringify(value);
case 'function':
return value.name ? `[function ${value.name}]` : '[function]';
case 'object':
if (value === null) {
return 'null';
}
return formatObjectValue(value, seenValues);
default:
return String(value);
}
}
function formatObjectValue(value, previouslySeenValues) {
if (previouslySeenValues.indexOf(value) !== -1) {
return '[Circular]';
}
const seenValues = [...previouslySeenValues, value];
const customInspectFn = getCustomFn(value);
if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
const customValue = customInspectFn.call(value);
// check for infinite recursion
if (customValue !== value) {
return typeof customValue === 'string'
? customValue
: formatValue(customValue, seenValues);
}
} else if (Array.isArray(value)) {
return formatArray(value, seenValues);
}
return formatObject(value, seenValues);
}
function formatObject(object, seenValues) {
const keys = Object.keys(object);
if (keys.length === 0) {
return '{}';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[' + getObjectTag(object) + ']';
}
const properties = keys.map(key => {
const value = formatValue(object[key], seenValues);
return key + ': ' + value;
});
return '{ ' + properties.join(', ') + ' }';
}
function formatArray(array, seenValues) {
if (array.length === 0) {
return '[]';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[Array]';
}
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
const remaining = array.length - len;
const items = [];
for (let i = 0; i < len; ++i) {
items.push(formatValue(array[i], seenValues));
}
if (remaining === 1) {
items.push('... 1 more item');
} else if (remaining > 1) {
items.push(`... ${remaining} more items`);
}
return '[' + items.join(', ') + ']';
}
function getCustomFn(object) {
const customInspectFn = object[String(nodejsCustomInspectSymbol)];
if (typeof customInspectFn === 'function') {
return customInspectFn;
}
if (typeof object.inspect === 'function') {
return object.inspect;
}
}
function getObjectTag(object) {
const tag = Object.prototype.toString
.call(object)
.replace(/^\[object /, '')
.replace(/]$/, '');
if (tag === 'Object' && typeof object.constructor === 'function') {
const name = object.constructor.name;
if (typeof name === 'string' && name !== '') {
return name;
}
}
return tag;
}

124
node_modules/graphql/jsutils/inspect.mjs generated vendored Normal file
View File

@@ -0,0 +1,124 @@
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
var MAX_ARRAY_LENGTH = 10;
var MAX_RECURSIVE_DEPTH = 2;
/**
* Used to print values in error messages.
*/
export default function inspect(value) {
return formatValue(value, []);
}
function formatValue(value, seenValues) {
switch (_typeof(value)) {
case 'string':
return JSON.stringify(value);
case 'function':
return value.name ? "[function ".concat(value.name, "]") : '[function]';
case 'object':
if (value === null) {
return 'null';
}
return formatObjectValue(value, seenValues);
default:
return String(value);
}
}
function formatObjectValue(value, previouslySeenValues) {
if (previouslySeenValues.indexOf(value) !== -1) {
return '[Circular]';
}
var seenValues = [].concat(previouslySeenValues, [value]);
var customInspectFn = getCustomFn(value);
if (customInspectFn !== undefined) {
// $FlowFixMe(>=0.90.0)
var customValue = customInspectFn.call(value); // check for infinite recursion
if (customValue !== value) {
return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
}
} else if (Array.isArray(value)) {
return formatArray(value, seenValues);
}
return formatObject(value, seenValues);
}
function formatObject(object, seenValues) {
var keys = Object.keys(object);
if (keys.length === 0) {
return '{}';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[' + getObjectTag(object) + ']';
}
var properties = keys.map(function (key) {
var value = formatValue(object[key], seenValues);
return key + ': ' + value;
});
return '{ ' + properties.join(', ') + ' }';
}
function formatArray(array, seenValues) {
if (array.length === 0) {
return '[]';
}
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
return '[Array]';
}
var len = Math.min(MAX_ARRAY_LENGTH, array.length);
var remaining = array.length - len;
var items = [];
for (var i = 0; i < len; ++i) {
items.push(formatValue(array[i], seenValues));
}
if (remaining === 1) {
items.push('... 1 more item');
} else if (remaining > 1) {
items.push("... ".concat(remaining, " more items"));
}
return '[' + items.join(', ') + ']';
}
function getCustomFn(object) {
var customInspectFn = object[String(nodejsCustomInspectSymbol)];
if (typeof customInspectFn === 'function') {
return customInspectFn;
}
if (typeof object.inspect === 'function') {
return object.inspect;
}
}
function getObjectTag(object) {
var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
if (tag === 'Object' && typeof object.constructor === 'function') {
var name = object.constructor.name;
if (typeof name === 'string' && name !== '') {
return name;
}
}
return tag;
}

35
node_modules/graphql/jsutils/instanceOf.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* 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/
var _default = process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
function instanceOf(value, constructor) {
return value instanceof constructor;
} : // eslint-disable-next-line no-shadow
function instanceOf(value, constructor) {
if (value instanceof constructor) {
return true;
}
if (value) {
var valueClass = value.constructor;
var className = constructor.name;
if (className && valueClass && valueClass.name === className) {
throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
}
}
return false;
};
exports.default = _default;

45
node_modules/graphql/jsutils/instanceOf.js.flow generated vendored Normal file
View File

@@ -0,0 +1,45 @@
// @flow strict
/**
* A replacement for instanceof which includes an error warning when multi-realm
* constructors are detected.
*/
declare function instanceOf(
value: mixed,
constructor: mixed,
): boolean %checks(value instanceof constructor);
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
// See: https://webpack.js.org/guides/production/
export default process.env.NODE_ENV === 'production'
? // eslint-disable-next-line no-shadow
function instanceOf(value: mixed, constructor: mixed) {
return value instanceof constructor;
}
: // eslint-disable-next-line no-shadow
function instanceOf(value: any, constructor: any) {
if (value instanceof constructor) {
return true;
}
if (value) {
const valueClass = value.constructor;
const className = constructor.name;
if (className && valueClass && valueClass.name === className) {
throw new Error(
`Cannot use ${className} "${value}" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.`,
);
}
}
return false;
};

26
node_modules/graphql/jsutils/instanceOf.mjs generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/**
* 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/
export default process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
function instanceOf(value, constructor) {
return value instanceof constructor;
} : // eslint-disable-next-line no-shadow
function instanceOf(value, constructor) {
if (value instanceof constructor) {
return true;
}
if (value) {
var valueClass = value.constructor;
var className = constructor.name;
if (className && valueClass && valueClass.name === className) {
throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
}
}
return false;
};

14
node_modules/graphql/jsutils/invariant.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = invariant;
function invariant(condition, message) {
var booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message || 'Unexpected invariant triggered');
}
}

8
node_modules/graphql/jsutils/invariant.js.flow generated vendored Normal file
View File

@@ -0,0 +1,8 @@
// @flow strict
export default function invariant(condition: mixed, message?: string): void {
const booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message || 'Unexpected invariant triggered');
}
}

7
node_modules/graphql/jsutils/invariant.mjs generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export default function invariant(condition, message) {
var booleanCondition = Boolean(condition);
if (!booleanCondition) {
throw new Error(message || 'Unexpected invariant triggered');
}
}

13
node_modules/graphql/jsutils/isInvalid.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isInvalid;
/**
* Returns true if a value is undefined, or NaN.
*/
function isInvalid(value) {
return value === undefined || value !== value;
}

8
node_modules/graphql/jsutils/isInvalid.js.flow generated vendored Normal file
View File

@@ -0,0 +1,8 @@
// @flow strict
/**
* Returns true if a value is undefined, or NaN.
*/
export default function isInvalid(value: mixed): boolean %checks {
return value === undefined || value !== value;
}

6
node_modules/graphql/jsutils/isInvalid.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* Returns true if a value is undefined, or NaN.
*/
export default function isInvalid(value) {
return value === undefined || value !== value;
}

13
node_modules/graphql/jsutils/isNullish.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isNullish;
/**
* Returns true if a value is null, undefined, or NaN.
*/
function isNullish(value) {
return value === null || value === undefined || value !== value;
}

8
node_modules/graphql/jsutils/isNullish.js.flow generated vendored Normal file
View File

@@ -0,0 +1,8 @@
// @flow strict
/**
* Returns true if a value is null, undefined, or NaN.
*/
export default function isNullish(value: mixed): boolean %checks {
return value === null || value === undefined || value !== value;
}

6
node_modules/graphql/jsutils/isNullish.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* Returns true if a value is null, undefined, or NaN.
*/
export default function isNullish(value) {
return value === null || value === undefined || value !== value;
}

16
node_modules/graphql/jsutils/isObjectLike.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isObjectLike;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/**
* Return true if `value` is object-like. A value is object-like if it's not
* `null` and has a `typeof` result of "object".
*/
function isObjectLike(value) {
return _typeof(value) == 'object' && value !== null;
}

9
node_modules/graphql/jsutils/isObjectLike.js.flow generated vendored Normal file
View File

@@ -0,0 +1,9 @@
// @flow strict
/**
* Return true if `value` is object-like. A value is object-like if it's not
* `null` and has a `typeof` result of "object".
*/
export default function isObjectLike(value: mixed): boolean %checks {
return typeof value == 'object' && value !== null;
}

9
node_modules/graphql/jsutils/isObjectLike.mjs generated vendored Normal file
View File

@@ -0,0 +1,9 @@
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/**
* Return true if `value` is object-like. A value is object-like if it's not
* `null` and has a `typeof` result of "object".
*/
export default function isObjectLike(value) {
return _typeof(value) == 'object' && value !== null;
}

15
node_modules/graphql/jsutils/isPromise.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isPromise;
/**
* Returns true if the value acts like a Promise, i.e. has a "then" function,
* otherwise returns false.
*/
// eslint-disable-next-line no-redeclare
function isPromise(value) {
return Boolean(value && typeof value.then === 'function');
}

13
node_modules/graphql/jsutils/isPromise.js.flow generated vendored Normal file
View File

@@ -0,0 +1,13 @@
// @flow strict
/**
* Returns true if the value acts like a Promise, i.e. has a "then" function,
* otherwise returns false.
*/
declare function isPromise(value: mixed): boolean %checks(value instanceof
Promise);
// eslint-disable-next-line no-redeclare
export default function isPromise(value) {
return Boolean(value && typeof value.then === 'function');
}

8
node_modules/graphql/jsutils/isPromise.mjs generated vendored Normal file
View File

@@ -0,0 +1,8 @@
/**
* Returns true if the value acts like a Promise, i.e. has a "then" function,
* otherwise returns false.
*/
// eslint-disable-next-line no-redeclare
export default function isPromise(value) {
return Boolean(value && typeof value.then === 'function');
}

36
node_modules/graphql/jsutils/keyMap.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = keyMap;
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* for each value in the array.
*
* This provides a convenient lookup for the array items if the key function
* produces unique results.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: { name: 'Jon', num: '555-1234' },
* // Jenny: { name: 'Jenny', num: '867-5309' } }
* const entriesByName = keyMap(
* phoneBook,
* entry => entry.name
* )
*
* // { name: 'Jenny', num: '857-6309' }
* const jennyEntry = entriesByName['Jenny']
*
*/
function keyMap(list, keyFn) {
return list.reduce(function (map, item) {
map[keyFn(item)] = item;
return map;
}, Object.create(null));
}

36
node_modules/graphql/jsutils/keyMap.js.flow generated vendored Normal file
View File

@@ -0,0 +1,36 @@
// @flow strict
import { type ObjMap } from './ObjMap';
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* for each value in the array.
*
* This provides a convenient lookup for the array items if the key function
* produces unique results.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: { name: 'Jon', num: '555-1234' },
* // Jenny: { name: 'Jenny', num: '867-5309' } }
* const entriesByName = keyMap(
* phoneBook,
* entry => entry.name
* )
*
* // { name: 'Jenny', num: '857-6309' }
* const jennyEntry = entriesByName['Jenny']
*
*/
export default function keyMap<T>(
list: $ReadOnlyArray<T>,
keyFn: (item: T) => string,
): ObjMap<T> {
return list.reduce((map, item) => {
map[keyFn(item)] = item;
return map;
}, Object.create(null));
}

29
node_modules/graphql/jsutils/keyMap.mjs generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* for each value in the array.
*
* This provides a convenient lookup for the array items if the key function
* produces unique results.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: { name: 'Jon', num: '555-1234' },
* // Jenny: { name: 'Jenny', num: '867-5309' } }
* const entriesByName = keyMap(
* phoneBook,
* entry => entry.name
* )
*
* // { name: 'Jenny', num: '857-6309' }
* const jennyEntry = entriesByName['Jenny']
*
*/
export default function keyMap(list, keyFn) {
return list.reduce(function (map, item) {
map[keyFn(item)] = item;
return map;
}, Object.create(null));
}

30
node_modules/graphql/jsutils/keyValMap.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = keyValMap;
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* and a function to produce the values from each item in the array.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: '555-1234', Jenny: '867-5309' }
* const phonesByName = keyValMap(
* phoneBook,
* entry => entry.name,
* entry => entry.num
* )
*
*/
function keyValMap(list, keyFn, valFn) {
return list.reduce(function (map, item) {
map[keyFn(item)] = valFn(item);
return map;
}, Object.create(null));
}

31
node_modules/graphql/jsutils/keyValMap.js.flow generated vendored Normal file
View File

@@ -0,0 +1,31 @@
// @flow strict
import { type ObjMap } from './ObjMap';
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* and a function to produce the values from each item in the array.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: '555-1234', Jenny: '867-5309' }
* const phonesByName = keyValMap(
* phoneBook,
* entry => entry.name,
* entry => entry.num
* )
*
*/
export default function keyValMap<T, V>(
list: $ReadOnlyArray<T>,
keyFn: (item: T) => string,
valFn: (item: T) => V,
): ObjMap<V> {
return list.reduce((map, item) => {
map[keyFn(item)] = valFn(item);
return map;
}, Object.create(null));
}

23
node_modules/graphql/jsutils/keyValMap.mjs generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* Creates a keyed JS object from an array, given a function to produce the keys
* and a function to produce the values from each item in the array.
*
* const phoneBook = [
* { name: 'Jon', num: '555-1234' },
* { name: 'Jenny', num: '867-5309' }
* ]
*
* // { Jon: '555-1234', Jenny: '867-5309' }
* const phonesByName = keyValMap(
* phoneBook,
* entry => entry.name,
* entry => entry.num
* )
*
*/
export default function keyValMap(list, keyFn, valFn) {
return list.reduce(function (map, item) {
map[keyFn(item)] = valFn(item);
return map;
}, Object.create(null));
}

27
node_modules/graphql/jsutils/mapValue.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = mapValue;
var _objectEntries3 = _interopRequireDefault(require("../polyfills/objectEntries"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Creates an object map with the same keys as `map` and values generated by
* running each value of `map` thru `fn`.
*/
function mapValue(map, fn) {
var result = Object.create(null);
for (var _i2 = 0, _objectEntries2 = (0, _objectEntries3.default)(map); _i2 < _objectEntries2.length; _i2++) {
var _ref2 = _objectEntries2[_i2];
var _key = _ref2[0];
var _value = _ref2[1];
result[_key] = fn(_value, _key);
}
return result;
}

21
node_modules/graphql/jsutils/mapValue.js.flow generated vendored Normal file
View File

@@ -0,0 +1,21 @@
// @flow strict
import objectEntries from '../polyfills/objectEntries';
import { type ObjMap } from './ObjMap';
/**
* Creates an object map with the same keys as `map` and values generated by
* running each value of `map` thru `fn`.
*/
export default function mapValue<T, V>(
map: ObjMap<T>,
fn: (value: T, key: string) => V,
): ObjMap<V> {
const result = Object.create(null);
for (const [key, value] of objectEntries(map)) {
result[key] = fn(value, key);
}
return result;
}

Some files were not shown because too many files have changed in this diff Show More