@miragejs/graphql
Version:
A library for handling GraphQL requests with Mirage JS
1,756 lines (1,751 loc) • 544 kB
JavaScript
function Te(e, t) {
if (!!!e)
throw new Error(t);
}
function Lr(e) {
return typeof (e == null ? void 0 : e.then) == "function";
}
function jr(e) {
return typeof e == "object" && e !== null;
}
function or(e, t) {
if (!!!e)
throw new Error(
t ?? "Unexpected invariant triggered."
);
}
const ad = /\r\n|[\n\r]/g;
function Ua(e, t) {
let n = 0, r = 1;
for (const i of e.body.matchAll(ad)) {
if (typeof i.index == "number" || or(!1), i.index >= t)
break;
n = i.index + i[0].length, r += 1;
}
return {
line: r,
column: t + 1 - n
};
}
function od(e) {
return mc(
e.source,
Ua(e.source, e.start)
);
}
function mc(e, t) {
const n = e.locationOffset.column - 1, r = "".padStart(n) + e.body, i = t.line - 1, s = e.locationOffset.line - 1, a = t.line + s, o = t.line === 1 ? n : 0, c = t.column + o, h = `${e.name}:${a}:${c}
`, v = r.split(/\r\n|[\n\r]/g), p = v[i];
if (p.length > 120) {
const b = Math.floor(c / 80), w = c % 80, $ = [];
for (let z = 0; z < p.length; z += 80)
$.push(p.slice(z, z + 80));
return h + au([
[`${a} |`, $[0]],
...$.slice(1, b + 1).map((z) => ["|", z]),
["|", "^".padStart(w)],
["|", $[b + 1]]
]);
}
return h + au([
// Lines specified like this: ["prefix", "string"],
[`${a - 1} |`, v[i - 1]],
[`${a} |`, p],
["|", "^".padStart(c)],
[`${a + 1} |`, v[i + 1]]
]);
}
function au(e) {
const t = e.filter(([r, i]) => i !== void 0), n = Math.max(...t.map(([r]) => r.length));
return t.map(([r, i]) => r.padStart(n) + (i ? " " + i : "")).join(`
`);
}
function ud(e) {
const t = e[0];
return t == null || "kind" in t || "length" in t ? {
nodes: t,
source: e[1],
positions: e[2],
path: e[3],
originalError: e[4],
extensions: e[5]
} : t;
}
class M extends Error {
/**
* An array of `{ line, column }` locations within the source GraphQL document
* which correspond to this error.
*
* Errors during validation often contain multiple locations, for example to
* point out two things with the same name. Errors during execution include a
* single location, the field which produced the error.
*
* Enumerable, and appears in the result of JSON.stringify().
*/
/**
* An array describing the JSON-path into the execution response which
* corresponds to this error. Only included for errors during execution.
*
* Enumerable, and appears in the result of JSON.stringify().
*/
/**
* An array of GraphQL AST Nodes corresponding to this error.
*/
/**
* The source GraphQL document for the first location of this error.
*
* Note that if this Error represents more than one node, the source may not
* represent nodes after the first node.
*/
/**
* An array of character offsets within the source GraphQL document
* which correspond to this error.
*/
/**
* The original error thrown from a field resolver during execution.
*/
/**
* Extension fields to add to the formatted error.
*/
/**
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
*/
constructor(t, ...n) {
var r, i, s;
const { nodes: a, source: o, positions: c, path: h, originalError: v, extensions: p } = ud(n);
super(t), this.name = "GraphQLError", this.path = h ?? void 0, this.originalError = v ?? void 0, this.nodes = ou(
Array.isArray(a) ? a : a ? [a] : void 0
);
const b = ou(
(r = this.nodes) === null || r === void 0 ? void 0 : r.map(($) => $.loc).filter(($) => $ != null)
);
this.source = o ?? (b == null || (i = b[0]) === null || i === void 0 ? void 0 : i.source), this.positions = c ?? (b == null ? void 0 : b.map(($) => $.start)), this.locations = c && o ? c.map(($) => Ua(o, $)) : b == null ? void 0 : b.map(($) => Ua($.source, $.start));
const w = jr(
v == null ? void 0 : v.extensions
) ? v == null ? void 0 : v.extensions : void 0;
this.extensions = (s = p ?? w) !== null && s !== void 0 ? s : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
message: {
writable: !0,
enumerable: !0
},
name: {
enumerable: !1
},
nodes: {
enumerable: !1
},
source: {
enumerable: !1
},
positions: {
enumerable: !1
},
originalError: {
enumerable: !1
}
}), v != null && v.stack ? Object.defineProperty(this, "stack", {
value: v.stack,
writable: !0,
configurable: !0
}) : Error.captureStackTrace ? Error.captureStackTrace(this, M) : Object.defineProperty(this, "stack", {
value: Error().stack,
writable: !0,
configurable: !0
});
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
toString() {
let t = this.message;
if (this.nodes)
for (const n of this.nodes)
n.loc && (t += `
` + od(n.loc));
else if (this.source && this.locations)
for (const n of this.locations)
t += `
` + mc(this.source, n);
return t;
}
toJSON() {
const t = {
message: this.message
};
return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t;
}
}
function ou(e) {
return e === void 0 || e.length === 0 ? void 0 : e;
}
function sn(e, t, n) {
return new M(`Syntax Error: ${n}`, {
source: e,
positions: [t]
});
}
class cd {
/**
* The character offset at which this Node begins.
*/
/**
* The character offset at which this Node ends.
*/
/**
* The Token at which this Node begins.
*/
/**
* The Token at which this Node ends.
*/
/**
* The Source document the AST represents.
*/
constructor(t, n, r) {
this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = r;
}
get [Symbol.toStringTag]() {
return "Location";
}
toJSON() {
return {
start: this.start,
end: this.end
};
}
}
class vc {
/**
* The kind of Token.
*/
/**
* The character offset at which this Node begins.
*/
/**
* The character offset at which this Node ends.
*/
/**
* The 1-indexed line number on which this Token appears.
*/
/**
* The 1-indexed column number at which this Token begins.
*/
/**
* For non-punctuation tokens, represents the interpreted value of the token.
*
* Note: is undefined for punctuation tokens, but typed as string for
* convenience in the parser.
*/
/**
* Tokens exist as nodes in a double-linked-list amongst all tokens
* including ignored tokens. <SOF> is always the first node and <EOF>
* the last.
*/
constructor(t, n, r, i, s, a) {
this.kind = t, this.start = n, this.end = r, this.line = i, this.column = s, this.value = a, this.prev = null, this.next = null;
}
get [Symbol.toStringTag]() {
return "Token";
}
toJSON() {
return {
kind: this.kind,
value: this.value,
line: this.line,
column: this.column
};
}
}
const _c = {
Name: [],
Document: ["definitions"],
OperationDefinition: [
"name",
"variableDefinitions",
"directives",
"selectionSet"
],
VariableDefinition: ["variable", "type", "defaultValue", "directives"],
Variable: ["name"],
SelectionSet: ["selections"],
Field: ["alias", "name", "arguments", "directives", "selectionSet"],
Argument: ["name", "value"],
FragmentSpread: ["name", "directives"],
InlineFragment: ["typeCondition", "directives", "selectionSet"],
FragmentDefinition: [
"name",
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
"variableDefinitions",
"typeCondition",
"directives",
"selectionSet"
],
IntValue: [],
FloatValue: [],
StringValue: [],
BooleanValue: [],
NullValue: [],
EnumValue: [],
ListValue: ["values"],
ObjectValue: ["fields"],
ObjectField: ["name", "value"],
Directive: ["name", "arguments"],
NamedType: ["name"],
ListType: ["type"],
NonNullType: ["type"],
SchemaDefinition: ["description", "directives", "operationTypes"],
OperationTypeDefinition: ["type"],
ScalarTypeDefinition: ["description", "name", "directives"],
ObjectTypeDefinition: [
"description",
"name",
"interfaces",
"directives",
"fields"
],
FieldDefinition: ["description", "name", "arguments", "type", "directives"],
InputValueDefinition: [
"description",
"name",
"type",
"defaultValue",
"directives"
],
InterfaceTypeDefinition: [
"description",
"name",
"interfaces",
"directives",
"fields"
],
UnionTypeDefinition: ["description", "name", "directives", "types"],
EnumTypeDefinition: ["description", "name", "directives", "values"],
EnumValueDefinition: ["description", "name", "directives"],
InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
DirectiveDefinition: ["description", "name", "arguments", "locations"],
SchemaExtension: ["directives", "operationTypes"],
ScalarTypeExtension: ["name", "directives"],
ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
UnionTypeExtension: ["name", "directives", "types"],
EnumTypeExtension: ["name", "directives", "values"],
InputObjectTypeExtension: ["name", "directives", "fields"]
}, ld = new Set(Object.keys(_c));
function Ba(e) {
const t = e == null ? void 0 : e.kind;
return typeof t == "string" && ld.has(t);
}
var an;
(function(e) {
e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
})(an || (an = {}));
var re;
(function(e) {
e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
})(re || (re = {}));
var N;
(function(e) {
e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
})(N || (N = {}));
function Ga(e) {
return e === 9 || e === 32;
}
function Ki(e) {
return e >= 48 && e <= 57;
}
function Tc(e) {
return e >= 97 && e <= 122 || // A-Z
e >= 65 && e <= 90;
}
function oo(e) {
return Tc(e) || e === 95;
}
function bc(e) {
return Tc(e) || Ki(e) || e === 95;
}
function fd(e) {
var t;
let n = Number.MAX_SAFE_INTEGER, r = null, i = -1;
for (let a = 0; a < e.length; ++a) {
var s;
const o = e[a], c = dd(o);
c !== o.length && (r = (s = r) !== null && s !== void 0 ? s : a, i = a, a !== 0 && c < n && (n = c));
}
return e.map((a, o) => o === 0 ? a : a.slice(n)).slice(
(t = r) !== null && t !== void 0 ? t : 0,
i + 1
);
}
function dd(e) {
let t = 0;
for (; t < e.length && Ga(e.charCodeAt(t)); )
++t;
return t;
}
function hd(e, t) {
const n = e.replace(/"""/g, '\\"""'), r = n.split(/\r\n|[\n\r]/g), i = r.length === 1, s = r.length > 1 && r.slice(1).every((w) => w.length === 0 || Ga(w.charCodeAt(0))), a = n.endsWith('\\"""'), o = e.endsWith('"') && !a, c = e.endsWith("\\"), h = o || c, v = !(t != null && t.minimize) && // add leading and trailing new lines only if it improves readability
(!i || e.length > 70 || h || s || a);
let p = "";
const b = i && Ga(e.charCodeAt(0));
return (v && !b || s) && (p += `
`), p += n, (v || h) && (p += `
`), '"""' + p + '"""';
}
var L;
(function(e) {
e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
})(L || (L = {}));
class pd {
/**
* The previously focused non-ignored token.
*/
/**
* The currently focused non-ignored token.
*/
/**
* The (1-indexed) line containing the current token.
*/
/**
* The character offset at which the current line begins.
*/
constructor(t) {
const n = new vc(L.SOF, 0, 0, 0, 0);
this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
}
get [Symbol.toStringTag]() {
return "Lexer";
}
/**
* Advances the token stream to the next non-ignored token.
*/
advance() {
return this.lastToken = this.token, this.token = this.lookahead();
}
/**
* Looks ahead and returns the next non-ignored token, but does not change
* the state of Lexer.
*/
lookahead() {
let t = this.token;
if (t.kind !== L.EOF)
do
if (t.next)
t = t.next;
else {
const n = gd(this, t.end);
t.next = n, n.prev = t, t = n;
}
while (t.kind === L.COMMENT);
return t;
}
}
function yd(e) {
return e === L.BANG || e === L.DOLLAR || e === L.AMP || e === L.PAREN_L || e === L.PAREN_R || e === L.SPREAD || e === L.COLON || e === L.EQUALS || e === L.AT || e === L.BRACKET_L || e === L.BRACKET_R || e === L.BRACE_L || e === L.PIPE || e === L.BRACE_R;
}
function Pi(e) {
return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
}
function Ys(e, t) {
return Ec(e.charCodeAt(t)) && Ic(e.charCodeAt(t + 1));
}
function Ec(e) {
return e >= 55296 && e <= 56319;
}
function Ic(e) {
return e >= 56320 && e <= 57343;
}
function gi(e, t) {
const n = e.source.body.codePointAt(t);
if (n === void 0)
return L.EOF;
if (n >= 32 && n <= 126) {
const r = String.fromCodePoint(n);
return r === '"' ? `'"'` : `"${r}"`;
}
return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
}
function Mt(e, t, n, r, i) {
const s = e.line, a = 1 + n - e.lineStart;
return new vc(t, n, r, s, a, i);
}
function gd(e, t) {
const n = e.source.body, r = n.length;
let i = t;
for (; i < r; ) {
const s = n.charCodeAt(i);
switch (s) {
case 65279:
case 9:
case 32:
case 44:
++i;
continue;
case 10:
++i, ++e.line, e.lineStart = i;
continue;
case 13:
n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
continue;
case 35:
return md(e, i);
case 33:
return Mt(e, L.BANG, i, i + 1);
case 36:
return Mt(e, L.DOLLAR, i, i + 1);
case 38:
return Mt(e, L.AMP, i, i + 1);
case 40:
return Mt(e, L.PAREN_L, i, i + 1);
case 41:
return Mt(e, L.PAREN_R, i, i + 1);
case 46:
if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
return Mt(e, L.SPREAD, i, i + 3);
break;
case 58:
return Mt(e, L.COLON, i, i + 1);
case 61:
return Mt(e, L.EQUALS, i, i + 1);
case 64:
return Mt(e, L.AT, i, i + 1);
case 91:
return Mt(e, L.BRACKET_L, i, i + 1);
case 93:
return Mt(e, L.BRACKET_R, i, i + 1);
case 123:
return Mt(e, L.BRACE_L, i, i + 1);
case 124:
return Mt(e, L.PIPE, i, i + 1);
case 125:
return Mt(e, L.BRACE_R, i, i + 1);
case 34:
return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? Id(e, i) : _d(e, i);
}
if (Ki(s) || s === 45)
return vd(e, i, s);
if (oo(s))
return Nd(e, i);
throw sn(
e.source,
i,
s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : Pi(s) || Ys(n, i) ? `Unexpected character: ${gi(e, i)}.` : `Invalid character: ${gi(e, i)}.`
);
}
return Mt(e, L.EOF, r, r);
}
function md(e, t) {
const n = e.source.body, r = n.length;
let i = t + 1;
for (; i < r; ) {
const s = n.charCodeAt(i);
if (s === 10 || s === 13)
break;
if (Pi(s))
++i;
else if (Ys(n, i))
i += 2;
else
break;
}
return Mt(
e,
L.COMMENT,
t,
i,
n.slice(t + 1, i)
);
}
function vd(e, t, n) {
const r = e.source.body;
let i = t, s = n, a = !1;
if (s === 45 && (s = r.charCodeAt(++i)), s === 48) {
if (s = r.charCodeAt(++i), Ki(s))
throw sn(
e.source,
i,
`Invalid number, unexpected digit after 0: ${gi(
e,
i
)}.`
);
} else
i = ga(e, i, s), s = r.charCodeAt(i);
if (s === 46 && (a = !0, s = r.charCodeAt(++i), i = ga(e, i, s), s = r.charCodeAt(i)), (s === 69 || s === 101) && (a = !0, s = r.charCodeAt(++i), (s === 43 || s === 45) && (s = r.charCodeAt(++i)), i = ga(e, i, s), s = r.charCodeAt(i)), s === 46 || oo(s))
throw sn(
e.source,
i,
`Invalid number, expected digit but got: ${gi(
e,
i
)}.`
);
return Mt(
e,
a ? L.FLOAT : L.INT,
t,
i,
r.slice(t, i)
);
}
function ga(e, t, n) {
if (!Ki(n))
throw sn(
e.source,
t,
`Invalid number, expected digit but got: ${gi(
e,
t
)}.`
);
const r = e.source.body;
let i = t + 1;
for (; Ki(r.charCodeAt(i)); )
++i;
return i;
}
function _d(e, t) {
const n = e.source.body, r = n.length;
let i = t + 1, s = i, a = "";
for (; i < r; ) {
const o = n.charCodeAt(i);
if (o === 34)
return a += n.slice(s, i), Mt(e, L.STRING, t, i + 1, a);
if (o === 92) {
a += n.slice(s, i);
const c = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? Td(e, i) : bd(e, i) : Ed(e, i);
a += c.value, i += c.size, s = i;
continue;
}
if (o === 10 || o === 13)
break;
if (Pi(o))
++i;
else if (Ys(n, i))
i += 2;
else
throw sn(
e.source,
i,
`Invalid character within String: ${gi(
e,
i
)}.`
);
}
throw sn(e.source, i, "Unterminated string.");
}
function Td(e, t) {
const n = e.source.body;
let r = 0, i = 3;
for (; i < 12; ) {
const s = n.charCodeAt(t + i++);
if (s === 125) {
if (i < 5 || !Pi(r))
break;
return {
value: String.fromCodePoint(r),
size: i
};
}
if (r = r << 4 | Bi(s), r < 0)
break;
}
throw sn(
e.source,
t,
`Invalid Unicode escape sequence: "${n.slice(
t,
t + i
)}".`
);
}
function bd(e, t) {
const n = e.source.body, r = uu(n, t + 2);
if (Pi(r))
return {
value: String.fromCodePoint(r),
size: 6
};
if (Ec(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
const i = uu(n, t + 8);
if (Ic(i))
return {
value: String.fromCodePoint(r, i),
size: 12
};
}
throw sn(
e.source,
t,
`Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
);
}
function uu(e, t) {
return Bi(e.charCodeAt(t)) << 12 | Bi(e.charCodeAt(t + 1)) << 8 | Bi(e.charCodeAt(t + 2)) << 4 | Bi(e.charCodeAt(t + 3));
}
function Bi(e) {
return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
}
function Ed(e, t) {
const n = e.source.body;
switch (n.charCodeAt(t + 1)) {
case 34:
return {
value: '"',
size: 2
};
case 92:
return {
value: "\\",
size: 2
};
case 47:
return {
value: "/",
size: 2
};
case 98:
return {
value: "\b",
size: 2
};
case 102:
return {
value: "\f",
size: 2
};
case 110:
return {
value: `
`,
size: 2
};
case 114:
return {
value: "\r",
size: 2
};
case 116:
return {
value: " ",
size: 2
};
}
throw sn(
e.source,
t,
`Invalid character escape sequence: "${n.slice(
t,
t + 2
)}".`
);
}
function Id(e, t) {
const n = e.source.body, r = n.length;
let i = e.lineStart, s = t + 3, a = s, o = "";
const c = [];
for (; s < r; ) {
const h = n.charCodeAt(s);
if (h === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) {
o += n.slice(a, s), c.push(o);
const v = Mt(
e,
L.BLOCK_STRING,
t,
s + 3,
// Return a string of the lines joined with U+000A.
fd(c).join(`
`)
);
return e.line += c.length - 1, e.lineStart = i, v;
}
if (h === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) {
o += n.slice(a, s), a = s + 1, s += 4;
continue;
}
if (h === 10 || h === 13) {
o += n.slice(a, s), c.push(o), h === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, o = "", a = s, i = s;
continue;
}
if (Pi(h))
++s;
else if (Ys(n, s))
s += 2;
else
throw sn(
e.source,
s,
`Invalid character within String: ${gi(
e,
s
)}.`
);
}
throw sn(e.source, s, "Unterminated string.");
}
function Nd(e, t) {
const n = e.source.body, r = n.length;
let i = t + 1;
for (; i < r; ) {
const s = n.charCodeAt(i);
if (bc(s))
++i;
else
break;
}
return Mt(
e,
L.NAME,
t,
i,
n.slice(t, i)
);
}
const Ad = 10, Nc = 2;
function K(e) {
return Js(e, []);
}
function Js(e, t) {
switch (typeof e) {
case "string":
return JSON.stringify(e);
case "function":
return e.name ? `[function ${e.name}]` : "[function]";
case "object":
return Sd(e, t);
default:
return String(e);
}
}
function Sd(e, t) {
if (e === null)
return "null";
if (t.includes(e))
return "[Circular]";
const n = [...t, e];
if (Od(e)) {
const r = e.toJSON();
if (r !== e)
return typeof r == "string" ? r : Js(r, n);
} else if (Array.isArray(e))
return Rd(e, n);
return wd(e, n);
}
function Od(e) {
return typeof e.toJSON == "function";
}
function wd(e, t) {
const n = Object.entries(e);
return n.length === 0 ? "{}" : t.length > Nc ? "[" + Fd(e) + "]" : "{ " + n.map(
([i, s]) => i + ": " + Js(s, t)
).join(", ") + " }";
}
function Rd(e, t) {
if (e.length === 0)
return "[]";
if (t.length > Nc)
return "[Array]";
const n = Math.min(Ad, e.length), r = e.length - n, i = [];
for (let s = 0; s < n; ++s)
i.push(Js(e[s], t));
return r === 1 ? i.push("... 1 more item") : r > 1 && i.push(`... ${r} more items`), "[" + i.join(", ") + "]";
}
function Fd(e) {
const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
if (t === "Object" && typeof e.constructor == "function") {
const n = e.constructor.name;
if (typeof n == "string" && n !== "")
return n;
}
return t;
}
const kr = (
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(t, n) {
return t instanceof n;
} : function(t, n) {
if (t instanceof n)
return !0;
if (typeof t == "object" && t !== null) {
var r;
const i = n.prototype[Symbol.toStringTag], s = (
// We still need to support constructor's name to detect conflicts with older versions of this library.
Symbol.toStringTag in t ? t[Symbol.toStringTag] : (r = t.constructor) === null || r === void 0 ? void 0 : r.name
);
if (i === s) {
const a = K(t);
throw new Error(`Cannot use ${i} "${a}" 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 !1;
}
);
class Ac {
constructor(t, n = "GraphQL request", r = {
line: 1,
column: 1
}) {
typeof t == "string" || Te(!1, `Body must be a string. Received: ${K(t)}.`), this.body = t, this.name = n, this.locationOffset = r, this.locationOffset.line > 0 || Te(
!1,
"line in locationOffset is 1-indexed and must be positive."
), this.locationOffset.column > 0 || Te(
!1,
"column in locationOffset is 1-indexed and must be positive."
);
}
get [Symbol.toStringTag]() {
return "Source";
}
}
function $d(e) {
return kr(e, Ac);
}
function Sc(e, t) {
return new Cd(e, t).parseDocument();
}
class Cd {
constructor(t, n = {}) {
const r = $d(t) ? t : new Ac(t);
this._lexer = new pd(r), this._options = n, this._tokenCounter = 0;
}
/**
* Converts a name lex token into a name parse node.
*/
parseName() {
const t = this.expectToken(L.NAME);
return this.node(t, {
kind: N.NAME,
value: t.value
});
}
// Implements the parsing rules in the Document section.
/**
* Document : Definition+
*/
parseDocument() {
return this.node(this._lexer.token, {
kind: N.DOCUMENT,
definitions: this.many(
L.SOF,
this.parseDefinition,
L.EOF
)
});
}
/**
* Definition :
* - ExecutableDefinition
* - TypeSystemDefinition
* - TypeSystemExtension
*
* ExecutableDefinition :
* - OperationDefinition
* - FragmentDefinition
*
* TypeSystemDefinition :
* - SchemaDefinition
* - TypeDefinition
* - DirectiveDefinition
*
* TypeDefinition :
* - ScalarTypeDefinition
* - ObjectTypeDefinition
* - InterfaceTypeDefinition
* - UnionTypeDefinition
* - EnumTypeDefinition
* - InputObjectTypeDefinition
*/
parseDefinition() {
if (this.peek(L.BRACE_L))
return this.parseOperationDefinition();
const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
if (n.kind === L.NAME) {
switch (n.value) {
case "schema":
return this.parseSchemaDefinition();
case "scalar":
return this.parseScalarTypeDefinition();
case "type":
return this.parseObjectTypeDefinition();
case "interface":
return this.parseInterfaceTypeDefinition();
case "union":
return this.parseUnionTypeDefinition();
case "enum":
return this.parseEnumTypeDefinition();
case "input":
return this.parseInputObjectTypeDefinition();
case "directive":
return this.parseDirectiveDefinition();
}
if (t)
throw sn(
this._lexer.source,
this._lexer.token.start,
"Unexpected description, descriptions are supported only on type definitions."
);
switch (n.value) {
case "query":
case "mutation":
case "subscription":
return this.parseOperationDefinition();
case "fragment":
return this.parseFragmentDefinition();
case "extend":
return this.parseTypeSystemExtension();
}
}
throw this.unexpected(n);
}
// Implements the parsing rules in the Operations section.
/**
* OperationDefinition :
* - SelectionSet
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
*/
parseOperationDefinition() {
const t = this._lexer.token;
if (this.peek(L.BRACE_L))
return this.node(t, {
kind: N.OPERATION_DEFINITION,
operation: an.QUERY,
name: void 0,
variableDefinitions: [],
directives: [],
selectionSet: this.parseSelectionSet()
});
const n = this.parseOperationType();
let r;
return this.peek(L.NAME) && (r = this.parseName()), this.node(t, {
kind: N.OPERATION_DEFINITION,
operation: n,
name: r,
variableDefinitions: this.parseVariableDefinitions(),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* OperationType : one of query mutation subscription
*/
parseOperationType() {
const t = this.expectToken(L.NAME);
switch (t.value) {
case "query":
return an.QUERY;
case "mutation":
return an.MUTATION;
case "subscription":
return an.SUBSCRIPTION;
}
throw this.unexpected(t);
}
/**
* VariableDefinitions : ( VariableDefinition+ )
*/
parseVariableDefinitions() {
return this.optionalMany(
L.PAREN_L,
this.parseVariableDefinition,
L.PAREN_R
);
}
/**
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
*/
parseVariableDefinition() {
return this.node(this._lexer.token, {
kind: N.VARIABLE_DEFINITION,
variable: this.parseVariable(),
type: (this.expectToken(L.COLON), this.parseTypeReference()),
defaultValue: this.expectOptionalToken(L.EQUALS) ? this.parseConstValueLiteral() : void 0,
directives: this.parseConstDirectives()
});
}
/**
* Variable : $ Name
*/
parseVariable() {
const t = this._lexer.token;
return this.expectToken(L.DOLLAR), this.node(t, {
kind: N.VARIABLE,
name: this.parseName()
});
}
/**
* ```
* SelectionSet : { Selection+ }
* ```
*/
parseSelectionSet() {
return this.node(this._lexer.token, {
kind: N.SELECTION_SET,
selections: this.many(
L.BRACE_L,
this.parseSelection,
L.BRACE_R
)
});
}
/**
* Selection :
* - Field
* - FragmentSpread
* - InlineFragment
*/
parseSelection() {
return this.peek(L.SPREAD) ? this.parseFragment() : this.parseField();
}
/**
* Field : Alias? Name Arguments? Directives? SelectionSet?
*
* Alias : Name :
*/
parseField() {
const t = this._lexer.token, n = this.parseName();
let r, i;
return this.expectOptionalToken(L.COLON) ? (r = n, i = this.parseName()) : i = n, this.node(t, {
kind: N.FIELD,
alias: r,
name: i,
arguments: this.parseArguments(!1),
directives: this.parseDirectives(!1),
selectionSet: this.peek(L.BRACE_L) ? this.parseSelectionSet() : void 0
});
}
/**
* Arguments[Const] : ( Argument[?Const]+ )
*/
parseArguments(t) {
const n = t ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(L.PAREN_L, n, L.PAREN_R);
}
/**
* Argument[Const] : Name : Value[?Const]
*/
parseArgument(t = !1) {
const n = this._lexer.token, r = this.parseName();
return this.expectToken(L.COLON), this.node(n, {
kind: N.ARGUMENT,
name: r,
value: this.parseValueLiteral(t)
});
}
parseConstArgument() {
return this.parseArgument(!0);
}
// Implements the parsing rules in the Fragments section.
/**
* Corresponds to both FragmentSpread and InlineFragment in the spec.
*
* FragmentSpread : ... FragmentName Directives?
*
* InlineFragment : ... TypeCondition? Directives? SelectionSet
*/
parseFragment() {
const t = this._lexer.token;
this.expectToken(L.SPREAD);
const n = this.expectOptionalKeyword("on");
return !n && this.peek(L.NAME) ? this.node(t, {
kind: N.FRAGMENT_SPREAD,
name: this.parseFragmentName(),
directives: this.parseDirectives(!1)
}) : this.node(t, {
kind: N.INLINE_FRAGMENT,
typeCondition: n ? this.parseNamedType() : void 0,
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* FragmentDefinition :
* - fragment FragmentName on TypeCondition Directives? SelectionSet
*
* TypeCondition : NamedType
*/
parseFragmentDefinition() {
const t = this._lexer.token;
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
kind: N.FRAGMENT_DEFINITION,
name: this.parseFragmentName(),
variableDefinitions: this.parseVariableDefinitions(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
}) : this.node(t, {
kind: N.FRAGMENT_DEFINITION,
name: this.parseFragmentName(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* FragmentName : Name but not `on`
*/
parseFragmentName() {
if (this._lexer.token.value === "on")
throw this.unexpected();
return this.parseName();
}
// Implements the parsing rules in the Values section.
/**
* Value[Const] :
* - [~Const] Variable
* - IntValue
* - FloatValue
* - StringValue
* - BooleanValue
* - NullValue
* - EnumValue
* - ListValue[?Const]
* - ObjectValue[?Const]
*
* BooleanValue : one of `true` `false`
*
* NullValue : `null`
*
* EnumValue : Name but not `true`, `false` or `null`
*/
parseValueLiteral(t) {
const n = this._lexer.token;
switch (n.kind) {
case L.BRACKET_L:
return this.parseList(t);
case L.BRACE_L:
return this.parseObject(t);
case L.INT:
return this.advanceLexer(), this.node(n, {
kind: N.INT,
value: n.value
});
case L.FLOAT:
return this.advanceLexer(), this.node(n, {
kind: N.FLOAT,
value: n.value
});
case L.STRING:
case L.BLOCK_STRING:
return this.parseStringLiteral();
case L.NAME:
switch (this.advanceLexer(), n.value) {
case "true":
return this.node(n, {
kind: N.BOOLEAN,
value: !0
});
case "false":
return this.node(n, {
kind: N.BOOLEAN,
value: !1
});
case "null":
return this.node(n, {
kind: N.NULL
});
default:
return this.node(n, {
kind: N.ENUM,
value: n.value
});
}
case L.DOLLAR:
if (t)
if (this.expectToken(L.DOLLAR), this._lexer.token.kind === L.NAME) {
const r = this._lexer.token.value;
throw sn(
this._lexer.source,
n.start,
`Unexpected variable "$${r}" in constant value.`
);
} else
throw this.unexpected(n);
return this.parseVariable();
default:
throw this.unexpected();
}
}
parseConstValueLiteral() {
return this.parseValueLiteral(!0);
}
parseStringLiteral() {
const t = this._lexer.token;
return this.advanceLexer(), this.node(t, {
kind: N.STRING,
value: t.value,
block: t.kind === L.BLOCK_STRING
});
}
/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
parseList(t) {
const n = () => this.parseValueLiteral(t);
return this.node(this._lexer.token, {
kind: N.LIST,
values: this.any(L.BRACKET_L, n, L.BRACKET_R)
});
}
/**
* ```
* ObjectValue[Const] :
* - { }
* - { ObjectField[?Const]+ }
* ```
*/
parseObject(t) {
const n = () => this.parseObjectField(t);
return this.node(this._lexer.token, {
kind: N.OBJECT,
fields: this.any(L.BRACE_L, n, L.BRACE_R)
});
}
/**
* ObjectField[Const] : Name : Value[?Const]
*/
parseObjectField(t) {
const n = this._lexer.token, r = this.parseName();
return this.expectToken(L.COLON), this.node(n, {
kind: N.OBJECT_FIELD,
name: r,
value: this.parseValueLiteral(t)
});
}
// Implements the parsing rules in the Directives section.
/**
* Directives[Const] : Directive[?Const]+
*/
parseDirectives(t) {
const n = [];
for (; this.peek(L.AT); )
n.push(this.parseDirective(t));
return n;
}
parseConstDirectives() {
return this.parseDirectives(!0);
}
/**
* ```
* Directive[Const] : @ Name Arguments[?Const]?
* ```
*/
parseDirective(t) {
const n = this._lexer.token;
return this.expectToken(L.AT), this.node(n, {
kind: N.DIRECTIVE,
name: this.parseName(),
arguments: this.parseArguments(t)
});
}
// Implements the parsing rules in the Types section.
/**
* Type :
* - NamedType
* - ListType
* - NonNullType
*/
parseTypeReference() {
const t = this._lexer.token;
let n;
if (this.expectOptionalToken(L.BRACKET_L)) {
const r = this.parseTypeReference();
this.expectToken(L.BRACKET_R), n = this.node(t, {
kind: N.LIST_TYPE,
type: r
});
} else
n = this.parseNamedType();
return this.expectOptionalToken(L.BANG) ? this.node(t, {
kind: N.NON_NULL_TYPE,
type: n
}) : n;
}
/**
* NamedType : Name
*/
parseNamedType() {
return this.node(this._lexer.token, {
kind: N.NAMED_TYPE,
name: this.parseName()
});
}
// Implements the parsing rules in the Type Definition section.
peekDescription() {
return this.peek(L.STRING) || this.peek(L.BLOCK_STRING);
}
/**
* Description : StringValue
*/
parseDescription() {
if (this.peekDescription())
return this.parseStringLiteral();
}
/**
* ```
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
* ```
*/
parseSchemaDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("schema");
const r = this.parseConstDirectives(), i = this.many(
L.BRACE_L,
this.parseOperationTypeDefinition,
L.BRACE_R
);
return this.node(t, {
kind: N.SCHEMA_DEFINITION,
description: n,
directives: r,
operationTypes: i
});
}
/**
* OperationTypeDefinition : OperationType : NamedType
*/
parseOperationTypeDefinition() {
const t = this._lexer.token, n = this.parseOperationType();
this.expectToken(L.COLON);
const r = this.parseNamedType();
return this.node(t, {
kind: N.OPERATION_TYPE_DEFINITION,
operation: n,
type: r
});
}
/**
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
*/
parseScalarTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("scalar");
const r = this.parseName(), i = this.parseConstDirectives();
return this.node(t, {
kind: N.SCALAR_TYPE_DEFINITION,
description: n,
name: r,
directives: i
});
}
/**
* ObjectTypeDefinition :
* Description?
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
*/
parseObjectTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("type");
const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(t, {
kind: N.OBJECT_TYPE_DEFINITION,
description: n,
name: r,
interfaces: i,
directives: s,
fields: a
});
}
/**
* ImplementsInterfaces :
* - implements `&`? NamedType
* - ImplementsInterfaces & NamedType
*/
parseImplementsInterfaces() {
return this.expectOptionalKeyword("implements") ? this.delimitedMany(L.AMP, this.parseNamedType) : [];
}
/**
* ```
* FieldsDefinition : { FieldDefinition+ }
* ```
*/
parseFieldsDefinition() {
return this.optionalMany(
L.BRACE_L,
this.parseFieldDefinition,
L.BRACE_R
);
}
/**
* FieldDefinition :
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
*/
parseFieldDefinition() {
const t = this._lexer.token, n = this.parseDescription(), r = this.parseName(), i = this.parseArgumentDefs();
this.expectToken(L.COLON);
const s = this.parseTypeReference(), a = this.parseConstDirectives();
return this.node(t, {
kind: N.FIELD_DEFINITION,
description: n,
name: r,
arguments: i,
type: s,
directives: a
});
}
/**
* ArgumentsDefinition : ( InputValueDefinition+ )
*/
parseArgumentDefs() {
return this.optionalMany(
L.PAREN_L,
this.parseInputValueDef,
L.PAREN_R
);
}
/**
* InputValueDefinition :
* - Description? Name : Type DefaultValue? Directives[Const]?
*/
parseInputValueDef() {
const t = this._lexer.token, n = this.parseDescription(), r = this.parseName();
this.expectToken(L.COLON);
const i = this.parseTypeReference();
let s;
this.expectOptionalToken(L.EQUALS) && (s = this.parseConstValueLiteral());
const a = this.parseConstDirectives();
return this.node(t, {
kind: N.INPUT_VALUE_DEFINITION,
description: n,
name: r,
type: i,
defaultValue: s,
directives: a
});
}
/**
* InterfaceTypeDefinition :
* - Description? interface Name Directives[Const]? FieldsDefinition?
*/
parseInterfaceTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("interface");
const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(t, {
kind: N.INTERFACE_TYPE_DEFINITION,
description: n,
name: r,
interfaces: i,
directives: s,
fields: a
});
}
/**
* UnionTypeDefinition :
* - Description? union Name Directives[Const]? UnionMemberTypes?
*/
parseUnionTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("union");
const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseUnionMemberTypes();
return this.node(t, {
kind: N.UNION_TYPE_DEFINITION,
description: n,
name: r,
directives: i,
types: s
});
}
/**
* UnionMemberTypes :
* - = `|`? NamedType
* - UnionMemberTypes | NamedType
*/
parseUnionMemberTypes() {
return this.expectOptionalToken(L.EQUALS) ? this.delimitedMany(L.PIPE, this.parseNamedType) : [];
}
/**
* EnumTypeDefinition :
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
*/
parseEnumTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("enum");
const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseEnumValuesDefinition();
return this.node(t, {
kind: N.ENUM_TYPE_DEFINITION,
description: n,
name: r,
directives: i,
values: s
});
}
/**
* ```
* EnumValuesDefinition : { EnumValueDefinition+ }
* ```
*/
parseEnumValuesDefinition() {
return this.optionalMany(
L.BRACE_L,
this.parseEnumValueDefinition,
L.BRACE_R
);
}
/**
* EnumValueDefinition : Description? EnumValue Directives[Const]?
*/
parseEnumValueDefinition() {
const t = this._lexer.token, n = this.parseDescription(), r = this.parseEnumValueName(), i = this.parseConstDirectives();
return this.node(t, {
kind: N.ENUM_VALUE_DEFINITION,
description: n,
name: r,
directives: i
});
}
/**
* EnumValue : Name but not `true`, `false` or `null`
*/
parseEnumValueName() {
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
throw sn(
this._lexer.source,
this._lexer.token.start,
`${ps(
this._lexer.token
)} is reserved and cannot be used for an enum value.`
);
return this.parseName();
}
/**
* InputObjectTypeDefinition :
* - Description? input Name Directives[Const]? InputFieldsDefinition?
*/
parseInputObjectTypeDefinition() {
const t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("input");
const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseInputFieldsDefinition();
return this.node(t, {
kind: N.INPUT_OBJECT_TYPE_DEFINITION,
description: n,
name: r,
directives: i,
fields: s
});
}
/**
* ```
* InputFieldsDefinition : { InputValueDefinition+ }
* ```
*/
parseInputFieldsDefinition() {
return this.optionalMany(
L.BRACE_L,
this.parseInputValueDef,
L.BRACE_R
);
}
/**
* TypeSystemExtension :
* - SchemaExtension
* - TypeExtension
*
* TypeExtension :
* - ScalarTypeExtension
* - ObjectTypeExtension
* - InterfaceTypeExtension
* - UnionTypeExtension
* - EnumTypeExtension
* - InputObjectTypeDefinition
*/
parseTypeSystemExtension() {
const t = this._lexer.lookahead();
if (t.kind === L.NAME)
switch (t.value) {
case "schema":
return this.parseSchemaExtension();
case "scalar":
return this.parseScalarTypeExtension();
case "type":
return this.parseObjectTypeExtension();
case "interface":
return this.parseInterfaceTypeExtension();
case "union":
return this.parseUnionTypeExtension();
case "enum":
return this.parseEnumTypeExtension();
case "input":
return this.parseInputObjectTypeExtension();
}
throw this.unexpected(t);
}
/**
* ```
* SchemaExtension :
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
* - extend schema Directives[Const]
* ```
*/
parseSchemaExtension() {
const t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("schema");
const n = this.parseConstDirectives(), r = this.optionalMany(
L.BRACE_L,
this.parseOperationTypeDefinition,
L.BRACE_R
);
if (n.length === 0 && r.length === 0)
throw this.unexpected();
return this.node(t, {
kind: N.SCHEMA_EXTENSION,
directives: n,
operationTypes: r
});
}
/**
* ScalarTypeExtension :
* - extend scalar Name Directives[Const]
*/
parseScalarTypeExtension() {
const t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("scalar");
const n = this.parseName(), r = this.parseConstDirectives();
if (r.length === 0)
throw this.unexpected();
return this.node(t, {
kind: N.SCALAR_TYPE_EXTENSION,
name: n,
directives: r
});
}
/**
* ObjectTypeExtension :
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
* - extend type Name ImplementsInterfaces? Directives[Const]
* - extend type Name ImplementsInterfaces
*/
parseObjectTypeExtension() {
const t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("type");
const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
if (r.length === 0 && i.length === 0 && s.length === 0)
throw this.unexpected();
return this.node(t, {
kind: N.OBJECT_TYPE_EXTENSION,
name: n,
interfaces: r,
directives: i,
fields: s
});
}
/**
* InterfaceTypeExtension :
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
* - extend interface Name ImplementsInterfaces? Directives[Const]
* - extend interface Name ImplementsInterfaces
*/
parseInterfaceTypeExtension() {
const t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("interface");
const n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
if (r.length === 0 && i.length === 0 && s.le