@graphql-tools/url-loader 7.13.8 → 7.13.9-alpha-20220815091027-af688a61

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.
package/cjs/index.js CHANGED
@@ -156,7 +156,7 @@ class UrlLoader {
156
156
  ws: 'http',
157
157
  });
158
158
  const executor = (request) => {
159
- var _a, _b;
159
+ var _a, _b, _c;
160
160
  const controller = (0, addCancelToResponseStream_js_1.cancelNeeded)() ? new fetch_1.AbortController() : undefined;
161
161
  let method = defaultMethod;
162
162
  const operationAst = (0, utils_1.getOperationASTFromRequest)(request);
@@ -169,10 +169,13 @@ class UrlLoader {
169
169
  method = 'GET';
170
170
  accept = 'text/event-stream';
171
171
  }
172
- const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
172
+ else if ((_a = operationAst.directives) === null || _a === void 0 ? void 0 : _a.some(({ name }) => name.value === 'defer' || name.value === 'stream')) {
173
+ accept += ', multipart/mixed';
174
+ }
175
+ const endpoint = ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.endpoint) || HTTP_URL;
173
176
  const headers = Object.assign({
174
177
  accept,
175
- }, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
178
+ }, options === null || options === void 0 ? void 0 : options.headers, ((_c = request.extensions) === null || _c === void 0 ? void 0 : _c.headers) || {});
176
179
  const query = (0, graphql_1.print)(request.document);
177
180
  const requestBody = {
178
181
  query,
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-case-declarations */
2
2
  /// <reference lib="dom" />
3
- import { print, buildASTSchema, buildSchema } from 'graphql';
3
+ import { print, buildASTSchema, buildSchema, } from 'graphql';
4
4
  import { observableToAsyncIterable, isAsyncIterable, parseGraphQLSDL, getOperationASTFromRequest, } from '@graphql-tools/utils';
5
5
  import { introspectSchema, wrapSchema } from '@graphql-tools/wrap';
6
6
  import { createClient } from 'graphql-ws';
@@ -152,7 +152,7 @@ export class UrlLoader {
152
152
  ws: 'http',
153
153
  });
154
154
  const executor = (request) => {
155
- var _a, _b;
155
+ var _a, _b, _c;
156
156
  const controller = cancelNeeded() ? new AbortController() : undefined;
157
157
  let method = defaultMethod;
158
158
  const operationAst = getOperationASTFromRequest(request);
@@ -165,10 +165,13 @@ export class UrlLoader {
165
165
  method = 'GET';
166
166
  accept = 'text/event-stream';
167
167
  }
168
- const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
168
+ else if ((_a = operationAst.directives) === null || _a === void 0 ? void 0 : _a.some(({ name }) => name.value === 'defer' || name.value === 'stream')) {
169
+ accept += ', multipart/mixed';
170
+ }
171
+ const endpoint = ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.endpoint) || HTTP_URL;
169
172
  const headers = Object.assign({
170
173
  accept,
171
- }, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
174
+ }, options === null || options === void 0 ? void 0 : options.headers, ((_c = request.extensions) === null || _c === void 0 ? void 0 : _c.headers) || {});
172
175
  const query = print(request.document);
173
176
  const requestBody = {
174
177
  query,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/url-loader",
3
- "version": "7.13.8",
3
+ "version": "7.13.9-alpha-20220815091027-af688a61",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {