1 | function h() {
|
2 | return (h = Object.assign || function(a) {
|
3 | var b, c, d;
|
4 | for (b = 1; b < arguments.length; b++) {
|
5 | c = arguments[b];
|
6 | for (d in c) {
|
7 | Object.prototype.hasOwnProperty.call(c, d) && (a[d] = c[d]);
|
8 | }
|
9 | }
|
10 | return a;
|
11 | }).apply(this, arguments);
|
12 | }
|
13 |
|
14 | function l(a) {
|
15 | return "string" == typeof a ? new GraphQLError(a) : "object" == typeof a && a.message ? new GraphQLError(a.message, a.nodes, a.source, a.positions, a.path, a, a.extensions || {}) : a;
|
16 | }
|
17 |
|
18 | function m() {
|
19 | return this.message;
|
20 | }
|
21 |
|
22 | function q(a, b) {
|
23 | a |= 0;
|
24 | for (var c = 0, d = 0 | b.length; c < d; c++) {
|
25 | a = (a << 5) + a + b.charCodeAt(c);
|
26 | }
|
27 | return a;
|
28 | }
|
29 |
|
30 | function u(a) {
|
31 | var b, c, d, e, f, g;
|
32 | if (null === a || r.has(a)) {
|
33 | return "null";
|
34 | }
|
35 | if ("object" != typeof a) {
|
36 | return JSON.stringify(a) || "";
|
37 | }
|
38 | if (a.toJSON) {
|
39 | return u(a.toJSON());
|
40 | }
|
41 | if (Array.isArray(a)) {
|
42 | for (b = "[", c = 0, d = a.length; c < d; c++) {
|
43 | 0 < c && (b += ",");
|
44 | b += 0 < (e = u(a[c])).length ? e : "null";
|
45 | }
|
46 | return b + "]";
|
47 | }
|
48 | if (!(b = Object.keys(a).sort()).length && a.constructor && a.constructor !== Object) {
|
49 | return b = t.get(a) || Math.random().toString(36).slice(2), t.set(a, b), '{"__key":"' + b + '"}';
|
50 | }
|
51 | r.add(a);
|
52 | c = "{";
|
53 | d = 0;
|
54 | for (e = b.length; d < e; d++) {
|
55 | (g = u(a[f = b[d]])) && (1 < c.length && (c += ","), c += u(f) + ":" + g);
|
56 | }
|
57 | r.delete(a);
|
58 | return c + "}";
|
59 | }
|
60 |
|
61 | function v(a) {
|
62 | r.clear();
|
63 | return u(a);
|
64 | }
|
65 |
|
66 | function w(a) {
|
67 | return q(5381, a.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim()) >>> 0;
|
68 | }
|
69 |
|
70 | function y(a, b, c) {
|
71 | return {
|
72 | operation: a,
|
73 | data: b.data,
|
74 | error: Array.isArray(b.errors) ? new n({
|
75 | graphQLErrors: b.errors,
|
76 | response: c
|
77 | }) : void 0,
|
78 | extensions: "object" == typeof b.extensions && b.extensions || void 0
|
79 | };
|
80 | }
|
81 |
|
82 | function z(a, b, c) {
|
83 | return {
|
84 | operation: a,
|
85 | data: void 0,
|
86 | error: new n({
|
87 | networkError: b,
|
88 | response: c
|
89 | }),
|
90 | extensions: void 0
|
91 | };
|
92 | }
|
93 |
|
94 | function makeFetchBody(a) {
|
95 | var c, d, e, f, b = print(a.query);
|
96 | a: {
|
97 | for (d = 0, e = (c = a.query).definitions.length; d < e; d++) {
|
98 | if ((f = c.definitions[d]).kind === Kind.OPERATION_DEFINITION && f.name) {
|
99 | c = f.name.value;
|
100 | break a;
|
101 | }
|
102 | }
|
103 | c = void 0;
|
104 | }
|
105 | return {
|
106 | query: b,
|
107 | operationName: c,
|
108 | variables: a.variables || void 0,
|
109 | extensions: void 0
|
110 | };
|
111 | }
|
112 |
|
113 | function makeFetchURL(a, b) {
|
114 | var c = a.context.url;
|
115 | if ("query" !== a.kind || !a.context.preferGetMethod || !b) {
|
116 | return c;
|
117 | }
|
118 | a = [];
|
119 | b.operationName && a.push("operationName=" + encodeURIComponent(b.operationName));
|
120 | b.query && a.push("query=" + encodeURIComponent(b.query.replace(/([\s,]|#[^\n\r]+)+/g, " ").trim()));
|
121 | b.variables && a.push("variables=" + encodeURIComponent(v(b.variables)));
|
122 | b.extensions && a.push("extensions=" + encodeURIComponent(v(b.extensions)));
|
123 | return c + "?" + a.join("&");
|
124 | }
|
125 |
|
126 | function makeFetchOptions(a, b) {
|
127 | var c = "query" === a.kind && !!a.context.preferGetMethod;
|
128 | return h({}, a = "function" == typeof a.context.fetchOptions ? a.context.fetchOptions() : a.context.fetchOptions || {}, {
|
129 | body: !c && b ? JSON.stringify(b) : void 0,
|
130 | method: c ? "GET" : "POST",
|
131 | headers: c ? a.headers : h({}, {
|
132 | "content-type": "application/json"
|
133 | }, a.headers)
|
134 | });
|
135 | }
|
136 |
|
137 | function makeFetchSource(a, b, c) {
|
138 | return make((function(d) {
|
139 | var e = d.next, f = d.complete, g = "undefined" != typeof AbortController ? new AbortController : null, p = !1;
|
140 | Promise.resolve().then((function() {
|
141 | if (!p) {
|
142 | return g && (c.signal = g.signal), function A(a, b, c) {
|
143 | var e, d = !1;
|
144 | return (a.context.fetch || fetch)(b, c).then((function(a) {
|
145 | e = a;
|
146 | d = 200 > a.status || a.status >= ("manual" === c.redirect ? 400 : 300);
|
147 | return a.json();
|
148 | })).then((function(b) {
|
149 | if (!("data" in b) && !("errors" in b)) {
|
150 | throw Error("No Content");
|
151 | }
|
152 | return y(a, b, e);
|
153 | })).catch((function(b) {
|
154 | if ("AbortError" !== b.name) {
|
155 | return z(a, d ? Error(e.statusText) : b, e);
|
156 | }
|
157 | }));
|
158 | }(a, b, c);
|
159 | }
|
160 | })).then((function(a) {
|
161 | p || (p = !0, a && e(a), f());
|
162 | }));
|
163 | return function() {
|
164 | p = !0;
|
165 | g && g.abort();
|
166 | };
|
167 | }));
|
168 | }
|
169 |
|
170 | function createRequest(a, b) {
|
171 | if ("string" == typeof a) {
|
172 | var c = w(a);
|
173 | a = void 0 !== x[c] ? x[c] : parse(a, {
|
174 | noLocation: !0
|
175 | });
|
176 | } else {
|
177 | void 0 !== a.__key ? c = a.__key : (c = w(print(a)), a = void 0 !== x[c] ? x[c] : a);
|
178 | }
|
179 | x[c] = a;
|
180 | a.__key = c;
|
181 | return {
|
182 | key: b ? q(c, v(b)) >>> 0 : c,
|
183 | query: a,
|
184 | variables: b || {}
|
185 | };
|
186 | }
|
187 |
|
188 | var n, r, t, x;
|
189 |
|
190 | import { GraphQLError } from "graphql/error/GraphQLError.mjs";
|
191 |
|
192 | import { parse } from "graphql/language/parser.mjs";
|
193 |
|
194 | import { print } from "graphql/language/printer.mjs";
|
195 |
|
196 | import { Kind } from "graphql/language/kinds.mjs";
|
197 |
|
198 | import { make } from "wonka";
|
199 |
|
200 | n = function(a) {
|
201 | function b(c) {
|
202 | var f, b = c.networkError, e = c.response;
|
203 | f = function k(a, b) {
|
204 | var d = "";
|
205 | if (void 0 !== a) {
|
206 | return d = "[Network] " + a.message;
|
207 | }
|
208 | void 0 !== b && b.forEach((function c(a) {
|
209 | d += "[GraphQL] " + a.message + "\n";
|
210 | }));
|
211 | return d.trim();
|
212 | }(b, c = (c.graphQLErrors || []).map(l));
|
213 | a.call(this, f);
|
214 | this.name = "CombinedError";
|
215 | this.message = f;
|
216 | this.graphQLErrors = c;
|
217 | this.networkError = b;
|
218 | this.response = e;
|
219 | }
|
220 | a && (b.__proto__ = a);
|
221 | (b.prototype = Object.create(a && a.prototype)).constructor = b;
|
222 | b.prototype.toString = m;
|
223 | return b;
|
224 | }(Error);
|
225 |
|
226 | r = new Set, t = new WeakMap;
|
227 |
|
228 | x = Object.create(null);
|
229 |
|
230 | export { n as C, h as _, z as a, makeFetchBody as b, makeFetchURL as c, makeFetchOptions as d, makeFetchSource as e, createRequest as f, y as m, v as s };
|
231 |
|