@graphql-tools/url-loader 7.13.3 → 7.13.4-alpha-b9e4a92b.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.
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-tools/url-loader",
3
- "version": "7.13.3",
3
+ "version": "7.13.4-alpha-b9e4a92b.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 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/delegate": "8.8.1",
11
- "@graphql-tools/utils": "8.9.0",
12
- "@graphql-tools/wrap": "8.5.1",
10
+ "@graphql-tools/delegate": "8.8.2-alpha-b9e4a92b.0",
11
+ "@graphql-tools/utils": "8.9.1-alpha-b9e4a92b.0",
12
+ "@graphql-tools/wrap": "8.5.2-alpha-b9e4a92b.0",
13
13
  "@ardatan/sync-fetch": "0.0.1",
14
14
  "@n1ru4l/graphql-live-query": "^0.10.0",
15
15
  "@types/ws": "^8.0.0",
@@ -40,7 +40,7 @@
40
40
  "exports": {
41
41
  ".": {
42
42
  "require": {
43
- "types": "./typings/index.d.ts",
43
+ "types": "./typings/index.d.cts",
44
44
  "default": "./cjs/index.js"
45
45
  },
46
46
  "import": {
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "./*": {
56
56
  "require": {
57
- "types": "./typings/*.d.ts",
57
+ "types": "./typings/*.d.cts",
58
58
  "default": "./cjs/*.js"
59
59
  },
60
60
  "import": {
@@ -0,0 +1 @@
1
+ export declare function addCancelToResponseStream<T>(resultStream: AsyncIterable<T>, controller: AbortController): AsyncIterable<T>;
@@ -0,0 +1,3 @@
1
+ import { fetch } from '@whatwg-node/fetch';
2
+ export declare type AsyncFetchFn = typeof fetch;
3
+ export declare const defaultAsyncFetch: AsyncFetchFn;
@@ -0,0 +1,6 @@
1
+ export declare const defaultSyncFetch: SyncFetchFn;
2
+ export declare type SyncFetchFn = (input: RequestInfo, init?: RequestInit) => SyncResponse;
3
+ export declare type SyncResponse = Omit<Response, 'json' | 'text'> & {
4
+ json: () => any;
5
+ text: () => string;
6
+ };
@@ -0,0 +1 @@
1
+ export declare function handleAsyncIterable(asyncIterable: AsyncIterable<Uint8Array | string>): AsyncGenerator<any, void, unknown>;
@@ -0,0 +1,3 @@
1
+ import { ExecutionResult } from 'graphql';
2
+ export declare function isReadableStream(value: any): value is ReadableStream;
3
+ export declare function handleEventStreamResponse(response: Response): Promise<AsyncIterable<ExecutionResult>>;
@@ -0,0 +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>>>;
@@ -0,0 +1,2 @@
1
+ import type { ExecutionResult } from 'graphql';
2
+ export declare function handleMultipartMixedResponse(response: Response): Promise<AsyncIterableIterator<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
@@ -0,0 +1,151 @@
1
+ /// <reference types="ws" />
2
+ /// <reference lib="dom" />
3
+ import { IntrospectionOptions } from 'graphql';
4
+ import { AsyncExecutor, Executor, SyncExecutor, Source, Loader, BaseLoaderOptions } from '@graphql-tools/utils';
5
+ import { ClientOptions } from 'graphql-ws';
6
+ import WebSocket from 'isomorphic-ws';
7
+ import { AsyncFetchFn } from './defaultAsyncFetch.cjs';
8
+ import { SyncFetchFn } from './defaultSyncFetch.cjs';
9
+ export declare type FetchFn = AsyncFetchFn | SyncFetchFn;
10
+ export declare type AsyncImportFn = (moduleName: string) => PromiseLike<any>;
11
+ export declare type SyncImportFn = (moduleName: string) => any;
12
+ declare type HeadersConfig = Record<string, string>;
13
+ interface ExecutionExtensions {
14
+ headers?: HeadersConfig;
15
+ endpoint?: string;
16
+ }
17
+ export declare enum SubscriptionProtocol {
18
+ WS = "WS",
19
+ /**
20
+ * Use legacy web socket protocol `graphql-ws` instead of the more current standard `graphql-transport-ws`
21
+ */
22
+ LEGACY_WS = "LEGACY_WS",
23
+ /**
24
+ * Use SSE for subscription instead of WebSocket
25
+ */
26
+ SSE = "SSE",
27
+ /**
28
+ * Use `graphql-sse` for subscriptions
29
+ */
30
+ GRAPHQL_SSE = "GRAPHQL_SSE"
31
+ }
32
+ /**
33
+ * Additional options for loading from a URL
34
+ */
35
+ export interface LoadFromUrlOptions extends BaseLoaderOptions, Partial<IntrospectionOptions> {
36
+ /**
37
+ * Additional headers to include when querying the original schema
38
+ */
39
+ headers?: HeadersConfig;
40
+ /**
41
+ * A custom `fetch` implementation to use when querying the original schema.
42
+ * Defaults to `cross-fetch`
43
+ */
44
+ customFetch?: FetchFn | string;
45
+ /**
46
+ * HTTP method to use when querying the original schema.
47
+ */
48
+ method?: 'GET' | 'POST';
49
+ /**
50
+ * Custom WebSocket implementation used by the loaded schema if subscriptions
51
+ * are enabled
52
+ */
53
+ webSocketImpl?: typeof WebSocket | string;
54
+ /**
55
+ * Whether to use the GET HTTP method for queries when querying the original schema
56
+ */
57
+ useGETForQueries?: boolean;
58
+ /**
59
+ * Use multipart for POST requests
60
+ */
61
+ multipart?: boolean;
62
+ /**
63
+ * Handle URL as schema SDL
64
+ */
65
+ handleAsSDL?: boolean;
66
+ /**
67
+ * Regular HTTP endpoint; defaults to the pointer
68
+ */
69
+ endpoint?: string;
70
+ /**
71
+ * Subscriptions endpoint; defaults to the endpoint given as HTTP endpoint
72
+ */
73
+ subscriptionsEndpoint?: string;
74
+ /**
75
+ * Use specific protocol for subscriptions
76
+ */
77
+ subscriptionsProtocol?: SubscriptionProtocol;
78
+ /**
79
+ * @deprecated This is no longer used. Will be removed in the next release
80
+ */
81
+ graphqlSseOptions?: any;
82
+ /**
83
+ * Retry attempts
84
+ */
85
+ retry?: number;
86
+ /**
87
+ * Timeout in milliseconds
88
+ */
89
+ timeout?: number;
90
+ /**
91
+ * Request Credentials (default: 'same-origin')
92
+ * You can pass `disable` if you don't want this to be set in `Request`
93
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials
94
+ */
95
+ credentials?: RequestCredentials | 'disable';
96
+ /**
97
+ * Connection Parameters for WebSockets connection
98
+ */
99
+ connectionParams?: any;
100
+ /**
101
+ * Enable Batching
102
+ */
103
+ batch?: boolean;
104
+ }
105
+ /**
106
+ * This loader loads a schema from a URL. The loaded schema is a fully-executable,
107
+ * remote schema since it's created using [@graphql-tools/wrap](/docs/remote-schemas).
108
+ *
109
+ * ```
110
+ * const schema = await loadSchema('http://localhost:3000/graphql', {
111
+ * loaders: [
112
+ * new UrlLoader(),
113
+ * ]
114
+ * });
115
+ * ```
116
+ */
117
+ export declare class UrlLoader implements Loader<LoadFromUrlOptions> {
118
+ createFormDataFromVariables<TVariables>({ query, variables, operationName, extensions, }: {
119
+ query: string;
120
+ variables: TVariables;
121
+ operationName?: string;
122
+ extensions?: any;
123
+ }): FormData | Promise<FormData>;
124
+ prepareGETUrl({ baseUrl, query, variables, operationName, extensions, }: {
125
+ baseUrl: string;
126
+ query: string;
127
+ variables: any;
128
+ operationName?: string;
129
+ extensions?: any;
130
+ }): string;
131
+ buildHTTPExecutor(endpoint: string, fetch: SyncFetchFn, options?: LoadFromUrlOptions): SyncExecutor<any, ExecutionExtensions>;
132
+ buildHTTPExecutor(endpoint: string, fetch: AsyncFetchFn, options?: LoadFromUrlOptions): AsyncExecutor<any, ExecutionExtensions>;
133
+ buildWSExecutor(subscriptionsEndpoint: string, webSocketImpl: typeof WebSocket, connectionParams?: ClientOptions['connectionParams']): Executor;
134
+ buildWSLegacyExecutor(subscriptionsEndpoint: string, WebSocketImpl: typeof WebSocket, options?: LoadFromUrlOptions): Executor;
135
+ getFetch(customFetch: LoadFromUrlOptions['customFetch'], importFn: AsyncImportFn): PromiseLike<AsyncFetchFn> | AsyncFetchFn;
136
+ getFetch(customFetch: LoadFromUrlOptions['customFetch'], importFn: SyncImportFn): SyncFetchFn;
137
+ private getDefaultMethodFromOptions;
138
+ getWebSocketImpl(importFn: AsyncImportFn, options?: LoadFromUrlOptions): PromiseLike<typeof WebSocket>;
139
+ getWebSocketImpl(importFn: SyncImportFn, options?: LoadFromUrlOptions): typeof WebSocket;
140
+ buildSubscriptionExecutor(subscriptionsEndpoint: string, fetch: SyncFetchFn, syncImport: SyncImportFn, options?: LoadFromUrlOptions): SyncExecutor;
141
+ buildSubscriptionExecutor(subscriptionsEndpoint: string, fetch: AsyncFetchFn, asyncImport: AsyncImportFn, options?: LoadFromUrlOptions): AsyncExecutor;
142
+ getExecutor(endpoint: string, asyncImport: AsyncImportFn, options?: Omit<LoadFromUrlOptions, 'endpoint'>): AsyncExecutor;
143
+ getExecutor(endpoint: string, syncImport: SyncImportFn, options?: Omit<LoadFromUrlOptions, 'endpoint'>): SyncExecutor;
144
+ getExecutorAsync(endpoint: string, options?: Omit<LoadFromUrlOptions, 'endpoint'>): AsyncExecutor;
145
+ getExecutorSync(endpoint: string, options?: Omit<LoadFromUrlOptions, 'endpoint'>): SyncExecutor;
146
+ handleSDL(pointer: string, fetch: SyncFetchFn, options: LoadFromUrlOptions): Source;
147
+ handleSDL(pointer: string, fetch: AsyncFetchFn, options: LoadFromUrlOptions): Promise<Source>;
148
+ load(pointer: string, options: LoadFromUrlOptions): Promise<Source[]>;
149
+ loadSync(pointer: string, options: LoadFromUrlOptions): Source[];
150
+ }
151
+ export {};
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ import type { Readable } from 'stream';
3
+ export declare function isBlob(obj: any): obj is Blob;
4
+ interface GraphQLUpload {
5
+ filename: string;
6
+ mimetype: string;
7
+ createReadStream: () => Readable;
8
+ }
9
+ export declare function isGraphQLUpload(upload: any): upload is GraphQLUpload;
10
+ export declare function isPromiseLike(obj: any): obj is PromiseLike<any>;
11
+ export declare enum LEGACY_WS {
12
+ CONNECTION_INIT = "connection_init",
13
+ CONNECTION_ACK = "connection_ack",
14
+ CONNECTION_ERROR = "connection_error",
15
+ CONNECTION_KEEP_ALIVE = "ka",
16
+ START = "start",
17
+ STOP = "stop",
18
+ CONNECTION_TERMINATE = "connection_terminate",
19
+ DATA = "data",
20
+ ERROR = "error",
21
+ COMPLETE = "complete"
22
+ }
23
+ export {};