client.js 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617
  1. var SubscriptionsTransportWs =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, {
  41. /******/ configurable: false,
  42. /******/ enumerable: true,
  43. /******/ get: getter
  44. /******/ });
  45. /******/ }
  46. /******/ };
  47. /******/
  48. /******/ // getDefaultExport function for compatibility with non-harmony modules
  49. /******/ __webpack_require__.n = function(module) {
  50. /******/ var getter = module && module.__esModule ?
  51. /******/ function getDefault() { return module['default']; } :
  52. /******/ function getModuleExports() { return module; };
  53. /******/ __webpack_require__.d(getter, 'a', getter);
  54. /******/ return getter;
  55. /******/ };
  56. /******/
  57. /******/ // Object.prototype.hasOwnProperty.call
  58. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  59. /******/
  60. /******/ // __webpack_public_path__
  61. /******/ __webpack_require__.p = "";
  62. /******/
  63. /******/ // Load entry module and return exports
  64. /******/ return __webpack_require__(__webpack_require__.s = 2);
  65. /******/ })
  66. /************************************************************************/
  67. /******/ ([
  68. /* 0 */
  69. /***/ (function(module, exports) {
  70. var g;
  71. // This works in non-strict mode
  72. g = (function() {
  73. return this;
  74. })();
  75. try {
  76. // This works if eval is allowed (see CSP)
  77. g = g || Function("return this")() || (1,eval)("this");
  78. } catch(e) {
  79. // This works if the window reference is available
  80. if(typeof window === "object")
  81. g = window;
  82. }
  83. // g can still be undefined, but nothing to do about it...
  84. // We return undefined, instead of nothing here, so it's
  85. // easier to handle this case. if(!global) { ...}
  86. module.exports = g;
  87. /***/ }),
  88. /* 1 */
  89. /***/ (function(module, exports, __webpack_require__) {
  90. "use strict";
  91. Object.defineProperty(exports, "__esModule", {
  92. value: true
  93. });
  94. exports.default = void 0;
  95. // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
  96. var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
  97. var _default = nodejsCustomInspectSymbol;
  98. exports.default = _default;
  99. /***/ }),
  100. /* 2 */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. /* WEBPACK VAR INJECTION */(function(global) {
  104. var __assign = (this && this.__assign) || function () {
  105. __assign = Object.assign || function(t) {
  106. for (var s, i = 1, n = arguments.length; i < n; i++) {
  107. s = arguments[i];
  108. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  109. t[p] = s[p];
  110. }
  111. return t;
  112. };
  113. return __assign.apply(this, arguments);
  114. };
  115. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  116. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  117. return new (P || (P = Promise))(function (resolve, reject) {
  118. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  119. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  120. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  121. step((generator = generator.apply(thisArg, _arguments || [])).next());
  122. });
  123. };
  124. var __generator = (this && this.__generator) || function (thisArg, body) {
  125. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  126. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  127. function verb(n) { return function (v) { return step([n, v]); }; }
  128. function step(op) {
  129. if (f) throw new TypeError("Generator is already executing.");
  130. while (_) try {
  131. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  132. if (y = 0, t) op = [op[0] & 2, t.value];
  133. switch (op[0]) {
  134. case 0: case 1: t = op; break;
  135. case 4: _.label++; return { value: op[1], done: false };
  136. case 5: _.label++; y = op[1]; op = [0]; continue;
  137. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  138. default:
  139. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  140. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  141. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  142. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  143. if (t[2]) _.ops.pop();
  144. _.trys.pop(); continue;
  145. }
  146. op = body.call(thisArg, _);
  147. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  148. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  149. }
  150. };
  151. var __spreadArrays = (this && this.__spreadArrays) || function () {
  152. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  153. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  154. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  155. r[k] = a[j];
  156. return r;
  157. };
  158. Object.defineProperty(exports, "__esModule", { value: true });
  159. exports.SubscriptionClient = void 0;
  160. var _global = typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : {});
  161. var NativeWebSocket = _global.WebSocket || _global.MozWebSocket;
  162. var Backoff = __webpack_require__(3);
  163. var eventemitter3_1 = __webpack_require__(4);
  164. var is_string_1 = __webpack_require__(5);
  165. var is_object_1 = __webpack_require__(6);
  166. var printer_1 = __webpack_require__(7);
  167. var getOperationAST_1 = __webpack_require__(14);
  168. var symbol_observable_1 = __webpack_require__(16);
  169. var protocol_1 = __webpack_require__(19);
  170. var defaults_1 = __webpack_require__(20);
  171. var message_types_1 = __webpack_require__(21);
  172. var SubscriptionClient = (function () {
  173. function SubscriptionClient(url, options, webSocketImpl, webSocketProtocols) {
  174. var _a = (options || {}), _b = _a.connectionCallback, connectionCallback = _b === void 0 ? undefined : _b, _c = _a.connectionParams, connectionParams = _c === void 0 ? {} : _c, _d = _a.minTimeout, minTimeout = _d === void 0 ? defaults_1.MIN_WS_TIMEOUT : _d, _e = _a.timeout, timeout = _e === void 0 ? defaults_1.WS_TIMEOUT : _e, _f = _a.reconnect, reconnect = _f === void 0 ? false : _f, _g = _a.reconnectionAttempts, reconnectionAttempts = _g === void 0 ? Infinity : _g, _h = _a.lazy, lazy = _h === void 0 ? false : _h, _j = _a.inactivityTimeout, inactivityTimeout = _j === void 0 ? 0 : _j, _k = _a.wsOptionArguments, wsOptionArguments = _k === void 0 ? [] : _k;
  175. this.wsImpl = webSocketImpl || NativeWebSocket;
  176. if (!this.wsImpl) {
  177. throw new Error('Unable to find native implementation, or alternative implementation for WebSocket!');
  178. }
  179. this.wsProtocols = webSocketProtocols || protocol_1.GRAPHQL_WS;
  180. this.connectionCallback = connectionCallback;
  181. this.url = url;
  182. this.operations = {};
  183. this.nextOperationId = 0;
  184. this.minWsTimeout = minTimeout;
  185. this.wsTimeout = timeout;
  186. this.unsentMessagesQueue = [];
  187. this.reconnect = reconnect;
  188. this.reconnecting = false;
  189. this.reconnectionAttempts = reconnectionAttempts;
  190. this.lazy = !!lazy;
  191. this.inactivityTimeout = inactivityTimeout;
  192. this.closedByUser = false;
  193. this.backoff = new Backoff({ jitter: 0.5 });
  194. this.eventEmitter = new eventemitter3_1.EventEmitter();
  195. this.middlewares = [];
  196. this.client = null;
  197. this.maxConnectTimeGenerator = this.createMaxConnectTimeGenerator();
  198. this.connectionParams = this.getConnectionParams(connectionParams);
  199. this.wsOptionArguments = wsOptionArguments;
  200. if (!this.lazy) {
  201. this.connect();
  202. }
  203. }
  204. Object.defineProperty(SubscriptionClient.prototype, "status", {
  205. get: function () {
  206. if (this.client === null) {
  207. return this.wsImpl.CLOSED;
  208. }
  209. return this.client.readyState;
  210. },
  211. enumerable: false,
  212. configurable: true
  213. });
  214. SubscriptionClient.prototype.close = function (isForced, closedByUser) {
  215. if (isForced === void 0) { isForced = true; }
  216. if (closedByUser === void 0) { closedByUser = true; }
  217. this.clearInactivityTimeout();
  218. if (this.client !== null) {
  219. this.closedByUser = closedByUser;
  220. if (isForced) {
  221. this.clearCheckConnectionInterval();
  222. this.clearMaxConnectTimeout();
  223. this.clearTryReconnectTimeout();
  224. this.unsubscribeAll();
  225. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_TERMINATE, null);
  226. }
  227. this.client.close();
  228. this.client.onopen = null;
  229. this.client.onclose = null;
  230. this.client.onerror = null;
  231. this.client.onmessage = null;
  232. this.client = null;
  233. this.eventEmitter.emit('disconnected');
  234. if (!isForced) {
  235. this.tryReconnect();
  236. }
  237. }
  238. };
  239. SubscriptionClient.prototype.request = function (request) {
  240. var _a;
  241. var getObserver = this.getObserver.bind(this);
  242. var executeOperation = this.executeOperation.bind(this);
  243. var unsubscribe = this.unsubscribe.bind(this);
  244. var opId;
  245. this.clearInactivityTimeout();
  246. return _a = {},
  247. _a[symbol_observable_1.default] = function () {
  248. return this;
  249. },
  250. _a.subscribe = function (observerOrNext, onError, onComplete) {
  251. var observer = getObserver(observerOrNext, onError, onComplete);
  252. opId = executeOperation(request, function (error, result) {
  253. if (error === null && result === null) {
  254. if (observer.complete) {
  255. observer.complete();
  256. }
  257. }
  258. else if (error) {
  259. if (observer.error) {
  260. observer.error(error[0]);
  261. }
  262. }
  263. else {
  264. if (observer.next) {
  265. observer.next(result);
  266. }
  267. }
  268. });
  269. return {
  270. unsubscribe: function () {
  271. if (opId) {
  272. unsubscribe(opId);
  273. opId = null;
  274. }
  275. },
  276. };
  277. },
  278. _a;
  279. };
  280. SubscriptionClient.prototype.on = function (eventName, callback, context) {
  281. var handler = this.eventEmitter.on(eventName, callback, context);
  282. return function () {
  283. handler.off(eventName, callback, context);
  284. };
  285. };
  286. SubscriptionClient.prototype.onConnected = function (callback, context) {
  287. return this.on('connected', callback, context);
  288. };
  289. SubscriptionClient.prototype.onConnecting = function (callback, context) {
  290. return this.on('connecting', callback, context);
  291. };
  292. SubscriptionClient.prototype.onDisconnected = function (callback, context) {
  293. return this.on('disconnected', callback, context);
  294. };
  295. SubscriptionClient.prototype.onReconnected = function (callback, context) {
  296. return this.on('reconnected', callback, context);
  297. };
  298. SubscriptionClient.prototype.onReconnecting = function (callback, context) {
  299. return this.on('reconnecting', callback, context);
  300. };
  301. SubscriptionClient.prototype.onError = function (callback, context) {
  302. return this.on('error', callback, context);
  303. };
  304. SubscriptionClient.prototype.unsubscribeAll = function () {
  305. var _this = this;
  306. Object.keys(this.operations).forEach(function (subId) {
  307. _this.unsubscribe(subId);
  308. });
  309. };
  310. SubscriptionClient.prototype.applyMiddlewares = function (options) {
  311. var _this = this;
  312. return new Promise(function (resolve, reject) {
  313. var queue = function (funcs, scope) {
  314. var next = function (error) {
  315. if (error) {
  316. reject(error);
  317. }
  318. else {
  319. if (funcs.length > 0) {
  320. var f = funcs.shift();
  321. if (f) {
  322. f.applyMiddleware.apply(scope, [options, next]);
  323. }
  324. }
  325. else {
  326. resolve(options);
  327. }
  328. }
  329. };
  330. next();
  331. };
  332. queue(__spreadArrays(_this.middlewares), _this);
  333. });
  334. };
  335. SubscriptionClient.prototype.use = function (middlewares) {
  336. var _this = this;
  337. middlewares.map(function (middleware) {
  338. if (typeof middleware.applyMiddleware === 'function') {
  339. _this.middlewares.push(middleware);
  340. }
  341. else {
  342. throw new Error('Middleware must implement the applyMiddleware function.');
  343. }
  344. });
  345. return this;
  346. };
  347. SubscriptionClient.prototype.getConnectionParams = function (connectionParams) {
  348. return function () { return new Promise(function (resolve, reject) {
  349. if (typeof connectionParams === 'function') {
  350. try {
  351. return resolve(connectionParams.call(null));
  352. }
  353. catch (error) {
  354. return reject(error);
  355. }
  356. }
  357. resolve(connectionParams);
  358. }); };
  359. };
  360. SubscriptionClient.prototype.executeOperation = function (options, handler) {
  361. var _this = this;
  362. if (this.client === null) {
  363. this.connect();
  364. }
  365. var opId = this.generateOperationId();
  366. this.operations[opId] = { options: options, handler: handler };
  367. this.applyMiddlewares(options)
  368. .then(function (processedOptions) {
  369. _this.checkOperationOptions(processedOptions, handler);
  370. if (_this.operations[opId]) {
  371. _this.operations[opId] = { options: processedOptions, handler: handler };
  372. _this.sendMessage(opId, message_types_1.default.GQL_START, processedOptions);
  373. }
  374. })
  375. .catch(function (error) {
  376. _this.unsubscribe(opId);
  377. handler(_this.formatErrors(error));
  378. });
  379. return opId;
  380. };
  381. SubscriptionClient.prototype.getObserver = function (observerOrNext, error, complete) {
  382. if (typeof observerOrNext === 'function') {
  383. return {
  384. next: function (v) { return observerOrNext(v); },
  385. error: function (e) { return error && error(e); },
  386. complete: function () { return complete && complete(); },
  387. };
  388. }
  389. return observerOrNext;
  390. };
  391. SubscriptionClient.prototype.createMaxConnectTimeGenerator = function () {
  392. var minValue = this.minWsTimeout;
  393. var maxValue = this.wsTimeout;
  394. return new Backoff({
  395. min: minValue,
  396. max: maxValue,
  397. factor: 1.2,
  398. });
  399. };
  400. SubscriptionClient.prototype.clearCheckConnectionInterval = function () {
  401. if (this.checkConnectionIntervalId) {
  402. clearInterval(this.checkConnectionIntervalId);
  403. this.checkConnectionIntervalId = null;
  404. }
  405. };
  406. SubscriptionClient.prototype.clearMaxConnectTimeout = function () {
  407. if (this.maxConnectTimeoutId) {
  408. clearTimeout(this.maxConnectTimeoutId);
  409. this.maxConnectTimeoutId = null;
  410. }
  411. };
  412. SubscriptionClient.prototype.clearTryReconnectTimeout = function () {
  413. if (this.tryReconnectTimeoutId) {
  414. clearTimeout(this.tryReconnectTimeoutId);
  415. this.tryReconnectTimeoutId = null;
  416. }
  417. };
  418. SubscriptionClient.prototype.clearInactivityTimeout = function () {
  419. if (this.inactivityTimeoutId) {
  420. clearTimeout(this.inactivityTimeoutId);
  421. this.inactivityTimeoutId = null;
  422. }
  423. };
  424. SubscriptionClient.prototype.setInactivityTimeout = function () {
  425. var _this = this;
  426. if (this.inactivityTimeout > 0 && Object.keys(this.operations).length === 0) {
  427. this.inactivityTimeoutId = setTimeout(function () {
  428. if (Object.keys(_this.operations).length === 0) {
  429. _this.close();
  430. }
  431. }, this.inactivityTimeout);
  432. }
  433. };
  434. SubscriptionClient.prototype.checkOperationOptions = function (options, handler) {
  435. var query = options.query, variables = options.variables, operationName = options.operationName;
  436. if (!query) {
  437. throw new Error('Must provide a query.');
  438. }
  439. if (!handler) {
  440. throw new Error('Must provide an handler.');
  441. }
  442. if ((!is_string_1.default(query) && !getOperationAST_1.getOperationAST(query, operationName)) ||
  443. (operationName && !is_string_1.default(operationName)) ||
  444. (variables && !is_object_1.default(variables))) {
  445. throw new Error('Incorrect option types. query must be a string or a document,' +
  446. '`operationName` must be a string, and `variables` must be an object.');
  447. }
  448. };
  449. SubscriptionClient.prototype.buildMessage = function (id, type, payload) {
  450. var payloadToReturn = payload && payload.query ? __assign(__assign({}, payload), { query: typeof payload.query === 'string' ? payload.query : printer_1.print(payload.query) }) :
  451. payload;
  452. return {
  453. id: id,
  454. type: type,
  455. payload: payloadToReturn,
  456. };
  457. };
  458. SubscriptionClient.prototype.formatErrors = function (errors) {
  459. if (Array.isArray(errors)) {
  460. return errors;
  461. }
  462. if (errors && errors.errors) {
  463. return this.formatErrors(errors.errors);
  464. }
  465. if (errors && errors.message) {
  466. return [errors];
  467. }
  468. return [{
  469. name: 'FormatedError',
  470. message: 'Unknown error',
  471. originalError: errors,
  472. }];
  473. };
  474. SubscriptionClient.prototype.sendMessage = function (id, type, payload) {
  475. this.sendMessageRaw(this.buildMessage(id, type, payload));
  476. };
  477. SubscriptionClient.prototype.sendMessageRaw = function (message) {
  478. switch (this.status) {
  479. case this.wsImpl.OPEN:
  480. var serializedMessage = JSON.stringify(message);
  481. try {
  482. JSON.parse(serializedMessage);
  483. }
  484. catch (e) {
  485. this.eventEmitter.emit('error', new Error("Message must be JSON-serializable. Got: " + message));
  486. }
  487. this.client.send(serializedMessage);
  488. break;
  489. case this.wsImpl.CONNECTING:
  490. this.unsentMessagesQueue.push(message);
  491. break;
  492. default:
  493. if (!this.reconnecting) {
  494. this.eventEmitter.emit('error', new Error('A message was not sent because socket is not connected, is closing or ' +
  495. 'is already closed. Message was: ' + JSON.stringify(message)));
  496. }
  497. }
  498. };
  499. SubscriptionClient.prototype.generateOperationId = function () {
  500. return String(++this.nextOperationId);
  501. };
  502. SubscriptionClient.prototype.tryReconnect = function () {
  503. var _this = this;
  504. if (!this.reconnect || this.backoff.attempts >= this.reconnectionAttempts) {
  505. return;
  506. }
  507. if (!this.reconnecting) {
  508. Object.keys(this.operations).forEach(function (key) {
  509. _this.unsentMessagesQueue.push(_this.buildMessage(key, message_types_1.default.GQL_START, _this.operations[key].options));
  510. });
  511. this.reconnecting = true;
  512. }
  513. this.clearTryReconnectTimeout();
  514. var delay = this.backoff.duration();
  515. this.tryReconnectTimeoutId = setTimeout(function () {
  516. _this.connect();
  517. }, delay);
  518. };
  519. SubscriptionClient.prototype.flushUnsentMessagesQueue = function () {
  520. var _this = this;
  521. this.unsentMessagesQueue.forEach(function (message) {
  522. _this.sendMessageRaw(message);
  523. });
  524. this.unsentMessagesQueue = [];
  525. };
  526. SubscriptionClient.prototype.checkConnection = function () {
  527. if (this.wasKeepAliveReceived) {
  528. this.wasKeepAliveReceived = false;
  529. return;
  530. }
  531. if (!this.reconnecting) {
  532. this.close(false, true);
  533. }
  534. };
  535. SubscriptionClient.prototype.checkMaxConnectTimeout = function () {
  536. var _this = this;
  537. this.clearMaxConnectTimeout();
  538. this.maxConnectTimeoutId = setTimeout(function () {
  539. if (_this.status !== _this.wsImpl.OPEN) {
  540. _this.reconnecting = true;
  541. _this.close(false, true);
  542. }
  543. }, this.maxConnectTimeGenerator.duration());
  544. };
  545. SubscriptionClient.prototype.connect = function () {
  546. var _a;
  547. var _this = this;
  548. this.client = new ((_a = this.wsImpl).bind.apply(_a, __spreadArrays([void 0, this.url, this.wsProtocols], this.wsOptionArguments)))();
  549. this.checkMaxConnectTimeout();
  550. this.client.onopen = function () { return __awaiter(_this, void 0, void 0, function () {
  551. var connectionParams, error_1;
  552. return __generator(this, function (_a) {
  553. switch (_a.label) {
  554. case 0:
  555. if (!(this.status === this.wsImpl.OPEN)) return [3, 4];
  556. this.clearMaxConnectTimeout();
  557. this.closedByUser = false;
  558. this.eventEmitter.emit(this.reconnecting ? 'reconnecting' : 'connecting');
  559. _a.label = 1;
  560. case 1:
  561. _a.trys.push([1, 3, , 4]);
  562. return [4, this.connectionParams()];
  563. case 2:
  564. connectionParams = _a.sent();
  565. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_INIT, connectionParams);
  566. this.flushUnsentMessagesQueue();
  567. return [3, 4];
  568. case 3:
  569. error_1 = _a.sent();
  570. this.sendMessage(undefined, message_types_1.default.GQL_CONNECTION_ERROR, error_1);
  571. this.flushUnsentMessagesQueue();
  572. return [3, 4];
  573. case 4: return [2];
  574. }
  575. });
  576. }); };
  577. this.client.onclose = function () {
  578. if (!_this.closedByUser) {
  579. _this.close(false, false);
  580. }
  581. };
  582. this.client.onerror = function (err) {
  583. _this.eventEmitter.emit('error', err);
  584. };
  585. this.client.onmessage = function (_a) {
  586. var data = _a.data;
  587. _this.processReceivedData(data);
  588. };
  589. };
  590. SubscriptionClient.prototype.processReceivedData = function (receivedData) {
  591. var parsedMessage;
  592. var opId;
  593. try {
  594. parsedMessage = JSON.parse(receivedData);
  595. opId = parsedMessage.id;
  596. }
  597. catch (e) {
  598. throw new Error("Message must be JSON-parseable. Got: " + receivedData);
  599. }
  600. if ([message_types_1.default.GQL_DATA,
  601. message_types_1.default.GQL_COMPLETE,
  602. message_types_1.default.GQL_ERROR,
  603. ].indexOf(parsedMessage.type) !== -1 && !this.operations[opId]) {
  604. this.unsubscribe(opId);
  605. return;
  606. }
  607. switch (parsedMessage.type) {
  608. case message_types_1.default.GQL_CONNECTION_ERROR:
  609. if (this.connectionCallback) {
  610. this.connectionCallback(parsedMessage.payload);
  611. }
  612. break;
  613. case message_types_1.default.GQL_CONNECTION_ACK:
  614. this.eventEmitter.emit(this.reconnecting ? 'reconnected' : 'connected', parsedMessage.payload);
  615. this.reconnecting = false;
  616. this.backoff.reset();
  617. this.maxConnectTimeGenerator.reset();
  618. if (this.connectionCallback) {
  619. this.connectionCallback();
  620. }
  621. break;
  622. case message_types_1.default.GQL_COMPLETE:
  623. var handler = this.operations[opId].handler;
  624. delete this.operations[opId];
  625. handler.call(this, null, null);
  626. break;
  627. case message_types_1.default.GQL_ERROR:
  628. this.operations[opId].handler(this.formatErrors(parsedMessage.payload), null);
  629. delete this.operations[opId];
  630. break;
  631. case message_types_1.default.GQL_DATA:
  632. var parsedPayload = !parsedMessage.payload.errors ?
  633. parsedMessage.payload : __assign(__assign({}, parsedMessage.payload), { errors: this.formatErrors(parsedMessage.payload.errors) });
  634. this.operations[opId].handler(null, parsedPayload);
  635. break;
  636. case message_types_1.default.GQL_CONNECTION_KEEP_ALIVE:
  637. var firstKA = typeof this.wasKeepAliveReceived === 'undefined';
  638. this.wasKeepAliveReceived = true;
  639. if (firstKA) {
  640. this.checkConnection();
  641. }
  642. if (this.checkConnectionIntervalId) {
  643. clearInterval(this.checkConnectionIntervalId);
  644. this.checkConnection();
  645. }
  646. this.checkConnectionIntervalId = setInterval(this.checkConnection.bind(this), this.wsTimeout);
  647. break;
  648. default:
  649. throw new Error('Invalid message type!');
  650. }
  651. };
  652. SubscriptionClient.prototype.unsubscribe = function (opId) {
  653. if (this.operations[opId]) {
  654. delete this.operations[opId];
  655. this.setInactivityTimeout();
  656. this.sendMessage(opId, message_types_1.default.GQL_STOP, undefined);
  657. }
  658. };
  659. return SubscriptionClient;
  660. }());
  661. exports.SubscriptionClient = SubscriptionClient;
  662. //# sourceMappingURL=client.js.map
  663. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  664. /***/ }),
  665. /* 3 */
  666. /***/ (function(module, exports) {
  667. /**
  668. * Expose `Backoff`.
  669. */
  670. module.exports = Backoff;
  671. /**
  672. * Initialize backoff timer with `opts`.
  673. *
  674. * - `min` initial timeout in milliseconds [100]
  675. * - `max` max timeout [10000]
  676. * - `jitter` [0]
  677. * - `factor` [2]
  678. *
  679. * @param {Object} opts
  680. * @api public
  681. */
  682. function Backoff(opts) {
  683. opts = opts || {};
  684. this.ms = opts.min || 100;
  685. this.max = opts.max || 10000;
  686. this.factor = opts.factor || 2;
  687. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  688. this.attempts = 0;
  689. }
  690. /**
  691. * Return the backoff duration.
  692. *
  693. * @return {Number}
  694. * @api public
  695. */
  696. Backoff.prototype.duration = function(){
  697. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  698. if (this.jitter) {
  699. var rand = Math.random();
  700. var deviation = Math.floor(rand * this.jitter * ms);
  701. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  702. }
  703. return Math.min(ms, this.max) | 0;
  704. };
  705. /**
  706. * Reset the number of attempts.
  707. *
  708. * @api public
  709. */
  710. Backoff.prototype.reset = function(){
  711. this.attempts = 0;
  712. };
  713. /**
  714. * Set the minimum duration
  715. *
  716. * @api public
  717. */
  718. Backoff.prototype.setMin = function(min){
  719. this.ms = min;
  720. };
  721. /**
  722. * Set the maximum duration
  723. *
  724. * @api public
  725. */
  726. Backoff.prototype.setMax = function(max){
  727. this.max = max;
  728. };
  729. /**
  730. * Set the jitter
  731. *
  732. * @api public
  733. */
  734. Backoff.prototype.setJitter = function(jitter){
  735. this.jitter = jitter;
  736. };
  737. /***/ }),
  738. /* 4 */
  739. /***/ (function(module, exports, __webpack_require__) {
  740. "use strict";
  741. var has = Object.prototype.hasOwnProperty
  742. , prefix = '~';
  743. /**
  744. * Constructor to create a storage for our `EE` objects.
  745. * An `Events` instance is a plain object whose properties are event names.
  746. *
  747. * @constructor
  748. * @private
  749. */
  750. function Events() {}
  751. //
  752. // We try to not inherit from `Object.prototype`. In some engines creating an
  753. // instance in this way is faster than calling `Object.create(null)` directly.
  754. // If `Object.create(null)` is not supported we prefix the event names with a
  755. // character to make sure that the built-in object properties are not
  756. // overridden or used as an attack vector.
  757. //
  758. if (Object.create) {
  759. Events.prototype = Object.create(null);
  760. //
  761. // This hack is needed because the `__proto__` property is still inherited in
  762. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  763. //
  764. if (!new Events().__proto__) prefix = false;
  765. }
  766. /**
  767. * Representation of a single event listener.
  768. *
  769. * @param {Function} fn The listener function.
  770. * @param {*} context The context to invoke the listener with.
  771. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  772. * @constructor
  773. * @private
  774. */
  775. function EE(fn, context, once) {
  776. this.fn = fn;
  777. this.context = context;
  778. this.once = once || false;
  779. }
  780. /**
  781. * Add a listener for a given event.
  782. *
  783. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  784. * @param {(String|Symbol)} event The event name.
  785. * @param {Function} fn The listener function.
  786. * @param {*} context The context to invoke the listener with.
  787. * @param {Boolean} once Specify if the listener is a one-time listener.
  788. * @returns {EventEmitter}
  789. * @private
  790. */
  791. function addListener(emitter, event, fn, context, once) {
  792. if (typeof fn !== 'function') {
  793. throw new TypeError('The listener must be a function');
  794. }
  795. var listener = new EE(fn, context || emitter, once)
  796. , evt = prefix ? prefix + event : event;
  797. if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  798. else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  799. else emitter._events[evt] = [emitter._events[evt], listener];
  800. return emitter;
  801. }
  802. /**
  803. * Clear event by name.
  804. *
  805. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  806. * @param {(String|Symbol)} evt The Event name.
  807. * @private
  808. */
  809. function clearEvent(emitter, evt) {
  810. if (--emitter._eventsCount === 0) emitter._events = new Events();
  811. else delete emitter._events[evt];
  812. }
  813. /**
  814. * Minimal `EventEmitter` interface that is molded against the Node.js
  815. * `EventEmitter` interface.
  816. *
  817. * @constructor
  818. * @public
  819. */
  820. function EventEmitter() {
  821. this._events = new Events();
  822. this._eventsCount = 0;
  823. }
  824. /**
  825. * Return an array listing the events for which the emitter has registered
  826. * listeners.
  827. *
  828. * @returns {Array}
  829. * @public
  830. */
  831. EventEmitter.prototype.eventNames = function eventNames() {
  832. var names = []
  833. , events
  834. , name;
  835. if (this._eventsCount === 0) return names;
  836. for (name in (events = this._events)) {
  837. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  838. }
  839. if (Object.getOwnPropertySymbols) {
  840. return names.concat(Object.getOwnPropertySymbols(events));
  841. }
  842. return names;
  843. };
  844. /**
  845. * Return the listeners registered for a given event.
  846. *
  847. * @param {(String|Symbol)} event The event name.
  848. * @returns {Array} The registered listeners.
  849. * @public
  850. */
  851. EventEmitter.prototype.listeners = function listeners(event) {
  852. var evt = prefix ? prefix + event : event
  853. , handlers = this._events[evt];
  854. if (!handlers) return [];
  855. if (handlers.fn) return [handlers.fn];
  856. for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
  857. ee[i] = handlers[i].fn;
  858. }
  859. return ee;
  860. };
  861. /**
  862. * Return the number of listeners listening to a given event.
  863. *
  864. * @param {(String|Symbol)} event The event name.
  865. * @returns {Number} The number of listeners.
  866. * @public
  867. */
  868. EventEmitter.prototype.listenerCount = function listenerCount(event) {
  869. var evt = prefix ? prefix + event : event
  870. , listeners = this._events[evt];
  871. if (!listeners) return 0;
  872. if (listeners.fn) return 1;
  873. return listeners.length;
  874. };
  875. /**
  876. * Calls each of the listeners registered for a given event.
  877. *
  878. * @param {(String|Symbol)} event The event name.
  879. * @returns {Boolean} `true` if the event had listeners, else `false`.
  880. * @public
  881. */
  882. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  883. var evt = prefix ? prefix + event : event;
  884. if (!this._events[evt]) return false;
  885. var listeners = this._events[evt]
  886. , len = arguments.length
  887. , args
  888. , i;
  889. if (listeners.fn) {
  890. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  891. switch (len) {
  892. case 1: return listeners.fn.call(listeners.context), true;
  893. case 2: return listeners.fn.call(listeners.context, a1), true;
  894. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  895. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  896. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  897. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  898. }
  899. for (i = 1, args = new Array(len -1); i < len; i++) {
  900. args[i - 1] = arguments[i];
  901. }
  902. listeners.fn.apply(listeners.context, args);
  903. } else {
  904. var length = listeners.length
  905. , j;
  906. for (i = 0; i < length; i++) {
  907. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  908. switch (len) {
  909. case 1: listeners[i].fn.call(listeners[i].context); break;
  910. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  911. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  912. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  913. default:
  914. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  915. args[j - 1] = arguments[j];
  916. }
  917. listeners[i].fn.apply(listeners[i].context, args);
  918. }
  919. }
  920. }
  921. return true;
  922. };
  923. /**
  924. * Add a listener for a given event.
  925. *
  926. * @param {(String|Symbol)} event The event name.
  927. * @param {Function} fn The listener function.
  928. * @param {*} [context=this] The context to invoke the listener with.
  929. * @returns {EventEmitter} `this`.
  930. * @public
  931. */
  932. EventEmitter.prototype.on = function on(event, fn, context) {
  933. return addListener(this, event, fn, context, false);
  934. };
  935. /**
  936. * Add a one-time listener for a given event.
  937. *
  938. * @param {(String|Symbol)} event The event name.
  939. * @param {Function} fn The listener function.
  940. * @param {*} [context=this] The context to invoke the listener with.
  941. * @returns {EventEmitter} `this`.
  942. * @public
  943. */
  944. EventEmitter.prototype.once = function once(event, fn, context) {
  945. return addListener(this, event, fn, context, true);
  946. };
  947. /**
  948. * Remove the listeners of a given event.
  949. *
  950. * @param {(String|Symbol)} event The event name.
  951. * @param {Function} fn Only remove the listeners that match this function.
  952. * @param {*} context Only remove the listeners that have this context.
  953. * @param {Boolean} once Only remove one-time listeners.
  954. * @returns {EventEmitter} `this`.
  955. * @public
  956. */
  957. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  958. var evt = prefix ? prefix + event : event;
  959. if (!this._events[evt]) return this;
  960. if (!fn) {
  961. clearEvent(this, evt);
  962. return this;
  963. }
  964. var listeners = this._events[evt];
  965. if (listeners.fn) {
  966. if (
  967. listeners.fn === fn &&
  968. (!once || listeners.once) &&
  969. (!context || listeners.context === context)
  970. ) {
  971. clearEvent(this, evt);
  972. }
  973. } else {
  974. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  975. if (
  976. listeners[i].fn !== fn ||
  977. (once && !listeners[i].once) ||
  978. (context && listeners[i].context !== context)
  979. ) {
  980. events.push(listeners[i]);
  981. }
  982. }
  983. //
  984. // Reset the array, or remove it completely if we have no more listeners.
  985. //
  986. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  987. else clearEvent(this, evt);
  988. }
  989. return this;
  990. };
  991. /**
  992. * Remove all listeners, or those of the specified event.
  993. *
  994. * @param {(String|Symbol)} [event] The event name.
  995. * @returns {EventEmitter} `this`.
  996. * @public
  997. */
  998. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  999. var evt;
  1000. if (event) {
  1001. evt = prefix ? prefix + event : event;
  1002. if (this._events[evt]) clearEvent(this, evt);
  1003. } else {
  1004. this._events = new Events();
  1005. this._eventsCount = 0;
  1006. }
  1007. return this;
  1008. };
  1009. //
  1010. // Alias methods names because people roll like that.
  1011. //
  1012. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  1013. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  1014. //
  1015. // Expose the prefix.
  1016. //
  1017. EventEmitter.prefixed = prefix;
  1018. //
  1019. // Allow `EventEmitter` to be imported as module namespace.
  1020. //
  1021. EventEmitter.EventEmitter = EventEmitter;
  1022. //
  1023. // Expose the module.
  1024. //
  1025. if (true) {
  1026. module.exports = EventEmitter;
  1027. }
  1028. /***/ }),
  1029. /* 5 */
  1030. /***/ (function(module, exports, __webpack_require__) {
  1031. "use strict";
  1032. Object.defineProperty(exports, "__esModule", { value: true });
  1033. function isString(value) {
  1034. return typeof value === 'string';
  1035. }
  1036. exports.default = isString;
  1037. //# sourceMappingURL=is-string.js.map
  1038. /***/ }),
  1039. /* 6 */
  1040. /***/ (function(module, exports, __webpack_require__) {
  1041. "use strict";
  1042. Object.defineProperty(exports, "__esModule", { value: true });
  1043. function isObject(value) {
  1044. return ((value !== null) && (typeof value === 'object'));
  1045. }
  1046. exports.default = isObject;
  1047. //# sourceMappingURL=is-object.js.map
  1048. /***/ }),
  1049. /* 7 */
  1050. /***/ (function(module, exports, __webpack_require__) {
  1051. "use strict";
  1052. Object.defineProperty(exports, "__esModule", {
  1053. value: true
  1054. });
  1055. exports.print = print;
  1056. var _visitor = __webpack_require__(8);
  1057. var _blockString = __webpack_require__(13);
  1058. /**
  1059. * Converts an AST into a string, using one set of reasonable
  1060. * formatting rules.
  1061. */
  1062. function print(ast) {
  1063. return (0, _visitor.visit)(ast, {
  1064. leave: printDocASTReducer
  1065. });
  1066. }
  1067. var MAX_LINE_LENGTH = 80; // TODO: provide better type coverage in future
  1068. var printDocASTReducer = {
  1069. Name: function Name(node) {
  1070. return node.value;
  1071. },
  1072. Variable: function Variable(node) {
  1073. return '$' + node.name;
  1074. },
  1075. // Document
  1076. Document: function Document(node) {
  1077. return join(node.definitions, '\n\n') + '\n';
  1078. },
  1079. OperationDefinition: function OperationDefinition(node) {
  1080. var op = node.operation;
  1081. var name = node.name;
  1082. var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
  1083. var directives = join(node.directives, ' ');
  1084. var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
  1085. // the query short form.
  1086. return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
  1087. },
  1088. VariableDefinition: function VariableDefinition(_ref) {
  1089. var variable = _ref.variable,
  1090. type = _ref.type,
  1091. defaultValue = _ref.defaultValue,
  1092. directives = _ref.directives;
  1093. return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
  1094. },
  1095. SelectionSet: function SelectionSet(_ref2) {
  1096. var selections = _ref2.selections;
  1097. return block(selections);
  1098. },
  1099. Field: function Field(_ref3) {
  1100. var alias = _ref3.alias,
  1101. name = _ref3.name,
  1102. args = _ref3.arguments,
  1103. directives = _ref3.directives,
  1104. selectionSet = _ref3.selectionSet;
  1105. var prefix = wrap('', alias, ': ') + name;
  1106. var argsLine = prefix + wrap('(', join(args, ', '), ')');
  1107. if (argsLine.length > MAX_LINE_LENGTH) {
  1108. argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
  1109. }
  1110. return join([argsLine, join(directives, ' '), selectionSet], ' ');
  1111. },
  1112. Argument: function Argument(_ref4) {
  1113. var name = _ref4.name,
  1114. value = _ref4.value;
  1115. return name + ': ' + value;
  1116. },
  1117. // Fragments
  1118. FragmentSpread: function FragmentSpread(_ref5) {
  1119. var name = _ref5.name,
  1120. directives = _ref5.directives;
  1121. return '...' + name + wrap(' ', join(directives, ' '));
  1122. },
  1123. InlineFragment: function InlineFragment(_ref6) {
  1124. var typeCondition = _ref6.typeCondition,
  1125. directives = _ref6.directives,
  1126. selectionSet = _ref6.selectionSet;
  1127. return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
  1128. },
  1129. FragmentDefinition: function FragmentDefinition(_ref7) {
  1130. var name = _ref7.name,
  1131. typeCondition = _ref7.typeCondition,
  1132. variableDefinitions = _ref7.variableDefinitions,
  1133. directives = _ref7.directives,
  1134. selectionSet = _ref7.selectionSet;
  1135. return (// Note: fragment variable definitions are experimental and may be changed
  1136. // or removed in the future.
  1137. "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
  1138. );
  1139. },
  1140. // Value
  1141. IntValue: function IntValue(_ref8) {
  1142. var value = _ref8.value;
  1143. return value;
  1144. },
  1145. FloatValue: function FloatValue(_ref9) {
  1146. var value = _ref9.value;
  1147. return value;
  1148. },
  1149. StringValue: function StringValue(_ref10, key) {
  1150. var value = _ref10.value,
  1151. isBlockString = _ref10.block;
  1152. return isBlockString ? (0, _blockString.printBlockString)(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
  1153. },
  1154. BooleanValue: function BooleanValue(_ref11) {
  1155. var value = _ref11.value;
  1156. return value ? 'true' : 'false';
  1157. },
  1158. NullValue: function NullValue() {
  1159. return 'null';
  1160. },
  1161. EnumValue: function EnumValue(_ref12) {
  1162. var value = _ref12.value;
  1163. return value;
  1164. },
  1165. ListValue: function ListValue(_ref13) {
  1166. var values = _ref13.values;
  1167. return '[' + join(values, ', ') + ']';
  1168. },
  1169. ObjectValue: function ObjectValue(_ref14) {
  1170. var fields = _ref14.fields;
  1171. return '{' + join(fields, ', ') + '}';
  1172. },
  1173. ObjectField: function ObjectField(_ref15) {
  1174. var name = _ref15.name,
  1175. value = _ref15.value;
  1176. return name + ': ' + value;
  1177. },
  1178. // Directive
  1179. Directive: function Directive(_ref16) {
  1180. var name = _ref16.name,
  1181. args = _ref16.arguments;
  1182. return '@' + name + wrap('(', join(args, ', '), ')');
  1183. },
  1184. // Type
  1185. NamedType: function NamedType(_ref17) {
  1186. var name = _ref17.name;
  1187. return name;
  1188. },
  1189. ListType: function ListType(_ref18) {
  1190. var type = _ref18.type;
  1191. return '[' + type + ']';
  1192. },
  1193. NonNullType: function NonNullType(_ref19) {
  1194. var type = _ref19.type;
  1195. return type + '!';
  1196. },
  1197. // Type System Definitions
  1198. SchemaDefinition: addDescription(function (_ref20) {
  1199. var directives = _ref20.directives,
  1200. operationTypes = _ref20.operationTypes;
  1201. return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
  1202. }),
  1203. OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
  1204. var operation = _ref21.operation,
  1205. type = _ref21.type;
  1206. return operation + ': ' + type;
  1207. },
  1208. ScalarTypeDefinition: addDescription(function (_ref22) {
  1209. var name = _ref22.name,
  1210. directives = _ref22.directives;
  1211. return join(['scalar', name, join(directives, ' ')], ' ');
  1212. }),
  1213. ObjectTypeDefinition: addDescription(function (_ref23) {
  1214. var name = _ref23.name,
  1215. interfaces = _ref23.interfaces,
  1216. directives = _ref23.directives,
  1217. fields = _ref23.fields;
  1218. return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  1219. }),
  1220. FieldDefinition: addDescription(function (_ref24) {
  1221. var name = _ref24.name,
  1222. args = _ref24.arguments,
  1223. type = _ref24.type,
  1224. directives = _ref24.directives;
  1225. return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
  1226. }),
  1227. InputValueDefinition: addDescription(function (_ref25) {
  1228. var name = _ref25.name,
  1229. type = _ref25.type,
  1230. defaultValue = _ref25.defaultValue,
  1231. directives = _ref25.directives;
  1232. return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
  1233. }),
  1234. InterfaceTypeDefinition: addDescription(function (_ref26) {
  1235. var name = _ref26.name,
  1236. interfaces = _ref26.interfaces,
  1237. directives = _ref26.directives,
  1238. fields = _ref26.fields;
  1239. return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  1240. }),
  1241. UnionTypeDefinition: addDescription(function (_ref27) {
  1242. var name = _ref27.name,
  1243. directives = _ref27.directives,
  1244. types = _ref27.types;
  1245. return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  1246. }),
  1247. EnumTypeDefinition: addDescription(function (_ref28) {
  1248. var name = _ref28.name,
  1249. directives = _ref28.directives,
  1250. values = _ref28.values;
  1251. return join(['enum', name, join(directives, ' '), block(values)], ' ');
  1252. }),
  1253. EnumValueDefinition: addDescription(function (_ref29) {
  1254. var name = _ref29.name,
  1255. directives = _ref29.directives;
  1256. return join([name, join(directives, ' ')], ' ');
  1257. }),
  1258. InputObjectTypeDefinition: addDescription(function (_ref30) {
  1259. var name = _ref30.name,
  1260. directives = _ref30.directives,
  1261. fields = _ref30.fields;
  1262. return join(['input', name, join(directives, ' '), block(fields)], ' ');
  1263. }),
  1264. DirectiveDefinition: addDescription(function (_ref31) {
  1265. var name = _ref31.name,
  1266. args = _ref31.arguments,
  1267. repeatable = _ref31.repeatable,
  1268. locations = _ref31.locations;
  1269. return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + (repeatable ? ' repeatable' : '') + ' on ' + join(locations, ' | ');
  1270. }),
  1271. SchemaExtension: function SchemaExtension(_ref32) {
  1272. var directives = _ref32.directives,
  1273. operationTypes = _ref32.operationTypes;
  1274. return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
  1275. },
  1276. ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
  1277. var name = _ref33.name,
  1278. directives = _ref33.directives;
  1279. return join(['extend scalar', name, join(directives, ' ')], ' ');
  1280. },
  1281. ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
  1282. var name = _ref34.name,
  1283. interfaces = _ref34.interfaces,
  1284. directives = _ref34.directives,
  1285. fields = _ref34.fields;
  1286. return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  1287. },
  1288. InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
  1289. var name = _ref35.name,
  1290. interfaces = _ref35.interfaces,
  1291. directives = _ref35.directives,
  1292. fields = _ref35.fields;
  1293. return join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  1294. },
  1295. UnionTypeExtension: function UnionTypeExtension(_ref36) {
  1296. var name = _ref36.name,
  1297. directives = _ref36.directives,
  1298. types = _ref36.types;
  1299. return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  1300. },
  1301. EnumTypeExtension: function EnumTypeExtension(_ref37) {
  1302. var name = _ref37.name,
  1303. directives = _ref37.directives,
  1304. values = _ref37.values;
  1305. return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
  1306. },
  1307. InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
  1308. var name = _ref38.name,
  1309. directives = _ref38.directives,
  1310. fields = _ref38.fields;
  1311. return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
  1312. }
  1313. };
  1314. function addDescription(cb) {
  1315. return function (node) {
  1316. return join([node.description, cb(node)], '\n');
  1317. };
  1318. }
  1319. /**
  1320. * Given maybeArray, print an empty string if it is null or empty, otherwise
  1321. * print all items together separated by separator if provided
  1322. */
  1323. function join(maybeArray) {
  1324. var _maybeArray$filter$jo;
  1325. var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1326. return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter(function (x) {
  1327. return x;
  1328. }).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : '';
  1329. }
  1330. /**
  1331. * Given array, print each item on its own line, wrapped in an
  1332. * indented "{ }" block.
  1333. */
  1334. function block(array) {
  1335. return wrap('{\n', indent(join(array, '\n')), '\n}');
  1336. }
  1337. /**
  1338. * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string.
  1339. */
  1340. function wrap(start, maybeString) {
  1341. var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  1342. return maybeString != null && maybeString !== '' ? start + maybeString + end : '';
  1343. }
  1344. function indent(str) {
  1345. return wrap(' ', str.replace(/\n/g, '\n '));
  1346. }
  1347. function isMultiline(str) {
  1348. return str.indexOf('\n') !== -1;
  1349. }
  1350. function hasMultilineItems(maybeArray) {
  1351. return maybeArray != null && maybeArray.some(isMultiline);
  1352. }
  1353. /***/ }),
  1354. /* 8 */
  1355. /***/ (function(module, exports, __webpack_require__) {
  1356. "use strict";
  1357. Object.defineProperty(exports, "__esModule", {
  1358. value: true
  1359. });
  1360. exports.visit = visit;
  1361. exports.visitInParallel = visitInParallel;
  1362. exports.getVisitFn = getVisitFn;
  1363. exports.BREAK = exports.QueryDocumentKeys = void 0;
  1364. var _inspect = _interopRequireDefault(__webpack_require__(9));
  1365. var _ast = __webpack_require__(10);
  1366. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1367. var QueryDocumentKeys = {
  1368. Name: [],
  1369. Document: ['definitions'],
  1370. OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
  1371. VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
  1372. Variable: ['name'],
  1373. SelectionSet: ['selections'],
  1374. Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
  1375. Argument: ['name', 'value'],
  1376. FragmentSpread: ['name', 'directives'],
  1377. InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
  1378. FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed
  1379. // or removed in the future.
  1380. 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],
  1381. IntValue: [],
  1382. FloatValue: [],
  1383. StringValue: [],
  1384. BooleanValue: [],
  1385. NullValue: [],
  1386. EnumValue: [],
  1387. ListValue: ['values'],
  1388. ObjectValue: ['fields'],
  1389. ObjectField: ['name', 'value'],
  1390. Directive: ['name', 'arguments'],
  1391. NamedType: ['name'],
  1392. ListType: ['type'],
  1393. NonNullType: ['type'],
  1394. SchemaDefinition: ['description', 'directives', 'operationTypes'],
  1395. OperationTypeDefinition: ['type'],
  1396. ScalarTypeDefinition: ['description', 'name', 'directives'],
  1397. ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
  1398. FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
  1399. InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],
  1400. InterfaceTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
  1401. UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
  1402. EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
  1403. EnumValueDefinition: ['description', 'name', 'directives'],
  1404. InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
  1405. DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
  1406. SchemaExtension: ['directives', 'operationTypes'],
  1407. ScalarTypeExtension: ['name', 'directives'],
  1408. ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  1409. InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  1410. UnionTypeExtension: ['name', 'directives', 'types'],
  1411. EnumTypeExtension: ['name', 'directives', 'values'],
  1412. InputObjectTypeExtension: ['name', 'directives', 'fields']
  1413. };
  1414. exports.QueryDocumentKeys = QueryDocumentKeys;
  1415. var BREAK = Object.freeze({});
  1416. /**
  1417. * visit() will walk through an AST using a depth-first traversal, calling
  1418. * the visitor's enter function at each node in the traversal, and calling the
  1419. * leave function after visiting that node and all of its child nodes.
  1420. *
  1421. * By returning different values from the enter and leave functions, the
  1422. * behavior of the visitor can be altered, including skipping over a sub-tree of
  1423. * the AST (by returning false), editing the AST by returning a value or null
  1424. * to remove the value, or to stop the whole traversal by returning BREAK.
  1425. *
  1426. * When using visit() to edit an AST, the original AST will not be modified, and
  1427. * a new version of the AST with the changes applied will be returned from the
  1428. * visit function.
  1429. *
  1430. * const editedAST = visit(ast, {
  1431. * enter(node, key, parent, path, ancestors) {
  1432. * // @return
  1433. * // undefined: no action
  1434. * // false: skip visiting this node
  1435. * // visitor.BREAK: stop visiting altogether
  1436. * // null: delete this node
  1437. * // any value: replace this node with the returned value
  1438. * },
  1439. * leave(node, key, parent, path, ancestors) {
  1440. * // @return
  1441. * // undefined: no action
  1442. * // false: no action
  1443. * // visitor.BREAK: stop visiting altogether
  1444. * // null: delete this node
  1445. * // any value: replace this node with the returned value
  1446. * }
  1447. * });
  1448. *
  1449. * Alternatively to providing enter() and leave() functions, a visitor can
  1450. * instead provide functions named the same as the kinds of AST nodes, or
  1451. * enter/leave visitors at a named key, leading to four permutations of the
  1452. * visitor API:
  1453. *
  1454. * 1) Named visitors triggered when entering a node of a specific kind.
  1455. *
  1456. * visit(ast, {
  1457. * Kind(node) {
  1458. * // enter the "Kind" node
  1459. * }
  1460. * })
  1461. *
  1462. * 2) Named visitors that trigger upon entering and leaving a node of
  1463. * a specific kind.
  1464. *
  1465. * visit(ast, {
  1466. * Kind: {
  1467. * enter(node) {
  1468. * // enter the "Kind" node
  1469. * }
  1470. * leave(node) {
  1471. * // leave the "Kind" node
  1472. * }
  1473. * }
  1474. * })
  1475. *
  1476. * 3) Generic visitors that trigger upon entering and leaving any node.
  1477. *
  1478. * visit(ast, {
  1479. * enter(node) {
  1480. * // enter any node
  1481. * },
  1482. * leave(node) {
  1483. * // leave any node
  1484. * }
  1485. * })
  1486. *
  1487. * 4) Parallel visitors for entering and leaving nodes of a specific kind.
  1488. *
  1489. * visit(ast, {
  1490. * enter: {
  1491. * Kind(node) {
  1492. * // enter the "Kind" node
  1493. * }
  1494. * },
  1495. * leave: {
  1496. * Kind(node) {
  1497. * // leave the "Kind" node
  1498. * }
  1499. * }
  1500. * })
  1501. */
  1502. exports.BREAK = BREAK;
  1503. function visit(root, visitor) {
  1504. var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
  1505. /* eslint-disable no-undef-init */
  1506. var stack = undefined;
  1507. var inArray = Array.isArray(root);
  1508. var keys = [root];
  1509. var index = -1;
  1510. var edits = [];
  1511. var node = undefined;
  1512. var key = undefined;
  1513. var parent = undefined;
  1514. var path = [];
  1515. var ancestors = [];
  1516. var newRoot = root;
  1517. /* eslint-enable no-undef-init */
  1518. do {
  1519. index++;
  1520. var isLeaving = index === keys.length;
  1521. var isEdited = isLeaving && edits.length !== 0;
  1522. if (isLeaving) {
  1523. key = ancestors.length === 0 ? undefined : path[path.length - 1];
  1524. node = parent;
  1525. parent = ancestors.pop();
  1526. if (isEdited) {
  1527. if (inArray) {
  1528. node = node.slice();
  1529. } else {
  1530. var clone = {};
  1531. for (var _i2 = 0, _Object$keys2 = Object.keys(node); _i2 < _Object$keys2.length; _i2++) {
  1532. var k = _Object$keys2[_i2];
  1533. clone[k] = node[k];
  1534. }
  1535. node = clone;
  1536. }
  1537. var editOffset = 0;
  1538. for (var ii = 0; ii < edits.length; ii++) {
  1539. var editKey = edits[ii][0];
  1540. var editValue = edits[ii][1];
  1541. if (inArray) {
  1542. editKey -= editOffset;
  1543. }
  1544. if (inArray && editValue === null) {
  1545. node.splice(editKey, 1);
  1546. editOffset++;
  1547. } else {
  1548. node[editKey] = editValue;
  1549. }
  1550. }
  1551. }
  1552. index = stack.index;
  1553. keys = stack.keys;
  1554. edits = stack.edits;
  1555. inArray = stack.inArray;
  1556. stack = stack.prev;
  1557. } else {
  1558. key = parent ? inArray ? index : keys[index] : undefined;
  1559. node = parent ? parent[key] : newRoot;
  1560. if (node === null || node === undefined) {
  1561. continue;
  1562. }
  1563. if (parent) {
  1564. path.push(key);
  1565. }
  1566. }
  1567. var result = void 0;
  1568. if (!Array.isArray(node)) {
  1569. if (!(0, _ast.isNode)(node)) {
  1570. throw new Error("Invalid AST Node: ".concat((0, _inspect.default)(node), "."));
  1571. }
  1572. var visitFn = getVisitFn(visitor, node.kind, isLeaving);
  1573. if (visitFn) {
  1574. result = visitFn.call(visitor, node, key, parent, path, ancestors);
  1575. if (result === BREAK) {
  1576. break;
  1577. }
  1578. if (result === false) {
  1579. if (!isLeaving) {
  1580. path.pop();
  1581. continue;
  1582. }
  1583. } else if (result !== undefined) {
  1584. edits.push([key, result]);
  1585. if (!isLeaving) {
  1586. if ((0, _ast.isNode)(result)) {
  1587. node = result;
  1588. } else {
  1589. path.pop();
  1590. continue;
  1591. }
  1592. }
  1593. }
  1594. }
  1595. }
  1596. if (result === undefined && isEdited) {
  1597. edits.push([key, node]);
  1598. }
  1599. if (isLeaving) {
  1600. path.pop();
  1601. } else {
  1602. var _visitorKeys$node$kin;
  1603. stack = {
  1604. inArray: inArray,
  1605. index: index,
  1606. keys: keys,
  1607. edits: edits,
  1608. prev: stack
  1609. };
  1610. inArray = Array.isArray(node);
  1611. keys = inArray ? node : (_visitorKeys$node$kin = visitorKeys[node.kind]) !== null && _visitorKeys$node$kin !== void 0 ? _visitorKeys$node$kin : [];
  1612. index = -1;
  1613. edits = [];
  1614. if (parent) {
  1615. ancestors.push(parent);
  1616. }
  1617. parent = node;
  1618. }
  1619. } while (stack !== undefined);
  1620. if (edits.length !== 0) {
  1621. newRoot = edits[edits.length - 1][1];
  1622. }
  1623. return newRoot;
  1624. }
  1625. /**
  1626. * Creates a new visitor instance which delegates to many visitors to run in
  1627. * parallel. Each visitor will be visited for each node before moving on.
  1628. *
  1629. * If a prior visitor edits a node, no following visitors will see that node.
  1630. */
  1631. function visitInParallel(visitors) {
  1632. var skipping = new Array(visitors.length);
  1633. return {
  1634. enter: function enter(node) {
  1635. for (var i = 0; i < visitors.length; i++) {
  1636. if (skipping[i] == null) {
  1637. var fn = getVisitFn(visitors[i], node.kind,
  1638. /* isLeaving */
  1639. false);
  1640. if (fn) {
  1641. var result = fn.apply(visitors[i], arguments);
  1642. if (result === false) {
  1643. skipping[i] = node;
  1644. } else if (result === BREAK) {
  1645. skipping[i] = BREAK;
  1646. } else if (result !== undefined) {
  1647. return result;
  1648. }
  1649. }
  1650. }
  1651. }
  1652. },
  1653. leave: function leave(node) {
  1654. for (var i = 0; i < visitors.length; i++) {
  1655. if (skipping[i] == null) {
  1656. var fn = getVisitFn(visitors[i], node.kind,
  1657. /* isLeaving */
  1658. true);
  1659. if (fn) {
  1660. var result = fn.apply(visitors[i], arguments);
  1661. if (result === BREAK) {
  1662. skipping[i] = BREAK;
  1663. } else if (result !== undefined && result !== false) {
  1664. return result;
  1665. }
  1666. }
  1667. } else if (skipping[i] === node) {
  1668. skipping[i] = null;
  1669. }
  1670. }
  1671. }
  1672. };
  1673. }
  1674. /**
  1675. * Given a visitor instance, if it is leaving or not, and a node kind, return
  1676. * the function the visitor runtime should call.
  1677. */
  1678. function getVisitFn(visitor, kind, isLeaving) {
  1679. var kindVisitor = visitor[kind];
  1680. if (kindVisitor) {
  1681. if (!isLeaving && typeof kindVisitor === 'function') {
  1682. // { Kind() {} }
  1683. return kindVisitor;
  1684. }
  1685. var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
  1686. if (typeof kindSpecificVisitor === 'function') {
  1687. // { Kind: { enter() {}, leave() {} } }
  1688. return kindSpecificVisitor;
  1689. }
  1690. } else {
  1691. var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
  1692. if (specificVisitor) {
  1693. if (typeof specificVisitor === 'function') {
  1694. // { enter() {}, leave() {} }
  1695. return specificVisitor;
  1696. }
  1697. var specificKindVisitor = specificVisitor[kind];
  1698. if (typeof specificKindVisitor === 'function') {
  1699. // { enter: { Kind() {} }, leave: { Kind() {} } }
  1700. return specificKindVisitor;
  1701. }
  1702. }
  1703. }
  1704. }
  1705. /***/ }),
  1706. /* 9 */
  1707. /***/ (function(module, exports, __webpack_require__) {
  1708. "use strict";
  1709. Object.defineProperty(exports, "__esModule", {
  1710. value: true
  1711. });
  1712. exports.default = inspect;
  1713. var _nodejsCustomInspectSymbol = _interopRequireDefault(__webpack_require__(1));
  1714. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1715. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1716. var MAX_ARRAY_LENGTH = 10;
  1717. var MAX_RECURSIVE_DEPTH = 2;
  1718. /**
  1719. * Used to print values in error messages.
  1720. */
  1721. function inspect(value) {
  1722. return formatValue(value, []);
  1723. }
  1724. function formatValue(value, seenValues) {
  1725. switch (_typeof(value)) {
  1726. case 'string':
  1727. return JSON.stringify(value);
  1728. case 'function':
  1729. return value.name ? "[function ".concat(value.name, "]") : '[function]';
  1730. case 'object':
  1731. if (value === null) {
  1732. return 'null';
  1733. }
  1734. return formatObjectValue(value, seenValues);
  1735. default:
  1736. return String(value);
  1737. }
  1738. }
  1739. function formatObjectValue(value, previouslySeenValues) {
  1740. if (previouslySeenValues.indexOf(value) !== -1) {
  1741. return '[Circular]';
  1742. }
  1743. var seenValues = [].concat(previouslySeenValues, [value]);
  1744. var customInspectFn = getCustomFn(value);
  1745. if (customInspectFn !== undefined) {
  1746. var customValue = customInspectFn.call(value); // check for infinite recursion
  1747. if (customValue !== value) {
  1748. return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
  1749. }
  1750. } else if (Array.isArray(value)) {
  1751. return formatArray(value, seenValues);
  1752. }
  1753. return formatObject(value, seenValues);
  1754. }
  1755. function formatObject(object, seenValues) {
  1756. var keys = Object.keys(object);
  1757. if (keys.length === 0) {
  1758. return '{}';
  1759. }
  1760. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  1761. return '[' + getObjectTag(object) + ']';
  1762. }
  1763. var properties = keys.map(function (key) {
  1764. var value = formatValue(object[key], seenValues);
  1765. return key + ': ' + value;
  1766. });
  1767. return '{ ' + properties.join(', ') + ' }';
  1768. }
  1769. function formatArray(array, seenValues) {
  1770. if (array.length === 0) {
  1771. return '[]';
  1772. }
  1773. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  1774. return '[Array]';
  1775. }
  1776. var len = Math.min(MAX_ARRAY_LENGTH, array.length);
  1777. var remaining = array.length - len;
  1778. var items = [];
  1779. for (var i = 0; i < len; ++i) {
  1780. items.push(formatValue(array[i], seenValues));
  1781. }
  1782. if (remaining === 1) {
  1783. items.push('... 1 more item');
  1784. } else if (remaining > 1) {
  1785. items.push("... ".concat(remaining, " more items"));
  1786. }
  1787. return '[' + items.join(', ') + ']';
  1788. }
  1789. function getCustomFn(object) {
  1790. var customInspectFn = object[String(_nodejsCustomInspectSymbol.default)];
  1791. if (typeof customInspectFn === 'function') {
  1792. return customInspectFn;
  1793. }
  1794. if (typeof object.inspect === 'function') {
  1795. return object.inspect;
  1796. }
  1797. }
  1798. function getObjectTag(object) {
  1799. var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
  1800. if (tag === 'Object' && typeof object.constructor === 'function') {
  1801. var name = object.constructor.name;
  1802. if (typeof name === 'string' && name !== '') {
  1803. return name;
  1804. }
  1805. }
  1806. return tag;
  1807. }
  1808. /***/ }),
  1809. /* 10 */
  1810. /***/ (function(module, exports, __webpack_require__) {
  1811. "use strict";
  1812. Object.defineProperty(exports, "__esModule", {
  1813. value: true
  1814. });
  1815. exports.isNode = isNode;
  1816. exports.Token = exports.Location = void 0;
  1817. var _defineInspect = _interopRequireDefault(__webpack_require__(11));
  1818. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1819. /**
  1820. * Contains a range of UTF-8 character offsets and token references that
  1821. * identify the region of the source from which the AST derived.
  1822. */
  1823. var Location = /*#__PURE__*/function () {
  1824. /**
  1825. * The character offset at which this Node begins.
  1826. */
  1827. /**
  1828. * The character offset at which this Node ends.
  1829. */
  1830. /**
  1831. * The Token at which this Node begins.
  1832. */
  1833. /**
  1834. * The Token at which this Node ends.
  1835. */
  1836. /**
  1837. * The Source document the AST represents.
  1838. */
  1839. function Location(startToken, endToken, source) {
  1840. this.start = startToken.start;
  1841. this.end = endToken.end;
  1842. this.startToken = startToken;
  1843. this.endToken = endToken;
  1844. this.source = source;
  1845. }
  1846. var _proto = Location.prototype;
  1847. _proto.toJSON = function toJSON() {
  1848. return {
  1849. start: this.start,
  1850. end: this.end
  1851. };
  1852. };
  1853. return Location;
  1854. }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
  1855. exports.Location = Location;
  1856. (0, _defineInspect.default)(Location);
  1857. /**
  1858. * Represents a range of characters represented by a lexical token
  1859. * within a Source.
  1860. */
  1861. var Token = /*#__PURE__*/function () {
  1862. /**
  1863. * The kind of Token.
  1864. */
  1865. /**
  1866. * The character offset at which this Node begins.
  1867. */
  1868. /**
  1869. * The character offset at which this Node ends.
  1870. */
  1871. /**
  1872. * The 1-indexed line number on which this Token appears.
  1873. */
  1874. /**
  1875. * The 1-indexed column number at which this Token begins.
  1876. */
  1877. /**
  1878. * For non-punctuation tokens, represents the interpreted value of the token.
  1879. */
  1880. /**
  1881. * Tokens exist as nodes in a double-linked-list amongst all tokens
  1882. * including ignored tokens. <SOF> is always the first node and <EOF>
  1883. * the last.
  1884. */
  1885. function Token(kind, start, end, line, column, prev, value) {
  1886. this.kind = kind;
  1887. this.start = start;
  1888. this.end = end;
  1889. this.line = line;
  1890. this.column = column;
  1891. this.value = value;
  1892. this.prev = prev;
  1893. this.next = null;
  1894. }
  1895. var _proto2 = Token.prototype;
  1896. _proto2.toJSON = function toJSON() {
  1897. return {
  1898. kind: this.kind,
  1899. value: this.value,
  1900. line: this.line,
  1901. column: this.column
  1902. };
  1903. };
  1904. return Token;
  1905. }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
  1906. exports.Token = Token;
  1907. (0, _defineInspect.default)(Token);
  1908. /**
  1909. * @internal
  1910. */
  1911. function isNode(maybeNode) {
  1912. return maybeNode != null && typeof maybeNode.kind === 'string';
  1913. }
  1914. /**
  1915. * The list of all possible AST node types.
  1916. */
  1917. /***/ }),
  1918. /* 11 */
  1919. /***/ (function(module, exports, __webpack_require__) {
  1920. "use strict";
  1921. Object.defineProperty(exports, "__esModule", {
  1922. value: true
  1923. });
  1924. exports.default = defineInspect;
  1925. var _invariant = _interopRequireDefault(__webpack_require__(12));
  1926. var _nodejsCustomInspectSymbol = _interopRequireDefault(__webpack_require__(1));
  1927. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1928. /**
  1929. * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
  1930. */
  1931. function defineInspect(classObject) {
  1932. var fn = classObject.prototype.toJSON;
  1933. typeof fn === 'function' || (0, _invariant.default)(0);
  1934. classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
  1935. if (_nodejsCustomInspectSymbol.default) {
  1936. classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
  1937. }
  1938. }
  1939. /***/ }),
  1940. /* 12 */
  1941. /***/ (function(module, exports, __webpack_require__) {
  1942. "use strict";
  1943. Object.defineProperty(exports, "__esModule", {
  1944. value: true
  1945. });
  1946. exports.default = invariant;
  1947. function invariant(condition, message) {
  1948. var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
  1949. if (!booleanCondition) {
  1950. throw new Error(message != null ? message : 'Unexpected invariant triggered.');
  1951. }
  1952. }
  1953. /***/ }),
  1954. /* 13 */
  1955. /***/ (function(module, exports, __webpack_require__) {
  1956. "use strict";
  1957. Object.defineProperty(exports, "__esModule", {
  1958. value: true
  1959. });
  1960. exports.dedentBlockStringValue = dedentBlockStringValue;
  1961. exports.getBlockStringIndentation = getBlockStringIndentation;
  1962. exports.printBlockString = printBlockString;
  1963. /**
  1964. * Produces the value of a block string from its parsed raw value, similar to
  1965. * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
  1966. *
  1967. * This implements the GraphQL spec's BlockStringValue() static algorithm.
  1968. *
  1969. * @internal
  1970. */
  1971. function dedentBlockStringValue(rawString) {
  1972. // Expand a block string's raw value into independent lines.
  1973. var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
  1974. var commonIndent = getBlockStringIndentation(rawString);
  1975. if (commonIndent !== 0) {
  1976. for (var i = 1; i < lines.length; i++) {
  1977. lines[i] = lines[i].slice(commonIndent);
  1978. }
  1979. } // Remove leading and trailing blank lines.
  1980. var startLine = 0;
  1981. while (startLine < lines.length && isBlank(lines[startLine])) {
  1982. ++startLine;
  1983. }
  1984. var endLine = lines.length;
  1985. while (endLine > startLine && isBlank(lines[endLine - 1])) {
  1986. --endLine;
  1987. } // Return a string of the lines joined with U+000A.
  1988. return lines.slice(startLine, endLine).join('\n');
  1989. }
  1990. function isBlank(str) {
  1991. for (var i = 0; i < str.length; ++i) {
  1992. if (str[i] !== ' ' && str[i] !== '\t') {
  1993. return false;
  1994. }
  1995. }
  1996. return true;
  1997. }
  1998. /**
  1999. * @internal
  2000. */
  2001. function getBlockStringIndentation(value) {
  2002. var _commonIndent;
  2003. var isFirstLine = true;
  2004. var isEmptyLine = true;
  2005. var indent = 0;
  2006. var commonIndent = null;
  2007. for (var i = 0; i < value.length; ++i) {
  2008. switch (value.charCodeAt(i)) {
  2009. case 13:
  2010. // \r
  2011. if (value.charCodeAt(i + 1) === 10) {
  2012. ++i; // skip \r\n as one symbol
  2013. }
  2014. // falls through
  2015. case 10:
  2016. // \n
  2017. isFirstLine = false;
  2018. isEmptyLine = true;
  2019. indent = 0;
  2020. break;
  2021. case 9: // \t
  2022. case 32:
  2023. // <space>
  2024. ++indent;
  2025. break;
  2026. default:
  2027. if (isEmptyLine && !isFirstLine && (commonIndent === null || indent < commonIndent)) {
  2028. commonIndent = indent;
  2029. }
  2030. isEmptyLine = false;
  2031. }
  2032. }
  2033. return (_commonIndent = commonIndent) !== null && _commonIndent !== void 0 ? _commonIndent : 0;
  2034. }
  2035. /**
  2036. * Print a block string in the indented block form by adding a leading and
  2037. * trailing blank line. However, if a block string starts with whitespace and is
  2038. * a single-line, adding a leading blank line would strip that whitespace.
  2039. *
  2040. * @internal
  2041. */
  2042. function printBlockString(value) {
  2043. var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  2044. var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2045. var isSingleLine = value.indexOf('\n') === -1;
  2046. var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
  2047. var hasTrailingQuote = value[value.length - 1] === '"';
  2048. var hasTrailingSlash = value[value.length - 1] === '\\';
  2049. var printAsMultipleLines = !isSingleLine || hasTrailingQuote || hasTrailingSlash || preferMultipleLines;
  2050. var result = ''; // Format a multi-line block quote to account for leading space.
  2051. if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
  2052. result += '\n' + indentation;
  2053. }
  2054. result += indentation ? value.replace(/\n/g, '\n' + indentation) : value;
  2055. if (printAsMultipleLines) {
  2056. result += '\n';
  2057. }
  2058. return '"""' + result.replace(/"""/g, '\\"""') + '"""';
  2059. }
  2060. /***/ }),
  2061. /* 14 */
  2062. /***/ (function(module, exports, __webpack_require__) {
  2063. "use strict";
  2064. Object.defineProperty(exports, "__esModule", {
  2065. value: true
  2066. });
  2067. exports.getOperationAST = getOperationAST;
  2068. var _kinds = __webpack_require__(15);
  2069. /**
  2070. * Returns an operation AST given a document AST and optionally an operation
  2071. * name. If a name is not provided, an operation is only returned if only one is
  2072. * provided in the document.
  2073. */
  2074. function getOperationAST(documentAST, operationName) {
  2075. var operation = null;
  2076. for (var _i2 = 0, _documentAST$definiti2 = documentAST.definitions; _i2 < _documentAST$definiti2.length; _i2++) {
  2077. var definition = _documentAST$definiti2[_i2];
  2078. if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
  2079. var _definition$name;
  2080. if (operationName == null) {
  2081. // If no operation name was provided, only return an Operation if there
  2082. // is one defined in the document. Upon encountering the second, return
  2083. // null.
  2084. if (operation) {
  2085. return null;
  2086. }
  2087. operation = definition;
  2088. } else if (((_definition$name = definition.name) === null || _definition$name === void 0 ? void 0 : _definition$name.value) === operationName) {
  2089. return definition;
  2090. }
  2091. }
  2092. }
  2093. return operation;
  2094. }
  2095. /***/ }),
  2096. /* 15 */
  2097. /***/ (function(module, exports, __webpack_require__) {
  2098. "use strict";
  2099. Object.defineProperty(exports, "__esModule", {
  2100. value: true
  2101. });
  2102. exports.Kind = void 0;
  2103. /**
  2104. * The set of allowed kind values for AST nodes.
  2105. */
  2106. var Kind = Object.freeze({
  2107. // Name
  2108. NAME: 'Name',
  2109. // Document
  2110. DOCUMENT: 'Document',
  2111. OPERATION_DEFINITION: 'OperationDefinition',
  2112. VARIABLE_DEFINITION: 'VariableDefinition',
  2113. SELECTION_SET: 'SelectionSet',
  2114. FIELD: 'Field',
  2115. ARGUMENT: 'Argument',
  2116. // Fragments
  2117. FRAGMENT_SPREAD: 'FragmentSpread',
  2118. INLINE_FRAGMENT: 'InlineFragment',
  2119. FRAGMENT_DEFINITION: 'FragmentDefinition',
  2120. // Values
  2121. VARIABLE: 'Variable',
  2122. INT: 'IntValue',
  2123. FLOAT: 'FloatValue',
  2124. STRING: 'StringValue',
  2125. BOOLEAN: 'BooleanValue',
  2126. NULL: 'NullValue',
  2127. ENUM: 'EnumValue',
  2128. LIST: 'ListValue',
  2129. OBJECT: 'ObjectValue',
  2130. OBJECT_FIELD: 'ObjectField',
  2131. // Directives
  2132. DIRECTIVE: 'Directive',
  2133. // Types
  2134. NAMED_TYPE: 'NamedType',
  2135. LIST_TYPE: 'ListType',
  2136. NON_NULL_TYPE: 'NonNullType',
  2137. // Type System Definitions
  2138. SCHEMA_DEFINITION: 'SchemaDefinition',
  2139. OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
  2140. // Type Definitions
  2141. SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
  2142. OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
  2143. FIELD_DEFINITION: 'FieldDefinition',
  2144. INPUT_VALUE_DEFINITION: 'InputValueDefinition',
  2145. INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
  2146. UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
  2147. ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
  2148. ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
  2149. INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
  2150. // Directive Definitions
  2151. DIRECTIVE_DEFINITION: 'DirectiveDefinition',
  2152. // Type System Extensions
  2153. SCHEMA_EXTENSION: 'SchemaExtension',
  2154. // Type Extensions
  2155. SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
  2156. OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
  2157. INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
  2158. UNION_TYPE_EXTENSION: 'UnionTypeExtension',
  2159. ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
  2160. INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
  2161. });
  2162. /**
  2163. * The enum type representing the possible kind values of AST nodes.
  2164. */
  2165. exports.Kind = Kind;
  2166. /***/ }),
  2167. /* 16 */
  2168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2169. "use strict";
  2170. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  2171. /* WEBPACK VAR INJECTION */(function(global, module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ponyfill_js__ = __webpack_require__(18);
  2172. /* global window */
  2173. var root;
  2174. if (typeof self !== 'undefined') {
  2175. root = self;
  2176. } else if (typeof window !== 'undefined') {
  2177. root = window;
  2178. } else if (typeof global !== 'undefined') {
  2179. root = global;
  2180. } else if (true) {
  2181. root = module;
  2182. } else {
  2183. root = Function('return this')();
  2184. }
  2185. var result = Object(__WEBPACK_IMPORTED_MODULE_0__ponyfill_js__["a" /* default */])(root);
  2186. /* harmony default export */ __webpack_exports__["default"] = (result);
  2187. /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(0), __webpack_require__(17)(module)))
  2188. /***/ }),
  2189. /* 17 */
  2190. /***/ (function(module, exports) {
  2191. module.exports = function(originalModule) {
  2192. if(!originalModule.webpackPolyfill) {
  2193. var module = Object.create(originalModule);
  2194. // module.parent = undefined by default
  2195. if(!module.children) module.children = [];
  2196. Object.defineProperty(module, "loaded", {
  2197. enumerable: true,
  2198. get: function() {
  2199. return module.l;
  2200. }
  2201. });
  2202. Object.defineProperty(module, "id", {
  2203. enumerable: true,
  2204. get: function() {
  2205. return module.i;
  2206. }
  2207. });
  2208. Object.defineProperty(module, "exports", {
  2209. enumerable: true,
  2210. });
  2211. module.webpackPolyfill = 1;
  2212. }
  2213. return module;
  2214. };
  2215. /***/ }),
  2216. /* 18 */
  2217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2218. "use strict";
  2219. /* harmony export (immutable) */ __webpack_exports__["a"] = symbolObservablePonyfill;
  2220. function symbolObservablePonyfill(root) {
  2221. var result;
  2222. var Symbol = root.Symbol;
  2223. if (typeof Symbol === 'function') {
  2224. if (Symbol.observable) {
  2225. result = Symbol.observable;
  2226. } else {
  2227. result = Symbol('observable');
  2228. Symbol.observable = result;
  2229. }
  2230. } else {
  2231. result = '@@observable';
  2232. }
  2233. return result;
  2234. };
  2235. /***/ }),
  2236. /* 19 */
  2237. /***/ (function(module, exports, __webpack_require__) {
  2238. "use strict";
  2239. Object.defineProperty(exports, "__esModule", { value: true });
  2240. exports.GRAPHQL_SUBSCRIPTIONS = exports.GRAPHQL_WS = void 0;
  2241. var GRAPHQL_WS = 'graphql-ws';
  2242. exports.GRAPHQL_WS = GRAPHQL_WS;
  2243. var GRAPHQL_SUBSCRIPTIONS = 'graphql-subscriptions';
  2244. exports.GRAPHQL_SUBSCRIPTIONS = GRAPHQL_SUBSCRIPTIONS;
  2245. //# sourceMappingURL=protocol.js.map
  2246. /***/ }),
  2247. /* 20 */
  2248. /***/ (function(module, exports, __webpack_require__) {
  2249. "use strict";
  2250. Object.defineProperty(exports, "__esModule", { value: true });
  2251. exports.WS_TIMEOUT = exports.MIN_WS_TIMEOUT = void 0;
  2252. var MIN_WS_TIMEOUT = 1000;
  2253. exports.MIN_WS_TIMEOUT = MIN_WS_TIMEOUT;
  2254. var WS_TIMEOUT = 30000;
  2255. exports.WS_TIMEOUT = WS_TIMEOUT;
  2256. //# sourceMappingURL=defaults.js.map
  2257. /***/ }),
  2258. /* 21 */
  2259. /***/ (function(module, exports, __webpack_require__) {
  2260. "use strict";
  2261. Object.defineProperty(exports, "__esModule", { value: true });
  2262. var MessageTypes = (function () {
  2263. function MessageTypes() {
  2264. throw new Error('Static Class');
  2265. }
  2266. MessageTypes.GQL_CONNECTION_INIT = 'connection_init';
  2267. MessageTypes.GQL_CONNECTION_ACK = 'connection_ack';
  2268. MessageTypes.GQL_CONNECTION_ERROR = 'connection_error';
  2269. MessageTypes.GQL_CONNECTION_KEEP_ALIVE = 'ka';
  2270. MessageTypes.GQL_CONNECTION_TERMINATE = 'connection_terminate';
  2271. MessageTypes.GQL_START = 'start';
  2272. MessageTypes.GQL_DATA = 'data';
  2273. MessageTypes.GQL_ERROR = 'error';
  2274. MessageTypes.GQL_COMPLETE = 'complete';
  2275. MessageTypes.GQL_STOP = 'stop';
  2276. MessageTypes.SUBSCRIPTION_START = 'subscription_start';
  2277. MessageTypes.SUBSCRIPTION_DATA = 'subscription_data';
  2278. MessageTypes.SUBSCRIPTION_SUCCESS = 'subscription_success';
  2279. MessageTypes.SUBSCRIPTION_FAIL = 'subscription_fail';
  2280. MessageTypes.SUBSCRIPTION_END = 'subscription_end';
  2281. MessageTypes.INIT = 'init';
  2282. MessageTypes.INIT_SUCCESS = 'init_success';
  2283. MessageTypes.INIT_FAIL = 'init_fail';
  2284. MessageTypes.KEEP_ALIVE = 'keepalive';
  2285. return MessageTypes;
  2286. }());
  2287. exports.default = MessageTypes;
  2288. //# sourceMappingURL=message-types.js.map
  2289. /***/ })
  2290. /******/ ]);