@graphql-tools/url-loader 7.9.19 → 7.9.22-alpha-effcdc7b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +22 -16
  2. package/index.mjs +22 -16
  3. package/package.json +5 -5
package/index.js CHANGED
@@ -435,7 +435,7 @@ class UrlLoader {
435
435
  method = 'GET';
436
436
  }
437
437
  let accept = 'application/json, multipart/mixed';
438
- if (operationType === 'subscription') {
438
+ if (operationType === 'subscription' || graphqlLiveQuery.isLiveQueryOperationDefinitionNode(operationAst)) {
439
439
  method = 'GET';
440
440
  accept = 'text/event-stream';
441
441
  }
@@ -739,23 +739,29 @@ class UrlLoader {
739
739
  const httpExecutor$ = fetch$.then(fetch => {
740
740
  return this.buildHTTPExecutor(endpoint, fetch, options);
741
741
  });
742
- const subscriptionExecutor$ = fetch$.then(fetch => {
743
- const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
744
- return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);
745
- });
746
- function getExecutorByRequest(request) {
747
- const operationAst = utils.getOperationASTFromRequest(request);
748
- if (operationAst.operation === 'subscription' ||
749
- graphqlLiveQuery.isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
750
- return subscriptionExecutor$;
751
- }
752
- else {
753
- return httpExecutor$;
742
+ if ((options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) != null || (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) !== exports.SubscriptionProtocol.SSE) {
743
+ const subscriptionExecutor$ = fetch$.then(fetch => {
744
+ const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
745
+ return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);
746
+ });
747
+ // eslint-disable-next-line no-inner-declarations
748
+ function getExecutorByRequest(request) {
749
+ const operationAst = utils.getOperationASTFromRequest(request);
750
+ if (operationAst.operation === 'subscription' ||
751
+ graphqlLiveQuery.isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
752
+ return subscriptionExecutor$;
753
+ }
754
+ else {
755
+ return httpExecutor$;
756
+ }
754
757
  }
758
+ return request => getExecutorByRequest(request)
759
+ .then(executor => executor(request))
760
+ .resolve();
761
+ }
762
+ else {
763
+ return request => httpExecutor$.then(executor => executor(request)).resolve();
755
764
  }
756
- return request => getExecutorByRequest(request)
757
- .then(executor => executor(request))
758
- .resolve();
759
765
  }
760
766
  getExecutorAsync(endpoint, options) {
761
767
  return this.getExecutor(endpoint, asyncImport, options);
package/index.mjs CHANGED
@@ -411,7 +411,7 @@ class UrlLoader {
411
411
  method = 'GET';
412
412
  }
413
413
  let accept = 'application/json, multipart/mixed';
414
- if (operationType === 'subscription') {
414
+ if (operationType === 'subscription' || isLiveQueryOperationDefinitionNode(operationAst)) {
415
415
  method = 'GET';
416
416
  accept = 'text/event-stream';
417
417
  }
@@ -715,23 +715,29 @@ class UrlLoader {
715
715
  const httpExecutor$ = fetch$.then(fetch => {
716
716
  return this.buildHTTPExecutor(endpoint, fetch, options);
717
717
  });
718
- const subscriptionExecutor$ = fetch$.then(fetch => {
719
- const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
720
- return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);
721
- });
722
- function getExecutorByRequest(request) {
723
- const operationAst = getOperationASTFromRequest(request);
724
- if (operationAst.operation === 'subscription' ||
725
- isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
726
- return subscriptionExecutor$;
727
- }
728
- else {
729
- return httpExecutor$;
718
+ if ((options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) != null || (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) !== SubscriptionProtocol.SSE) {
719
+ const subscriptionExecutor$ = fetch$.then(fetch => {
720
+ const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
721
+ return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);
722
+ });
723
+ // eslint-disable-next-line no-inner-declarations
724
+ function getExecutorByRequest(request) {
725
+ const operationAst = getOperationASTFromRequest(request);
726
+ if (operationAst.operation === 'subscription' ||
727
+ isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
728
+ return subscriptionExecutor$;
729
+ }
730
+ else {
731
+ return httpExecutor$;
732
+ }
730
733
  }
734
+ return request => getExecutorByRequest(request)
735
+ .then(executor => executor(request))
736
+ .resolve();
737
+ }
738
+ else {
739
+ return request => httpExecutor$.then(executor => executor(request)).resolve();
731
740
  }
732
- return request => getExecutorByRequest(request)
733
- .then(executor => executor(request))
734
- .resolve();
735
741
  }
736
742
  getExecutorAsync(endpoint, options) {
737
743
  return this.getExecutor(endpoint, asyncImport, options);
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@graphql-tools/url-loader",
3
- "version": "7.9.19",
3
+ "version": "7.9.22-alpha-effcdc7b.0",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/delegate": "8.7.7",
11
- "@graphql-tools/utils": "8.6.9",
12
- "@graphql-tools/wrap": "8.4.16",
10
+ "@graphql-tools/delegate": "8.7.9-alpha-effcdc7b.0",
11
+ "@graphql-tools/utils": "8.6.10",
12
+ "@graphql-tools/wrap": "8.4.18-alpha-effcdc7b.0",
13
13
  "@n1ru4l/graphql-live-query": "^0.9.0",
14
14
  "@types/ws": "^8.0.0",
15
- "cross-undici-fetch": "^0.3.5",
15
+ "cross-undici-fetch": "^0.4.0",
16
16
  "dset": "^3.1.0",
17
17
  "extract-files": "^11.0.0",
18
18
  "graphql-ws": "^5.4.1",