@0no-co/graphql.web
Advanced tools
Comparing version
@@ -534,3 +534,3 @@ /*!@ts-ignore*/ | ||
type StringValueNode = Or< | ||
GraphQL.FloatValueNode, | ||
GraphQL.StringValueNode, | ||
{ | ||
@@ -537,0 +537,0 @@ readonly kind: Kind.STRING; |
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
class GraphQLError extends Error { | ||
constructor(e, r, i, n, a, t, o) { | ||
constructor(e, r, i, n, t, a, o) { | ||
super(e); | ||
this.name = "GraphQLError"; | ||
this.message = e; | ||
if (a) { | ||
this.path = a; | ||
if (t) { | ||
this.path = t; | ||
} | ||
@@ -23,8 +23,8 @@ if (r) { | ||
} | ||
if (t) { | ||
this.originalError = t; | ||
if (a) { | ||
this.originalError = a; | ||
} | ||
var l = o; | ||
if (!l && t) { | ||
var u = t.extensions; | ||
if (!l && a) { | ||
var u = a.extensions; | ||
if (u && "object" == typeof u) { | ||
@@ -70,4 +70,4 @@ l = u; | ||
var n = ""; | ||
var t = 0; | ||
var a = 0; | ||
var t = 0; | ||
var o = r.length - 1; | ||
@@ -77,14 +77,14 @@ for (var l = 0; l < r.length; l++) { | ||
if (i.test(r[l])) { | ||
if (l && (!a || i.lastIndex < a)) { | ||
a = i.lastIndex; | ||
if (l && (!t || i.lastIndex < t)) { | ||
t = i.lastIndex; | ||
} | ||
t = t || l; | ||
a = a || l; | ||
o = l; | ||
} | ||
} | ||
for (var u = t; u <= o; u++) { | ||
if (u !== t) { | ||
for (var u = a; u <= o; u++) { | ||
if (u !== a) { | ||
n += "\n"; | ||
} | ||
n += r[u].slice(a).replace(/\\"""/g, '"""'); | ||
n += r[u].slice(t).replace(/\\"""/g, '"""'); | ||
} | ||
@@ -105,5 +105,5 @@ return n; | ||
var a = new RegExp("(?:(null|true|false)|\\$(" + n.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + n.source + "))", "y"); | ||
var t = new RegExp("(?:(null|true|false)|\\$(" + n.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + n.source + "))", "y"); | ||
var t = function(e) { | ||
var a = function(e) { | ||
e[e.Const = 1] = "Const"; | ||
@@ -117,3 +117,3 @@ e[e.Var = 2] = "Var"; | ||
return e; | ||
}(t || {}); | ||
}(a || {}); | ||
@@ -125,3 +125,3 @@ var o = /\\/g; | ||
var u; | ||
a.lastIndex = r; | ||
t.lastIndex = r; | ||
if (91 === e.charCodeAt(r)) { | ||
@@ -168,6 +168,6 @@ r++; | ||
}; | ||
} else if (null != (u = a.exec(e))) { | ||
r = a.lastIndex; | ||
} else if (null != (u = t.exec(e))) { | ||
r = t.lastIndex; | ||
ignored(); | ||
if (null != (l = u[t.Const])) { | ||
if (null != (l = u[a.Const])) { | ||
return "null" === l ? { | ||
@@ -179,3 +179,3 @@ kind: "NullValue" | ||
}; | ||
} else if (null != (l = u[t.Var])) { | ||
} else if (null != (l = u[a.Var])) { | ||
if (i) { | ||
@@ -192,5 +192,5 @@ throw error("Variable"); | ||
} | ||
} else if (null != (l = u[t.Int])) { | ||
} else if (null != (l = u[a.Int])) { | ||
var v; | ||
if (null != (v = u[t.Float])) { | ||
if (null != (v = u[a.Float])) { | ||
return { | ||
@@ -206,3 +206,3 @@ kind: "FloatValue", | ||
} | ||
} else if (null != (l = u[t.BlockString])) { | ||
} else if (null != (l = u[a.BlockString])) { | ||
return { | ||
@@ -213,3 +213,3 @@ kind: "StringValue", | ||
}; | ||
} else if (null != (l = u[t.String])) { | ||
} else if (null != (l = u[a.String])) { | ||
return { | ||
@@ -220,3 +220,3 @@ kind: "StringValue", | ||
}; | ||
} else if (null != (l = u[t.Enum])) { | ||
} else if (null != (l = u[a.Enum])) { | ||
return { | ||
@@ -233,8 +233,8 @@ kind: "EnumValue", | ||
if (40 === e.charCodeAt(r)) { | ||
var a = []; | ||
var t = []; | ||
r++; | ||
ignored(); | ||
var t; | ||
var a; | ||
do { | ||
if (null == (t = advance(n))) { | ||
if (null == (a = advance(n))) { | ||
throw error("Argument"); | ||
@@ -247,7 +247,7 @@ } | ||
ignored(); | ||
a.push({ | ||
t.push({ | ||
kind: "Argument", | ||
name: { | ||
kind: "Name", | ||
value: t | ||
value: a | ||
}, | ||
@@ -259,3 +259,3 @@ value: value(i) | ||
ignored(); | ||
return a; | ||
return t; | ||
} | ||
@@ -266,15 +266,15 @@ } | ||
if (64 === e.charCodeAt(r)) { | ||
var a = []; | ||
var t; | ||
var t = []; | ||
var a; | ||
do { | ||
r++; | ||
if (null == (t = advance(n))) { | ||
if (null == (a = advance(n))) { | ||
throw error("Directive"); | ||
} | ||
ignored(); | ||
a.push({ | ||
t.push({ | ||
kind: "Directive", | ||
name: { | ||
kind: "Name", | ||
value: t | ||
value: a | ||
}, | ||
@@ -284,3 +284,3 @@ arguments: arguments_(i) | ||
} while (64 === e.charCodeAt(r)); | ||
return a; | ||
return t; | ||
} | ||
@@ -291,5 +291,5 @@ } | ||
var i; | ||
var a = 0; | ||
var t = 0; | ||
while (91 === e.charCodeAt(r)) { | ||
a++; | ||
t++; | ||
r++; | ||
@@ -302,3 +302,3 @@ ignored(); | ||
ignored(); | ||
var t = { | ||
var a = { | ||
kind: "NamedType", | ||
@@ -314,8 +314,8 @@ name: { | ||
ignored(); | ||
t = { | ||
a = { | ||
kind: "NonNullType", | ||
type: t | ||
type: a | ||
}; | ||
} | ||
if (a) { | ||
if (t) { | ||
if (93 !== e.charCodeAt(r++)) { | ||
@@ -325,9 +325,9 @@ throw error("NamedType"); | ||
ignored(); | ||
t = { | ||
a = { | ||
kind: "ListType", | ||
type: t | ||
type: a | ||
}; | ||
} | ||
} while (a--); | ||
return t; | ||
} while (t--); | ||
return a; | ||
} | ||
@@ -345,9 +345,9 @@ | ||
var i = []; | ||
var t; | ||
var a; | ||
var t; | ||
do { | ||
l.lastIndex = r; | ||
if (null != (t = l.exec(e))) { | ||
if (null != (a = l.exec(e))) { | ||
r = l.lastIndex; | ||
if (null != t[u.Spread]) { | ||
if (null != a[u.Spread]) { | ||
ignored(); | ||
@@ -391,3 +391,3 @@ var o = advance(n); | ||
} | ||
} else if (null != (a = t[u.Name])) { | ||
} else if (null != (t = a[u.Name])) { | ||
var s = void 0; | ||
@@ -398,4 +398,4 @@ ignored(); | ||
ignored(); | ||
s = a; | ||
if (null == (a = advance(n))) { | ||
s = t; | ||
if (null == (t = advance(n))) { | ||
throw error("Field"); | ||
@@ -421,3 +421,3 @@ } | ||
kind: "Name", | ||
value: a | ||
value: t | ||
}, | ||
@@ -443,3 +443,3 @@ arguments: v, | ||
var i; | ||
var a; | ||
var t; | ||
if (null == (i = advance(n))) { | ||
@@ -453,7 +453,7 @@ throw error("FragmentDefinition"); | ||
ignored(); | ||
if (null == (a = advance(n))) { | ||
if (null == (t = advance(n))) { | ||
throw error("FragmentDefinition"); | ||
} | ||
ignored(); | ||
var t = directives(!1); | ||
var a = directives(!1); | ||
if (123 !== e.charCodeAt(r++)) { | ||
@@ -473,6 +473,6 @@ throw error("FragmentDefinition"); | ||
kind: "Name", | ||
value: a | ||
value: t | ||
} | ||
}, | ||
directives: t, | ||
directives: a, | ||
selectionSet: selectionSet() | ||
@@ -485,9 +485,9 @@ }; | ||
function operationDefinition(i) { | ||
var t; | ||
var a; | ||
var t; | ||
var o; | ||
if (i) { | ||
ignored(); | ||
a = advance(n); | ||
t = function variableDefinitions() { | ||
t = advance(n); | ||
a = function variableDefinitions() { | ||
ignored(); | ||
@@ -498,3 +498,3 @@ if (40 === e.charCodeAt(r)) { | ||
ignored(); | ||
var a; | ||
var t; | ||
do { | ||
@@ -504,3 +504,3 @@ if (36 !== e.charCodeAt(r++)) { | ||
} | ||
if (null == (a = advance(n))) { | ||
if (null == (t = advance(n))) { | ||
throw error("Variable"); | ||
@@ -513,3 +513,3 @@ } | ||
ignored(); | ||
var t = type(); | ||
var a = type(); | ||
var o = void 0; | ||
@@ -528,6 +528,6 @@ if (61 === e.charCodeAt(r)) { | ||
kind: "Name", | ||
value: a | ||
value: t | ||
} | ||
}, | ||
type: t, | ||
type: a, | ||
defaultValue: o, | ||
@@ -550,7 +550,7 @@ directives: directives(!0) | ||
operation: i || "query", | ||
name: a ? { | ||
name: t ? { | ||
kind: "Name", | ||
value: a | ||
value: t | ||
} : void 0, | ||
variableDefinitions: t, | ||
variableDefinitions: a, | ||
directives: o, | ||
@@ -564,2 +564,13 @@ selectionSet: selectionSet() | ||
function mapJoin(e, r, i) { | ||
var n = ""; | ||
for (var t = 0; t < e.length; t++) { | ||
if (t) { | ||
n += r; | ||
} | ||
n += i(e[t]); | ||
} | ||
return n; | ||
} | ||
function printString(e) { | ||
@@ -573,9 +584,6 @@ return JSON.stringify(e); | ||
var hasItems = e => !(!e || !e.length); | ||
var v = "\n"; | ||
var v = { | ||
var c = { | ||
OperationDefinition(e) { | ||
if ("query" === e.operation && !e.name && !hasItems(e.variableDefinitions) && !hasItems(e.directives)) { | ||
return v.SelectionSet(e.selectionSet); | ||
} | ||
var r = e.operation; | ||
@@ -585,20 +593,20 @@ if (e.name) { | ||
} | ||
if (hasItems(e.variableDefinitions)) { | ||
if (e.variableDefinitions && e.variableDefinitions.length) { | ||
if (!e.name) { | ||
r += " "; | ||
} | ||
r += "(" + e.variableDefinitions.map(v.VariableDefinition).join(", ") + ")"; | ||
r += "(" + mapJoin(e.variableDefinitions, ", ", c.VariableDefinition) + ")"; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
return r + " " + v.SelectionSet(e.selectionSet); | ||
return "query" !== r ? r + " " + c.SelectionSet(e.selectionSet) : c.SelectionSet(e.selectionSet); | ||
}, | ||
VariableDefinition(e) { | ||
var r = v.Variable(e.variable) + ": " + print(e.type); | ||
var r = c.Variable(e.variable) + ": " + _print(e.type); | ||
if (e.defaultValue) { | ||
r += " = " + print(e.defaultValue); | ||
r += " = " + _print(e.defaultValue); | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
@@ -608,14 +616,26 @@ return r; | ||
Field(e) { | ||
var r = (e.alias ? e.alias.value + ": " : "") + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
var i = e.arguments.map(v.Argument); | ||
var n = r + "(" + i.join(", ") + ")"; | ||
r = n.length > 80 ? r + "(\n " + i.join("\n").replace(/\n/g, "\n ") + "\n)" : n; | ||
var r = e.alias ? e.alias.value + ": " + e.name.value : e.name.value; | ||
if (e.arguments && e.arguments.length) { | ||
var i = mapJoin(e.arguments, ", ", c.Argument); | ||
if (r.length + i.length + 2 > 80) { | ||
r += "(" + (v += " ") + mapJoin(e.arguments, v, c.Argument) + (v = v.slice(0, -2)) + ")"; | ||
} else { | ||
r += "(" + i + ")"; | ||
} | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
return e.selectionSet ? r + " " + v.SelectionSet(e.selectionSet) : r; | ||
if (e.selectionSet) { | ||
r += " " + c.SelectionSet(e.selectionSet); | ||
} | ||
return r; | ||
}, | ||
StringValue: e => e.block ? printBlockString(e.value) : printString(e.value), | ||
StringValue(e) { | ||
if (e.block) { | ||
return printBlockString(e.value).replace(/\n/g, v); | ||
} else { | ||
return printString(e.value); | ||
} | ||
}, | ||
BooleanValue: e => "" + e.value, | ||
@@ -628,12 +648,17 @@ NullValue: e => "null", | ||
Variable: e => "$" + e.name.value, | ||
ListValue: e => "[" + e.values.map(print).join(", ") + "]", | ||
ObjectValue: e => "{" + e.fields.map(v.ObjectField).join(", ") + "}", | ||
ObjectField: e => e.name.value + ": " + print(e.value), | ||
Document: e => hasItems(e.definitions) ? e.definitions.map(print).join("\n\n") : "", | ||
SelectionSet: e => "{\n " + e.selections.map(print).join("\n").replace(/\n/g, "\n ") + "\n}", | ||
Argument: e => e.name.value + ": " + print(e.value), | ||
ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]", | ||
ObjectValue: e => "{" + mapJoin(e.fields, ", ", c.ObjectField) + "}", | ||
ObjectField: e => e.name.value + ": " + _print(e.value), | ||
Document(e) { | ||
if (!e.definitions || !e.definitions.length) { | ||
return ""; | ||
} | ||
return mapJoin(e.definitions, "\n\n", _print); | ||
}, | ||
SelectionSet: e => "{" + (v += " ") + mapJoin(e.selections, v, _print) + (v = v.slice(0, -2)) + "}", | ||
Argument: e => e.name.value + ": " + _print(e.value), | ||
FragmentSpread(e) { | ||
var r = "..." + e.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
@@ -647,6 +672,6 @@ return r; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
return r += " " + c.SelectionSet(e.selectionSet); | ||
}, | ||
@@ -656,11 +681,11 @@ FragmentDefinition(e) { | ||
r += " on " + e.typeCondition.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(v.Directive).join(" "); | ||
if (e.directives && e.directives.length) { | ||
r += " " + mapJoin(e.directives, " ", c.Directive); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
return r + " " + c.SelectionSet(e.selectionSet); | ||
}, | ||
Directive(e) { | ||
var r = "@" + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
r += "(" + e.arguments.map(v.Argument).join(", ") + ")"; | ||
if (e.arguments && e.arguments.length) { | ||
r += "(" + mapJoin(e.arguments, ", ", c.Argument) + ")"; | ||
} | ||
@@ -670,9 +695,7 @@ return r; | ||
NamedType: e => e.name.value, | ||
ListType: e => "[" + print(e.type) + "]", | ||
NonNullType: e => print(e.type) + "!" | ||
ListType: e => "[" + _print(e.type) + "]", | ||
NonNullType: e => _print(e.type) + "!" | ||
}; | ||
function print(e) { | ||
return v[e.kind] ? v[e.kind](e) : ""; | ||
} | ||
var _print = e => c[e.kind](e); | ||
@@ -703,7 +726,7 @@ function valueFromASTUntyped(e, r) { | ||
case "ObjectValue": | ||
var a = Object.create(null); | ||
for (var t of e.fields) { | ||
a[t.name.value] = valueFromASTUntyped(t.value, r); | ||
var t = Object.create(null); | ||
for (var a of e.fields) { | ||
t[a.name.value] = valueFromASTUntyped(a.value, r); | ||
} | ||
return a; | ||
return t; | ||
@@ -759,9 +782,9 @@ case "Variable": | ||
ignored(); | ||
var a = []; | ||
var t = []; | ||
do { | ||
if ("fragment" === (i = advance(d))) { | ||
ignored(); | ||
a.push(fragmentDefinition()); | ||
t.push(fragmentDefinition()); | ||
} else if (null != (n = operationDefinition(i))) { | ||
a.push(n); | ||
t.push(n); | ||
} else { | ||
@@ -773,3 +796,3 @@ throw error("Document"); | ||
kind: "Document", | ||
definitions: a | ||
definitions: t | ||
}; | ||
@@ -792,3 +815,6 @@ }(); | ||
exports.print = print; | ||
exports.print = function print(e) { | ||
v = "\n"; | ||
return c[e.kind] ? c[e.kind](e) : ""; | ||
}; | ||
@@ -811,8 +837,8 @@ exports.printBlockString = printBlockString; | ||
var n = []; | ||
for (var a of e.values) { | ||
var t = valueFromTypeNode(a, r.type, i); | ||
if (void 0 === t) { | ||
for (var t of e.values) { | ||
var a = valueFromTypeNode(t, r.type, i); | ||
if (void 0 === a) { | ||
return; | ||
} else { | ||
n.push(t); | ||
n.push(a); | ||
} | ||
@@ -840,6 +866,6 @@ } | ||
try { | ||
var a = function traverse(e, a, t) { | ||
var t = function traverse(e, t, a) { | ||
var o = !1; | ||
var l = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter; | ||
var u = l && l.call(r, e, a, t, n, i); | ||
var u = l && l.call(r, e, t, a, n, i); | ||
if (!1 === u) { | ||
@@ -855,4 +881,4 @@ return e; | ||
} | ||
if (t) { | ||
i.push(t); | ||
if (a) { | ||
i.push(a); | ||
} | ||
@@ -895,7 +921,7 @@ var d; | ||
} | ||
if (t) { | ||
if (a) { | ||
i.pop(); | ||
} | ||
var g = r[e.kind] && r[e.kind].leave || r.leave; | ||
var h = g && g.call(r, e, a, t, n, i); | ||
var h = g && g.call(r, e, t, a, n, i); | ||
if (h === s) { | ||
@@ -911,3 +937,3 @@ throw s; | ||
}(e); | ||
return void 0 !== a && !1 !== a ? a : e; | ||
return void 0 !== t && !1 !== t ? t : e; | ||
} catch (r) { | ||
@@ -914,0 +940,0 @@ if (r !== s) { |
{ | ||
"name": "@0no-co/graphql.web", | ||
"description": "A spec-compliant client-side GraphQL implementation", | ||
"version": "1.0.5-canary-896f588a807bd3ccf890eaf48fe0654bb684a278", | ||
"version": "1.0.5", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -6,0 +6,0 @@ "source": "./src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
170207
2.86%2492
2.09%1
-50%