@fragment-dev/cli
Version:
1,415 lines (1,400 loc) • 464 kB
JavaScript
import {
require_GraphQLError,
require_ast,
require_blockString,
require_characterClasses,
require_devAssert,
require_directiveLocation,
require_inspect,
require_instanceOf,
require_invariant,
require_isObjectLike,
require_kinds,
require_lexer,
require_location,
require_parser,
require_printLocation,
require_printer,
require_source,
require_syntaxError,
require_tokenKind,
require_visitor
} from "./chunk-7K4RMTU4.js";
import {
__commonJS,
init_cjs_shims
} from "./chunk-7GH3YGSC.js";
// ../../node_modules/graphql/version.js
var require_version = __commonJS({
"../../node_modules/graphql/version.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.versionInfo = exports.version = void 0;
var version = "16.8.1";
exports.version = version;
var versionInfo = Object.freeze({
major: 16,
minor: 8,
patch: 1,
preReleaseTag: null
});
exports.versionInfo = versionInfo;
}
});
// ../../node_modules/graphql/jsutils/isPromise.js
var require_isPromise = __commonJS({
"../../node_modules/graphql/jsutils/isPromise.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isPromise = isPromise;
function isPromise(value) {
return typeof (value === null || value === void 0 ? void 0 : value.then) === "function";
}
}
});
// ../../node_modules/graphql/jsutils/didYouMean.js
var require_didYouMean = __commonJS({
"../../node_modules/graphql/jsutils/didYouMean.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.didYouMean = didYouMean;
var MAX_SUGGESTIONS = 5;
function didYouMean(firstArg, secondArg) {
const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
let message = " Did you mean ";
if (subMessage) {
message += subMessage + " ";
}
const suggestions = suggestionsArg.map((x) => `"${x}"`);
switch (suggestions.length) {
case 0:
return "";
case 1:
return message + suggestions[0] + "?";
case 2:
return message + suggestions[0] + " or " + suggestions[1] + "?";
}
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
const lastItem = selected.pop();
return message + selected.join(", ") + ", or " + lastItem + "?";
}
}
});
// ../../node_modules/graphql/jsutils/identityFunc.js
var require_identityFunc = __commonJS({
"../../node_modules/graphql/jsutils/identityFunc.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.identityFunc = identityFunc;
function identityFunc(x) {
return x;
}
}
});
// ../../node_modules/graphql/jsutils/keyMap.js
var require_keyMap = __commonJS({
"../../node_modules/graphql/jsutils/keyMap.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.keyMap = keyMap;
function keyMap(list, keyFn) {
const result = /* @__PURE__ */ Object.create(null);
for (const item of list) {
result[keyFn(item)] = item;
}
return result;
}
}
});
// ../../node_modules/graphql/jsutils/keyValMap.js
var require_keyValMap = __commonJS({
"../../node_modules/graphql/jsutils/keyValMap.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.keyValMap = keyValMap;
function keyValMap(list, keyFn, valFn) {
const result = /* @__PURE__ */ Object.create(null);
for (const item of list) {
result[keyFn(item)] = valFn(item);
}
return result;
}
}
});
// ../../node_modules/graphql/jsutils/mapValue.js
var require_mapValue = __commonJS({
"../../node_modules/graphql/jsutils/mapValue.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mapValue = mapValue;
function mapValue(map, fn) {
const result = /* @__PURE__ */ Object.create(null);
for (const key of Object.keys(map)) {
result[key] = fn(map[key], key);
}
return result;
}
}
});
// ../../node_modules/graphql/jsutils/naturalCompare.js
var require_naturalCompare = __commonJS({
"../../node_modules/graphql/jsutils/naturalCompare.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.naturalCompare = naturalCompare;
function naturalCompare(aStr, bStr) {
let aIndex = 0;
let bIndex = 0;
while (aIndex < aStr.length && bIndex < bStr.length) {
let aChar = aStr.charCodeAt(aIndex);
let bChar = bStr.charCodeAt(bIndex);
if (isDigit(aChar) && isDigit(bChar)) {
let aNum = 0;
do {
++aIndex;
aNum = aNum * 10 + aChar - DIGIT_0;
aChar = aStr.charCodeAt(aIndex);
} while (isDigit(aChar) && aNum > 0);
let bNum = 0;
do {
++bIndex;
bNum = bNum * 10 + bChar - DIGIT_0;
bChar = bStr.charCodeAt(bIndex);
} while (isDigit(bChar) && bNum > 0);
if (aNum < bNum) {
return -1;
}
if (aNum > bNum) {
return 1;
}
} else {
if (aChar < bChar) {
return -1;
}
if (aChar > bChar) {
return 1;
}
++aIndex;
++bIndex;
}
}
return aStr.length - bStr.length;
}
var DIGIT_0 = 48;
var DIGIT_9 = 57;
function isDigit(code) {
return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9;
}
}
});
// ../../node_modules/graphql/jsutils/suggestionList.js
var require_suggestionList = __commonJS({
"../../node_modules/graphql/jsutils/suggestionList.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.suggestionList = suggestionList;
var _naturalCompare = require_naturalCompare();
function suggestionList(input, options) {
const optionsByDistance = /* @__PURE__ */ Object.create(null);
const lexicalDistance = new LexicalDistance(input);
const threshold = Math.floor(input.length * 0.4) + 1;
for (const option of options) {
const distance = lexicalDistance.measure(option, threshold);
if (distance !== void 0) {
optionsByDistance[option] = distance;
}
}
return Object.keys(optionsByDistance).sort((a, b) => {
const distanceDiff = optionsByDistance[a] - optionsByDistance[b];
return distanceDiff !== 0 ? distanceDiff : (0, _naturalCompare.naturalCompare)(a, b);
});
}
var LexicalDistance = class {
constructor(input) {
this._input = input;
this._inputLowerCase = input.toLowerCase();
this._inputArray = stringToArray(this._inputLowerCase);
this._rows = [
new Array(input.length + 1).fill(0),
new Array(input.length + 1).fill(0),
new Array(input.length + 1).fill(0)
];
}
measure(option, threshold) {
if (this._input === option) {
return 0;
}
const optionLowerCase = option.toLowerCase();
if (this._inputLowerCase === optionLowerCase) {
return 1;
}
let a = stringToArray(optionLowerCase);
let b = this._inputArray;
if (a.length < b.length) {
const tmp = a;
a = b;
b = tmp;
}
const aLength = a.length;
const bLength = b.length;
if (aLength - bLength > threshold) {
return void 0;
}
const rows = this._rows;
for (let j = 0; j <= bLength; j++) {
rows[0][j] = j;
}
for (let i = 1; i <= aLength; i++) {
const upRow = rows[(i - 1) % 3];
const currentRow = rows[i % 3];
let smallestCell = currentRow[0] = i;
for (let j = 1; j <= bLength; j++) {
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
let currentCell = Math.min(
upRow[j] + 1,
// delete
currentRow[j - 1] + 1,
// insert
upRow[j - 1] + cost
// substitute
);
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
const doubleDiagonalCell = rows[(i - 2) % 3][j - 2];
currentCell = Math.min(currentCell, doubleDiagonalCell + 1);
}
if (currentCell < smallestCell) {
smallestCell = currentCell;
}
currentRow[j] = currentCell;
}
if (smallestCell > threshold) {
return void 0;
}
}
const distance = rows[aLength % 3][bLength];
return distance <= threshold ? distance : void 0;
}
};
function stringToArray(str) {
const strLength = str.length;
const array = new Array(strLength);
for (let i = 0; i < strLength; ++i) {
array[i] = str.charCodeAt(i);
}
return array;
}
}
});
// ../../node_modules/graphql/jsutils/toObjMap.js
var require_toObjMap = __commonJS({
"../../node_modules/graphql/jsutils/toObjMap.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toObjMap = toObjMap;
function toObjMap(obj) {
if (obj == null) {
return /* @__PURE__ */ Object.create(null);
}
if (Object.getPrototypeOf(obj) === null) {
return obj;
}
const map = /* @__PURE__ */ Object.create(null);
for (const [key, value] of Object.entries(obj)) {
map[key] = value;
}
return map;
}
}
});
// ../../node_modules/graphql/utilities/valueFromASTUntyped.js
var require_valueFromASTUntyped = __commonJS({
"../../node_modules/graphql/utilities/valueFromASTUntyped.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.valueFromASTUntyped = valueFromASTUntyped;
var _keyValMap = require_keyValMap();
var _kinds = require_kinds();
function valueFromASTUntyped(valueNode, variables) {
switch (valueNode.kind) {
case _kinds.Kind.NULL:
return null;
case _kinds.Kind.INT:
return parseInt(valueNode.value, 10);
case _kinds.Kind.FLOAT:
return parseFloat(valueNode.value);
case _kinds.Kind.STRING:
case _kinds.Kind.ENUM:
case _kinds.Kind.BOOLEAN:
return valueNode.value;
case _kinds.Kind.LIST:
return valueNode.values.map(
(node) => valueFromASTUntyped(node, variables)
);
case _kinds.Kind.OBJECT:
return (0, _keyValMap.keyValMap)(
valueNode.fields,
(field) => field.name.value,
(field) => valueFromASTUntyped(field.value, variables)
);
case _kinds.Kind.VARIABLE:
return variables === null || variables === void 0 ? void 0 : variables[valueNode.name.value];
}
}
}
});
// ../../node_modules/graphql/type/assertName.js
var require_assertName = __commonJS({
"../../node_modules/graphql/type/assertName.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertEnumValueName = assertEnumValueName;
exports.assertName = assertName;
var _devAssert = require_devAssert();
var _GraphQLError = require_GraphQLError();
var _characterClasses = require_characterClasses();
function assertName(name) {
name != null || (0, _devAssert.devAssert)(false, "Must provide name.");
typeof name === "string" || (0, _devAssert.devAssert)(false, "Expected name to be a string.");
if (name.length === 0) {
throw new _GraphQLError.GraphQLError(
"Expected name to be a non-empty string."
);
}
for (let i = 1; i < name.length; ++i) {
if (!(0, _characterClasses.isNameContinue)(name.charCodeAt(i))) {
throw new _GraphQLError.GraphQLError(
`Names must only contain [_a-zA-Z0-9] but "${name}" does not.`
);
}
}
if (!(0, _characterClasses.isNameStart)(name.charCodeAt(0))) {
throw new _GraphQLError.GraphQLError(
`Names must start with [_a-zA-Z] but "${name}" does not.`
);
}
return name;
}
function assertEnumValueName(name) {
if (name === "true" || name === "false" || name === "null") {
throw new _GraphQLError.GraphQLError(
`Enum values cannot be named: ${name}`
);
}
return assertName(name);
}
}
});
// ../../node_modules/graphql/type/definition.js
var require_definition = __commonJS({
"../../node_modules/graphql/type/definition.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLUnionType = exports.GraphQLScalarType = exports.GraphQLObjectType = exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInterfaceType = exports.GraphQLInputObjectType = exports.GraphQLEnumType = void 0;
exports.argsToArgsConfig = argsToArgsConfig;
exports.assertAbstractType = assertAbstractType;
exports.assertCompositeType = assertCompositeType;
exports.assertEnumType = assertEnumType;
exports.assertInputObjectType = assertInputObjectType;
exports.assertInputType = assertInputType;
exports.assertInterfaceType = assertInterfaceType;
exports.assertLeafType = assertLeafType;
exports.assertListType = assertListType;
exports.assertNamedType = assertNamedType;
exports.assertNonNullType = assertNonNullType;
exports.assertNullableType = assertNullableType;
exports.assertObjectType = assertObjectType;
exports.assertOutputType = assertOutputType;
exports.assertScalarType = assertScalarType;
exports.assertType = assertType;
exports.assertUnionType = assertUnionType;
exports.assertWrappingType = assertWrappingType;
exports.defineArguments = defineArguments;
exports.getNamedType = getNamedType;
exports.getNullableType = getNullableType;
exports.isAbstractType = isAbstractType;
exports.isCompositeType = isCompositeType;
exports.isEnumType = isEnumType;
exports.isInputObjectType = isInputObjectType;
exports.isInputType = isInputType;
exports.isInterfaceType = isInterfaceType;
exports.isLeafType = isLeafType;
exports.isListType = isListType;
exports.isNamedType = isNamedType;
exports.isNonNullType = isNonNullType;
exports.isNullableType = isNullableType;
exports.isObjectType = isObjectType;
exports.isOutputType = isOutputType;
exports.isRequiredArgument = isRequiredArgument;
exports.isRequiredInputField = isRequiredInputField;
exports.isScalarType = isScalarType;
exports.isType = isType;
exports.isUnionType = isUnionType;
exports.isWrappingType = isWrappingType;
exports.resolveObjMapThunk = resolveObjMapThunk;
exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk;
var _devAssert = require_devAssert();
var _didYouMean = require_didYouMean();
var _identityFunc = require_identityFunc();
var _inspect = require_inspect();
var _instanceOf = require_instanceOf();
var _isObjectLike = require_isObjectLike();
var _keyMap = require_keyMap();
var _keyValMap = require_keyValMap();
var _mapValue = require_mapValue();
var _suggestionList = require_suggestionList();
var _toObjMap = require_toObjMap();
var _GraphQLError = require_GraphQLError();
var _kinds = require_kinds();
var _printer = require_printer();
var _valueFromASTUntyped = require_valueFromASTUntyped();
var _assertName = require_assertName();
function isType(type) {
return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);
}
function assertType(type) {
if (!isType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL type.`
);
}
return type;
}
function isScalarType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLScalarType);
}
function assertScalarType(type) {
if (!isScalarType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Scalar type.`
);
}
return type;
}
function isObjectType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLObjectType);
}
function assertObjectType(type) {
if (!isObjectType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Object type.`
);
}
return type;
}
function isInterfaceType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLInterfaceType);
}
function assertInterfaceType(type) {
if (!isInterfaceType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Interface type.`
);
}
return type;
}
function isUnionType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLUnionType);
}
function assertUnionType(type) {
if (!isUnionType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Union type.`
);
}
return type;
}
function isEnumType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLEnumType);
}
function assertEnumType(type) {
if (!isEnumType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Enum type.`
);
}
return type;
}
function isInputObjectType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLInputObjectType);
}
function assertInputObjectType(type) {
if (!isInputObjectType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(
type
)} to be a GraphQL Input Object type.`
);
}
return type;
}
function isListType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLList);
}
function assertListType(type) {
if (!isListType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL List type.`
);
}
return type;
}
function isNonNullType(type) {
return (0, _instanceOf.instanceOf)(type, GraphQLNonNull);
}
function assertNonNullType(type) {
if (!isNonNullType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Non-Null type.`
);
}
return type;
}
function isInputType(type) {
return isScalarType(type) || isEnumType(type) || isInputObjectType(type) || isWrappingType(type) && isInputType(type.ofType);
}
function assertInputType(type) {
if (!isInputType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL input type.`
);
}
return type;
}
function isOutputType(type) {
return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isWrappingType(type) && isOutputType(type.ofType);
}
function assertOutputType(type) {
if (!isOutputType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL output type.`
);
}
return type;
}
function isLeafType(type) {
return isScalarType(type) || isEnumType(type);
}
function assertLeafType(type) {
if (!isLeafType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL leaf type.`
);
}
return type;
}
function isCompositeType(type) {
return isObjectType(type) || isInterfaceType(type) || isUnionType(type);
}
function assertCompositeType(type) {
if (!isCompositeType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL composite type.`
);
}
return type;
}
function isAbstractType(type) {
return isInterfaceType(type) || isUnionType(type);
}
function assertAbstractType(type) {
if (!isAbstractType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL abstract type.`
);
}
return type;
}
var GraphQLList = class {
constructor(ofType) {
isType(ofType) || (0, _devAssert.devAssert)(
false,
`Expected ${(0, _inspect.inspect)(ofType)} to be a GraphQL type.`
);
this.ofType = ofType;
}
get [Symbol.toStringTag]() {
return "GraphQLList";
}
toString() {
return "[" + String(this.ofType) + "]";
}
toJSON() {
return this.toString();
}
};
exports.GraphQLList = GraphQLList;
var GraphQLNonNull = class {
constructor(ofType) {
isNullableType(ofType) || (0, _devAssert.devAssert)(
false,
`Expected ${(0, _inspect.inspect)(
ofType
)} to be a GraphQL nullable type.`
);
this.ofType = ofType;
}
get [Symbol.toStringTag]() {
return "GraphQLNonNull";
}
toString() {
return String(this.ofType) + "!";
}
toJSON() {
return this.toString();
}
};
exports.GraphQLNonNull = GraphQLNonNull;
function isWrappingType(type) {
return isListType(type) || isNonNullType(type);
}
function assertWrappingType(type) {
if (!isWrappingType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL wrapping type.`
);
}
return type;
}
function isNullableType(type) {
return isType(type) && !isNonNullType(type);
}
function assertNullableType(type) {
if (!isNullableType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL nullable type.`
);
}
return type;
}
function getNullableType(type) {
if (type) {
return isNonNullType(type) ? type.ofType : type;
}
}
function isNamedType(type) {
return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type);
}
function assertNamedType(type) {
if (!isNamedType(type)) {
throw new Error(
`Expected ${(0, _inspect.inspect)(type)} to be a GraphQL named type.`
);
}
return type;
}
function getNamedType(type) {
if (type) {
let unwrappedType = type;
while (isWrappingType(unwrappedType)) {
unwrappedType = unwrappedType.ofType;
}
return unwrappedType;
}
}
function resolveReadonlyArrayThunk(thunk) {
return typeof thunk === "function" ? thunk() : thunk;
}
function resolveObjMapThunk(thunk) {
return typeof thunk === "function" ? thunk() : thunk;
}
var GraphQLScalarType = class {
constructor(config) {
var _config$parseValue, _config$serialize, _config$parseLiteral, _config$extensionASTN;
const parseValue = (_config$parseValue = config.parseValue) !== null && _config$parseValue !== void 0 ? _config$parseValue : _identityFunc.identityFunc;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.specifiedByURL = config.specifiedByURL;
this.serialize = (_config$serialize = config.serialize) !== null && _config$serialize !== void 0 ? _config$serialize : _identityFunc.identityFunc;
this.parseValue = parseValue;
this.parseLiteral = (_config$parseLiteral = config.parseLiteral) !== null && _config$parseLiteral !== void 0 ? _config$parseLiteral : (node, variables) => parseValue(
(0, _valueFromASTUntyped.valueFromASTUntyped)(node, variables)
);
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN = config.extensionASTNodes) !== null && _config$extensionASTN !== void 0 ? _config$extensionASTN : [];
config.specifiedByURL == null || typeof config.specifiedByURL === "string" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide "specifiedByURL" as a string, but got: ${(0, _inspect.inspect)(config.specifiedByURL)}.`
);
config.serialize == null || typeof config.serialize === "function" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`
);
if (config.parseLiteral) {
typeof config.parseValue === "function" && typeof config.parseLiteral === "function" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide both "parseValue" and "parseLiteral" functions.`
);
}
}
get [Symbol.toStringTag]() {
return "GraphQLScalarType";
}
toConfig() {
return {
name: this.name,
description: this.description,
specifiedByURL: this.specifiedByURL,
serialize: this.serialize,
parseValue: this.parseValue,
parseLiteral: this.parseLiteral,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLScalarType = GraphQLScalarType;
var GraphQLObjectType = class {
constructor(config) {
var _config$extensionASTN2;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.isTypeOf = config.isTypeOf;
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN2 = config.extensionASTNodes) !== null && _config$extensionASTN2 !== void 0 ? _config$extensionASTN2 : [];
this._fields = () => defineFieldMap(config);
this._interfaces = () => defineInterfaces(config);
config.isTypeOf == null || typeof config.isTypeOf === "function" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide "isTypeOf" as a function, but got: ${(0, _inspect.inspect)(config.isTypeOf)}.`
);
}
get [Symbol.toStringTag]() {
return "GraphQLObjectType";
}
getFields() {
if (typeof this._fields === "function") {
this._fields = this._fields();
}
return this._fields;
}
getInterfaces() {
if (typeof this._interfaces === "function") {
this._interfaces = this._interfaces();
}
return this._interfaces;
}
toConfig() {
return {
name: this.name,
description: this.description,
interfaces: this.getInterfaces(),
fields: fieldsToFieldsConfig(this.getFields()),
isTypeOf: this.isTypeOf,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLObjectType = GraphQLObjectType;
function defineInterfaces(config) {
var _config$interfaces;
const interfaces = resolveReadonlyArrayThunk(
(_config$interfaces = config.interfaces) !== null && _config$interfaces !== void 0 ? _config$interfaces : []
);
Array.isArray(interfaces) || (0, _devAssert.devAssert)(
false,
`${config.name} interfaces must be an Array or a function which returns an Array.`
);
return interfaces;
}
function defineFieldMap(config) {
const fieldMap = resolveObjMapThunk(config.fields);
isPlainObj(fieldMap) || (0, _devAssert.devAssert)(
false,
`${config.name} fields must be an object with field names as keys or a function which returns such an object.`
);
return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => {
var _fieldConfig$args;
isPlainObj(fieldConfig) || (0, _devAssert.devAssert)(
false,
`${config.name}.${fieldName} field config must be an object.`
);
fieldConfig.resolve == null || typeof fieldConfig.resolve === "function" || (0, _devAssert.devAssert)(
false,
`${config.name}.${fieldName} field resolver must be a function if provided, but got: ${(0, _inspect.inspect)(fieldConfig.resolve)}.`
);
const argsConfig = (_fieldConfig$args = fieldConfig.args) !== null && _fieldConfig$args !== void 0 ? _fieldConfig$args : {};
isPlainObj(argsConfig) || (0, _devAssert.devAssert)(
false,
`${config.name}.${fieldName} args must be an object with argument names as keys.`
);
return {
name: (0, _assertName.assertName)(fieldName),
description: fieldConfig.description,
type: fieldConfig.type,
args: defineArguments(argsConfig),
resolve: fieldConfig.resolve,
subscribe: fieldConfig.subscribe,
deprecationReason: fieldConfig.deprecationReason,
extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions),
astNode: fieldConfig.astNode
};
});
}
function defineArguments(config) {
return Object.entries(config).map(([argName, argConfig]) => ({
name: (0, _assertName.assertName)(argName),
description: argConfig.description,
type: argConfig.type,
defaultValue: argConfig.defaultValue,
deprecationReason: argConfig.deprecationReason,
extensions: (0, _toObjMap.toObjMap)(argConfig.extensions),
astNode: argConfig.astNode
}));
}
function isPlainObj(obj) {
return (0, _isObjectLike.isObjectLike)(obj) && !Array.isArray(obj);
}
function fieldsToFieldsConfig(fields) {
return (0, _mapValue.mapValue)(fields, (field) => ({
description: field.description,
type: field.type,
args: argsToArgsConfig(field.args),
resolve: field.resolve,
subscribe: field.subscribe,
deprecationReason: field.deprecationReason,
extensions: field.extensions,
astNode: field.astNode
}));
}
function argsToArgsConfig(args) {
return (0, _keyValMap.keyValMap)(
args,
(arg) => arg.name,
(arg) => ({
description: arg.description,
type: arg.type,
defaultValue: arg.defaultValue,
deprecationReason: arg.deprecationReason,
extensions: arg.extensions,
astNode: arg.astNode
})
);
}
function isRequiredArgument(arg) {
return isNonNullType(arg.type) && arg.defaultValue === void 0;
}
var GraphQLInterfaceType = class {
constructor(config) {
var _config$extensionASTN3;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.resolveType = config.resolveType;
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN3 = config.extensionASTNodes) !== null && _config$extensionASTN3 !== void 0 ? _config$extensionASTN3 : [];
this._fields = defineFieldMap.bind(void 0, config);
this._interfaces = defineInterfaces.bind(void 0, config);
config.resolveType == null || typeof config.resolveType === "function" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide "resolveType" as a function, but got: ${(0, _inspect.inspect)(config.resolveType)}.`
);
}
get [Symbol.toStringTag]() {
return "GraphQLInterfaceType";
}
getFields() {
if (typeof this._fields === "function") {
this._fields = this._fields();
}
return this._fields;
}
getInterfaces() {
if (typeof this._interfaces === "function") {
this._interfaces = this._interfaces();
}
return this._interfaces;
}
toConfig() {
return {
name: this.name,
description: this.description,
interfaces: this.getInterfaces(),
fields: fieldsToFieldsConfig(this.getFields()),
resolveType: this.resolveType,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLInterfaceType = GraphQLInterfaceType;
var GraphQLUnionType = class {
constructor(config) {
var _config$extensionASTN4;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.resolveType = config.resolveType;
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN4 = config.extensionASTNodes) !== null && _config$extensionASTN4 !== void 0 ? _config$extensionASTN4 : [];
this._types = defineTypes.bind(void 0, config);
config.resolveType == null || typeof config.resolveType === "function" || (0, _devAssert.devAssert)(
false,
`${this.name} must provide "resolveType" as a function, but got: ${(0, _inspect.inspect)(config.resolveType)}.`
);
}
get [Symbol.toStringTag]() {
return "GraphQLUnionType";
}
getTypes() {
if (typeof this._types === "function") {
this._types = this._types();
}
return this._types;
}
toConfig() {
return {
name: this.name,
description: this.description,
types: this.getTypes(),
resolveType: this.resolveType,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLUnionType = GraphQLUnionType;
function defineTypes(config) {
const types = resolveReadonlyArrayThunk(config.types);
Array.isArray(types) || (0, _devAssert.devAssert)(
false,
`Must provide Array of types or a function which returns such an array for Union ${config.name}.`
);
return types;
}
var GraphQLEnumType = class {
/* <T> */
constructor(config) {
var _config$extensionASTN5;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN5 = config.extensionASTNodes) !== null && _config$extensionASTN5 !== void 0 ? _config$extensionASTN5 : [];
this._values = defineEnumValues(this.name, config.values);
this._valueLookup = new Map(
this._values.map((enumValue) => [enumValue.value, enumValue])
);
this._nameLookup = (0, _keyMap.keyMap)(this._values, (value) => value.name);
}
get [Symbol.toStringTag]() {
return "GraphQLEnumType";
}
getValues() {
return this._values;
}
getValue(name) {
return this._nameLookup[name];
}
serialize(outputValue) {
const enumValue = this._valueLookup.get(outputValue);
if (enumValue === void 0) {
throw new _GraphQLError.GraphQLError(
`Enum "${this.name}" cannot represent value: ${(0, _inspect.inspect)(
outputValue
)}`
);
}
return enumValue.name;
}
parseValue(inputValue) {
if (typeof inputValue !== "string") {
const valueStr = (0, _inspect.inspect)(inputValue);
throw new _GraphQLError.GraphQLError(
`Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr)
);
}
const enumValue = this.getValue(inputValue);
if (enumValue == null) {
throw new _GraphQLError.GraphQLError(
`Value "${inputValue}" does not exist in "${this.name}" enum.` + didYouMeanEnumValue(this, inputValue)
);
}
return enumValue.value;
}
parseLiteral(valueNode, _variables) {
if (valueNode.kind !== _kinds.Kind.ENUM) {
const valueStr = (0, _printer.print)(valueNode);
throw new _GraphQLError.GraphQLError(
`Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + didYouMeanEnumValue(this, valueStr),
{
nodes: valueNode
}
);
}
const enumValue = this.getValue(valueNode.value);
if (enumValue == null) {
const valueStr = (0, _printer.print)(valueNode);
throw new _GraphQLError.GraphQLError(
`Value "${valueStr}" does not exist in "${this.name}" enum.` + didYouMeanEnumValue(this, valueStr),
{
nodes: valueNode
}
);
}
return enumValue.value;
}
toConfig() {
const values = (0, _keyValMap.keyValMap)(
this.getValues(),
(value) => value.name,
(value) => ({
description: value.description,
value: value.value,
deprecationReason: value.deprecationReason,
extensions: value.extensions,
astNode: value.astNode
})
);
return {
name: this.name,
description: this.description,
values,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLEnumType = GraphQLEnumType;
function didYouMeanEnumValue(enumType, unknownValueStr) {
const allNames = enumType.getValues().map((value) => value.name);
const suggestedValues = (0, _suggestionList.suggestionList)(
unknownValueStr,
allNames
);
return (0, _didYouMean.didYouMean)("the enum value", suggestedValues);
}
function defineEnumValues(typeName, valueMap) {
isPlainObj(valueMap) || (0, _devAssert.devAssert)(
false,
`${typeName} values must be an object with value names as keys.`
);
return Object.entries(valueMap).map(([valueName, valueConfig]) => {
isPlainObj(valueConfig) || (0, _devAssert.devAssert)(
false,
`${typeName}.${valueName} must refer to an object with a "value" key representing an internal value but got: ${(0, _inspect.inspect)(
valueConfig
)}.`
);
return {
name: (0, _assertName.assertEnumValueName)(valueName),
description: valueConfig.description,
value: valueConfig.value !== void 0 ? valueConfig.value : valueName,
deprecationReason: valueConfig.deprecationReason,
extensions: (0, _toObjMap.toObjMap)(valueConfig.extensions),
astNode: valueConfig.astNode
};
});
}
var GraphQLInputObjectType = class {
constructor(config) {
var _config$extensionASTN6;
this.name = (0, _assertName.assertName)(config.name);
this.description = config.description;
this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
this.astNode = config.astNode;
this.extensionASTNodes = (_config$extensionASTN6 = config.extensionASTNodes) !== null && _config$extensionASTN6 !== void 0 ? _config$extensionASTN6 : [];
this._fields = defineInputFieldMap.bind(void 0, config);
}
get [Symbol.toStringTag]() {
return "GraphQLInputObjectType";
}
getFields() {
if (typeof this._fields === "function") {
this._fields = this._fields();
}
return this._fields;
}
toConfig() {
const fields = (0, _mapValue.mapValue)(this.getFields(), (field) => ({
description: field.description,
type: field.type,
defaultValue: field.defaultValue,
deprecationReason: field.deprecationReason,
extensions: field.extensions,
astNode: field.astNode
}));
return {
name: this.name,
description: this.description,
fields,
extensions: this.extensions,
astNode: this.astNode,
extensionASTNodes: this.extensionASTNodes
};
}
toString() {
return this.name;
}
toJSON() {
return this.toString();
}
};
exports.GraphQLInputObjectType = GraphQLInputObjectType;
function defineInputFieldMap(config) {
const fieldMap = resolveObjMapThunk(config.fields);
isPlainObj(fieldMap) || (0, _devAssert.devAssert)(
false,
`${config.name} fields must be an object with field names as keys or a function which returns such an object.`
);
return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => {
!("resolve" in fieldConfig) || (0, _devAssert.devAssert)(
false,
`${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`
);
return {
name: (0, _assertName.assertName)(fieldName),
description: fieldConfig.description,
type: fieldConfig.type,
defaultValue: fieldConfig.defaultValue,
deprecationReason: fieldConfig.deprecationReason,
extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions),
astNode: fieldConfig.astNode
};
});
}
function isRequiredInputField(field) {
return isNonNullType(field.type) && field.defaultValue === void 0;
}
}
});
// ../../node_modules/graphql/utilities/typeComparators.js
var require_typeComparators = __commonJS({
"../../node_modules/graphql/utilities/typeComparators.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.doTypesOverlap = doTypesOverlap;
exports.isEqualType = isEqualType;
exports.isTypeSubTypeOf = isTypeSubTypeOf;
var _definition = require_definition();
function isEqualType(typeA, typeB) {
if (typeA === typeB) {
return true;
}
if ((0, _definition.isNonNullType)(typeA) && (0, _definition.isNonNullType)(typeB)) {
return isEqualType(typeA.ofType, typeB.ofType);
}
if ((0, _definition.isListType)(typeA) && (0, _definition.isListType)(typeB)) {
return isEqualType(typeA.ofType, typeB.ofType);
}
return false;
}
function isTypeSubTypeOf(schema, maybeSubType, superType) {
if (maybeSubType === superType) {
return true;
}
if ((0, _definition.isNonNullType)(superType)) {
if ((0, _definition.isNonNullType)(maybeSubType)) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
}
return false;
}
if ((0, _definition.isNonNullType)(maybeSubType)) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
}
if ((0, _definition.isListType)(superType)) {
if ((0, _definition.isListType)(maybeSubType)) {
return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
}
return false;
}
if ((0, _definition.isListType)(maybeSubType)) {
return false;
}
return (0, _definition.isAbstractType)(superType) && ((0, _definition.isInterfaceType)(maybeSubType) || (0, _definition.isObjectType)(maybeSubType)) && schema.isSubType(superType, maybeSubType);
}
function doTypesOverlap(schema, typeA, typeB) {
if (typeA === typeB) {
return true;
}
if ((0, _definition.isAbstractType)(typeA)) {
if ((0, _definition.isAbstractType)(typeB)) {
return schema.getPossibleTypes(typeA).some((type) => schema.isSubType(typeB, type));
}
return schema.isSubType(typeA, typeB);
}
if ((0, _definition.isAbstractType)(typeB)) {
return schema.isSubType(typeB, typeA);
}
return false;
}
}
});
// ../../node_modules/graphql/type/scalars.js
var require_scalars = __commonJS({
"../../node_modules/graphql/type/scalars.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphQLString = exports.GraphQLInt = exports.GraphQLID = exports.GraphQLFloat = exports.GraphQLBoolean = exports.GRAPHQL_MIN_INT = exports.GRAPHQL_MAX_INT = void 0;
exports.isSpecifiedScalarType = isSpecifiedScalarType;
exports.specifiedScalarTypes = void 0;
var _inspect = require_inspect();
var _isObjectLike = require_isObjectLike();
var _GraphQLError = require_GraphQLError();
var _kinds = require_kinds();
var _printer = require_printer();
var _definition = require_definition();
var GRAPHQL_MAX_INT = 2147483647;
exports.GRAPHQL_MAX_INT = GRAPHQL_MAX_INT;
var GRAPHQL_MIN_INT = -2147483648;
exports.GRAPHQL_MIN_INT = GRAPHQL_MIN_INT;
var GraphQLInt = new _definition.GraphQLScalarType({
name: "Int",
description: "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",
serialize(outputValue) {
const coercedValue = serializeObject(outputValue);
if (typeof coercedValue === "boolean") {
return coercedValue ? 1 : 0;
}
let num = coercedValue;
if (typeof coercedValue === "string" && coercedValue !== "") {
num = Number(coercedValue);
}
if (typeof num !== "number" || !Number.isInteger(num)) {
throw new _GraphQLError.GraphQLError(
`Int cannot represent non-integer value: ${(0, _inspect.inspect)(
coercedValue
)}`
);
}
if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {
throw new _GraphQLError.GraphQLError(
"Int cannot represent non 32-bit signed integer value: " + (0, _inspect.inspect)(coercedValue)
);
}
return num;
},
parseValue(inputValue) {
if (typeof inputValue !== "number" || !Number.isInteger(inputValue)) {
throw new _GraphQLError.GraphQLError(
`Int cannot represent non-integer value: ${(0, _inspect.inspect)(
inputValue
)}`
);
}
if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) {
throw new _GraphQLError.GraphQLError(
`Int cannot represent non 32-bit signed integer value: ${inputValue}`
);
}
return inputValue;
},
parseLiteral(valueNode) {
if (valueNode.kind !== _kinds.Kind.INT) {
throw new _GraphQLError.GraphQLError(
`Int cannot represent non-integer value: ${(0, _printer.print)(
valueNode
)}`,
{
nodes: valueNode
}
);
}
const num = parseInt(valueNode.value, 10);
if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) {
throw new _GraphQLError.GraphQLError(
`Int cannot represent non 32-bit signed integer value: ${valueNode.value}`,
{
nodes: valueNode
}
);
}
return num;
}
});
exports.GraphQLInt = GraphQLInt;
var GraphQLFloat = new _definition.GraphQLScalarType({
name: "Float",
description: "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",
serialize(outputValue) {
const coercedValue = serializeObject(outputValue);
if (typeof coercedValue === "boolean") {
return coercedValue ? 1 : 0;
}
let num = coercedValue;
if (typeof coercedValue === "string" && coercedValue !== "") {
num = Number(coercedValue);
}
if (typeof num !== "number" || !Number.isFinit