@graphiql/toolkit
Advanced tools
Comparing version 0.7.3 to 0.8.0
# @graphiql/toolkit | ||
## 0.8.0 | ||
### Minor Changes | ||
- [#2719](https://github.com/graphql/graphiql/pull/2719) [`e244b782`](https://github.com/graphql/graphiql/commit/e244b78291c2e2bb02d5753db82437926ebb4df4) Thanks [@andreialecu](https://github.com/andreialecu)! - Allow passing Headers for subscriptions into connection_init payload | ||
## 0.7.3 | ||
@@ -4,0 +10,0 @@ |
@@ -21,3 +21,2 @@ "use strict"; | ||
var simpleFetcher = (0, lib_1.createSimpleFetcher)(options, httpFetch); | ||
var wsFetcher = (0, lib_1.getWsFetcher)(options); | ||
var httpFetcher = options.enableIncrementalDelivery | ||
@@ -34,2 +33,3 @@ ? (0, lib_1.createMultipartFetcher)(options, httpFetch) | ||
if (isSubscription) { | ||
var wsFetcher = (0, lib_1.getWsFetcher)(options, fetcherOpts); | ||
if (!wsFetcher) { | ||
@@ -36,0 +36,0 @@ throw Error("Your GraphiQL createFetcher is not properly configured for websocket subscriptions yet. ".concat(options.subscriptionUrl |
import { DocumentNode } from 'graphql'; | ||
import { Client, ClientOptions, ExecutionResult } from 'graphql-ws'; | ||
import type { Fetcher, FetcherParams, CreateFetcherOptions } from './types'; | ||
import type { Fetcher, FetcherParams, FetcherOpts, CreateFetcherOptions } from './types'; | ||
export declare const isSubscriptionWithName: (document: DocumentNode, name: string | undefined) => boolean; | ||
@@ -12,3 +12,3 @@ export declare const createSimpleFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher; | ||
export declare const createMultipartFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher; | ||
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined; | ||
export declare const getWsFetcher: (options: CreateFetcherOptions, fetcherOpts: FetcherOpts | undefined) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined; | ||
//# sourceMappingURL=lib.d.ts.map |
@@ -214,3 +214,3 @@ "use strict"; | ||
exports.createMultipartFetcher = createMultipartFetcher; | ||
var getWsFetcher = function (options) { | ||
var getWsFetcher = function (options, fetcherOpts) { | ||
if (options.wsClient) { | ||
@@ -220,3 +220,3 @@ return (0, exports.createWebsocketsFetcherFromClient)(options.wsClient); | ||
if (options.subscriptionUrl) { | ||
return (0, exports.createWebsocketsFetcherFromUrl)(options.subscriptionUrl, options.wsConnectionParams); | ||
return (0, exports.createWebsocketsFetcherFromUrl)(options.subscriptionUrl, __assign(__assign({}, options.wsConnectionParams), fetcherOpts === null || fetcherOpts === void 0 ? void 0 : fetcherOpts.headers)); | ||
} | ||
@@ -223,0 +223,0 @@ var legacyWebsocketsClient = options.legacyClient || options.legacyWsClient; |
@@ -18,3 +18,2 @@ import { createMultipartFetcher, createSimpleFetcher, isSubscriptionWithName, getWsFetcher, } from './lib'; | ||
const simpleFetcher = createSimpleFetcher(options, httpFetch); | ||
const wsFetcher = getWsFetcher(options); | ||
const httpFetcher = options.enableIncrementalDelivery | ||
@@ -31,2 +30,3 @@ ? createMultipartFetcher(options, httpFetch) | ||
if (isSubscription) { | ||
const wsFetcher = getWsFetcher(options, fetcherOpts); | ||
if (!wsFetcher) { | ||
@@ -33,0 +33,0 @@ throw Error(`Your GraphiQL createFetcher is not properly configured for websocket subscriptions yet. ${options.subscriptionUrl |
import { DocumentNode } from 'graphql'; | ||
import { Client, ClientOptions, ExecutionResult } from 'graphql-ws'; | ||
import type { Fetcher, FetcherParams, CreateFetcherOptions } from './types'; | ||
import type { Fetcher, FetcherParams, FetcherOpts, CreateFetcherOptions } from './types'; | ||
export declare const isSubscriptionWithName: (document: DocumentNode, name: string | undefined) => boolean; | ||
@@ -12,3 +12,3 @@ export declare const createSimpleFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher; | ||
export declare const createMultipartFetcher: (options: CreateFetcherOptions, httpFetch: typeof fetch) => Fetcher; | ||
export declare const getWsFetcher: (options: CreateFetcherOptions) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined; | ||
export declare const getWsFetcher: (options: CreateFetcherOptions, fetcherOpts: FetcherOpts | undefined) => ((graphQLParams: FetcherParams) => AsyncIterableIterator<ExecutionResult<Record<string, unknown>, Record<string, unknown>>>) | undefined; | ||
//# sourceMappingURL=lib.d.ts.map |
@@ -120,3 +120,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
export const getWsFetcher = (options) => { | ||
export const getWsFetcher = (options, fetcherOpts) => { | ||
if (options.wsClient) { | ||
@@ -126,3 +126,3 @@ return createWebsocketsFetcherFromClient(options.wsClient); | ||
if (options.subscriptionUrl) { | ||
return createWebsocketsFetcherFromUrl(options.subscriptionUrl, options.wsConnectionParams); | ||
return createWebsocketsFetcherFromUrl(options.subscriptionUrl, Object.assign(Object.assign({}, options.wsConnectionParams), fetcherOpts === null || fetcherOpts === void 0 ? void 0 : fetcherOpts.headers)); | ||
} | ||
@@ -129,0 +129,0 @@ const legacyWebsocketsClient = options.legacyClient || options.legacyWsClient; |
{ | ||
"name": "@graphiql/toolkit", | ||
"version": "0.7.3", | ||
"version": "0.8.0", | ||
"description": "Utility to build a fetcher for GraphiQL", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -100,3 +100,3 @@ import { parse } from 'graphql'; | ||
expect(createClient.mock.calls[0]).toEqual([ | ||
{ connectionParams: undefined, url: 'wss://example' }, | ||
{ connectionParams: {}, url: 'wss://example' }, | ||
]); | ||
@@ -103,0 +103,0 @@ expect(SubscriptionClient.mock.calls).toHaveLength(0); |
@@ -38,3 +38,2 @@ import type { Fetcher, CreateFetcherOptions } from './types'; | ||
const wsFetcher = getWsFetcher(options); | ||
const httpFetcher = options.enableIncrementalDelivery | ||
@@ -58,2 +57,4 @@ ? createMultipartFetcher(options, httpFetch) | ||
if (isSubscription) { | ||
const wsFetcher = getWsFetcher(options, fetcherOpts); | ||
if (!wsFetcher) { | ||
@@ -60,0 +61,0 @@ throw Error( |
@@ -196,3 +196,6 @@ import { DocumentNode, visit } from 'graphql'; | ||
*/ | ||
export const getWsFetcher = (options: CreateFetcherOptions) => { | ||
export const getWsFetcher = ( | ||
options: CreateFetcherOptions, | ||
fetcherOpts: FetcherOpts | undefined, | ||
) => { | ||
if (options.wsClient) { | ||
@@ -202,6 +205,6 @@ return createWebsocketsFetcherFromClient(options.wsClient); | ||
if (options.subscriptionUrl) { | ||
return createWebsocketsFetcherFromUrl( | ||
options.subscriptionUrl, | ||
options.wsConnectionParams, | ||
); | ||
return createWebsocketsFetcherFromUrl(options.subscriptionUrl, { | ||
...options.wsConnectionParams, | ||
...fetcherOpts?.headers, | ||
}); | ||
} | ||
@@ -208,0 +211,0 @@ const legacyWebsocketsClient = options.legacyClient || options.legacyWsClient; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
302634
3965