@graphql-tools/url-loader 7.13.8 → 7.13.10-alpha-20220815173503-a11014cc

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
@@ -4,7 +4,7 @@ exports.UrlLoader = exports.SubscriptionProtocol = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* eslint-disable no-case-declarations */
6
6
  /// <reference lib="dom" />
7
- const graphql_1 = require("graphql");
7
+ const graphql_1 = require("@graphql-tools/graphql");
8
8
  const utils_1 = require("@graphql-tools/utils");
9
9
  const wrap_1 = require("@graphql-tools/wrap");
10
10
  const graphql_ws_1 = require("graphql-ws");
@@ -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);
@@ -164,15 +164,19 @@ class UrlLoader {
164
164
  if ((options === null || options === void 0 ? void 0 : options.useGETForQueries) && operationType === 'query') {
165
165
  method = 'GET';
166
166
  }
167
- let accept = 'application/json';
167
+ let accept = 'application/json, multipart/mixed';
168
+ // @ts-expect-error Uses graphql-js so it doesn't like us
168
169
  if (operationType === 'subscription' || (0, graphql_live_query_1.isLiveQueryOperationDefinitionNode)(operationAst)) {
169
170
  method = 'GET';
170
171
  accept = 'text/event-stream';
171
172
  }
172
- const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
173
+ else if ((_a = operationAst.directives) === null || _a === void 0 ? void 0 : _a.some(({ name }) => name.value === 'defer' || name.value === 'stream')) {
174
+ accept += ', multipart/mixed';
175
+ }
176
+ const endpoint = ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.endpoint) || HTTP_URL;
173
177
  const headers = Object.assign({
174
178
  accept,
175
- }, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
179
+ }, options === null || options === void 0 ? void 0 : options.headers, ((_c = request.extensions) === null || _c === void 0 ? void 0 : _c.headers) || {});
176
180
  const query = (0, graphql_1.print)(request.document);
177
181
  const requestBody = {
178
182
  query,
@@ -316,7 +320,9 @@ class UrlLoader {
316
320
  variables: variables,
317
321
  operationName,
318
322
  extensions,
319
- }, observer);
323
+ },
324
+ // @ts-expect-error Uses graphql-js so it doesn't like us
325
+ observer);
320
326
  return {
321
327
  unsubscribe,
322
328
  };
@@ -502,6 +508,7 @@ class UrlLoader {
502
508
  function getExecutorByRequest(request) {
503
509
  const operationAst = (0, utils_1.getOperationASTFromRequest)(request);
504
510
  if (operationAst.operation === 'subscription' ||
511
+ // @ts-expect-error Uses graphql-js so it doesn't like us
505
512
  (0, graphql_live_query_1.isLiveQueryOperationDefinitionNode)(operationAst, request.variables)) {
506
513
  return subscriptionExecutor$;
507
514
  }
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-tools/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);
@@ -160,15 +160,19 @@ export class UrlLoader {
160
160
  if ((options === null || options === void 0 ? void 0 : options.useGETForQueries) && operationType === 'query') {
161
161
  method = 'GET';
162
162
  }
163
- let accept = 'application/json';
163
+ let accept = 'application/json, multipart/mixed';
164
+ // @ts-expect-error Uses graphql-js so it doesn't like us
164
165
  if (operationType === 'subscription' || isLiveQueryOperationDefinitionNode(operationAst)) {
165
166
  method = 'GET';
166
167
  accept = 'text/event-stream';
167
168
  }
168
- const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
169
+ else if ((_a = operationAst.directives) === null || _a === void 0 ? void 0 : _a.some(({ name }) => name.value === 'defer' || name.value === 'stream')) {
170
+ accept += ', multipart/mixed';
171
+ }
172
+ const endpoint = ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.endpoint) || HTTP_URL;
169
173
  const headers = Object.assign({
170
174
  accept,
171
- }, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
175
+ }, options === null || options === void 0 ? void 0 : options.headers, ((_c = request.extensions) === null || _c === void 0 ? void 0 : _c.headers) || {});
172
176
  const query = print(request.document);
173
177
  const requestBody = {
174
178
  query,
@@ -312,7 +316,9 @@ export class UrlLoader {
312
316
  variables: variables,
313
317
  operationName,
314
318
  extensions,
315
- }, observer);
319
+ },
320
+ // @ts-expect-error Uses graphql-js so it doesn't like us
321
+ observer);
316
322
  return {
317
323
  unsubscribe,
318
324
  };
@@ -498,6 +504,7 @@ export class UrlLoader {
498
504
  function getExecutorByRequest(request) {
499
505
  const operationAst = getOperationASTFromRequest(request);
500
506
  if (operationAst.operation === 'subscription' ||
507
+ // @ts-expect-error Uses graphql-js so it doesn't like us
501
508
  isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
502
509
  return subscriptionExecutor$;
503
510
  }
package/package.json CHANGED
@@ -1,17 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-tools/url-loader",
3
- "version": "7.13.8",
3
+ "version": "7.13.10-alpha-20220815173503-a11014cc",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
- "peerDependencies": {
7
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
- },
9
6
  "dependencies": {
10
- "@graphql-tools/delegate": "9.0.3",
11
- "@graphql-tools/utils": "8.10.0",
12
- "@graphql-tools/wrap": "9.0.4",
7
+ "@graphql-tools/delegate": "9.0.4-alpha-20220815173503-a11014cc",
8
+ "@graphql-tools/utils": "8.10.1-alpha-20220815173503-a11014cc",
9
+ "@graphql-tools/wrap": "9.0.5-alpha-20220815173503-a11014cc",
13
10
  "@ardatan/sync-fetch": "0.0.1",
14
11
  "@n1ru4l/graphql-live-query": "^0.10.0",
12
+ "@graphql-tools/graphql": "0.1.0-alpha-20220815173503-a11014cc",
15
13
  "@types/ws": "^8.0.0",
16
14
  "@whatwg-node/fetch": "^0.2.9",
17
15
  "dset": "^3.1.2",
@@ -1,3 +1,3 @@
1
- import { ExecutionResult } from 'graphql';
1
+ import { ExecutionResult } from '@graphql-tools/graphql';
2
2
  export declare function isReadableStream(value: any): value is ReadableStream;
3
3
  export declare function handleEventStreamResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult>>;
@@ -1,3 +1,3 @@
1
- import { ExecutionResult } from 'graphql';
1
+ import { ExecutionResult } from '@graphql-tools/graphql';
2
2
  export declare function isReadableStream(value: any): value is ReadableStream;
3
3
  export declare function handleEventStreamResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult>>;
@@ -1,2 +1,2 @@
1
- import { ExecutionResult } from 'graphql';
2
- export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>>>;
1
+ import { ExecutionResult } from '@graphql-tools/graphql';
2
+ export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("../../../../graphql/src/jsutils/ObjMap").ObjMap<unknown>, import("../../../../graphql/src/jsutils/ObjMap").ObjMap<unknown>>>;
@@ -1,2 +1,2 @@
1
- import { ExecutionResult } from 'graphql';
2
- export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>>>;
1
+ import { ExecutionResult } from '@graphql-tools/graphql';
2
+ export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("../../../../graphql/src/jsutils/ObjMap").ObjMap<unknown>, import("../../../../graphql/src/jsutils/ObjMap").ObjMap<unknown>>>;
@@ -1,2 +1,2 @@
1
- import type { ExecutionResult } from 'graphql';
2
- export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
1
+ import type { ExecutionResult } from '@graphql-tools/graphql';
2
+ export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("../../../graphql/src/jsutils/ObjMap.js").ObjMap<unknown>, import("../../../graphql/src/jsutils/ObjMap.js").ObjMap<unknown>> | undefined>>;
@@ -1,2 +1,2 @@
1
- import type { ExecutionResult } from 'graphql';
2
- export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
1
+ import type { ExecutionResult } from '@graphql-tools/graphql';
2
+ export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("../../../graphql/src/jsutils/ObjMap.js").ObjMap<unknown>, import("../../../graphql/src/jsutils/ObjMap.js").ObjMap<unknown>> | undefined>>;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="ws" />
2
2
  /// <reference lib="dom" />
3
- import { IntrospectionOptions } from 'graphql';
3
+ import { IntrospectionOptions } from '@graphql-tools/graphql';
4
4
  import { AsyncExecutor, Executor, SyncExecutor, Source, Loader, BaseLoaderOptions } from '@graphql-tools/utils';
5
5
  import { ClientOptions } from 'graphql-ws';
6
6
  import WebSocket from 'isomorphic-ws';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="ws" />
2
2
  /// <reference lib="dom" />
3
- import { IntrospectionOptions } from 'graphql';
3
+ import { IntrospectionOptions } from '@graphql-tools/graphql';
4
4
  import { AsyncExecutor, Executor, SyncExecutor, Source, Loader, BaseLoaderOptions } from '@graphql-tools/utils';
5
5
  import { ClientOptions } from 'graphql-ws';
6
6
  import WebSocket from 'isomorphic-ws';