1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('apollo-link'), require('graphql/execution/execute')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'apollo-link', 'graphql/execution/execute'], factory) :
|
4 | (global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.schema = {}), global.tslib, global.apolloLink.core, global.graphql.execute));
|
5 | }(this, (function (exports, tslib_1, apolloLink, execute) { 'use strict';
|
6 |
|
7 | var SchemaLink = (function (_super) {
|
8 | tslib_1.__extends(SchemaLink, _super);
|
9 | function SchemaLink(_a) {
|
10 | var schema = _a.schema, rootValue = _a.rootValue, context = _a.context;
|
11 | var _this = _super.call(this) || this;
|
12 | _this.schema = schema;
|
13 | _this.rootValue = rootValue;
|
14 | _this.context = context;
|
15 | return _this;
|
16 | }
|
17 | SchemaLink.prototype.request = function (operation) {
|
18 | var _this = this;
|
19 | return new apolloLink.Observable(function (observer) {
|
20 | Promise.resolve(execute.execute(_this.schema, operation.query, _this.rootValue, typeof _this.context === 'function'
|
21 | ? _this.context(operation)
|
22 | : _this.context, operation.variables, operation.operationName))
|
23 | .then(function (data) {
|
24 | if (!observer.closed) {
|
25 | observer.next(data);
|
26 | observer.complete();
|
27 | }
|
28 | })
|
29 | .catch(function (error) {
|
30 | if (!observer.closed) {
|
31 | observer.error(error);
|
32 | }
|
33 | });
|
34 | });
|
35 | };
|
36 | return SchemaLink;
|
37 | }(apolloLink.ApolloLink));
|
38 |
|
39 | exports.SchemaLink = SchemaLink;
|
40 | exports.default = SchemaLink;
|
41 |
|
42 | Object.defineProperty(exports, '__esModule', { value: true });
|
43 |
|
44 | })));
|
45 |
|