Socket
Socket
Sign inDemoInstall

@graphql-tools/url-loader

Package Overview
Dependencies
Maintainers
3
Versions
1537
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/url-loader - npm Package Compare versions

Comparing version 8.0.0-rc-20230519104353-b09f3180 to 8.0.0-rc-20230519104627-f6fea064

2

cjs/defaultSyncFetch.js

@@ -8,3 +8,3 @@ "use strict";

if (typeof input === 'string') {
init === null || init === void 0 ? true : delete init.signal;
delete init?.signal;
}

@@ -11,0 +11,0 @@ else {

@@ -39,3 +39,3 @@ "use strict";

}
catch (_a) {
catch {
return false;

@@ -112,3 +112,3 @@ }

getWebSocketImpl(importFn, options) {
if (typeof (options === null || options === void 0 ? void 0 : options.webSocketImpl) === 'string') {
if (typeof options?.webSocketImpl === 'string') {
const [moduleName, webSocketImplName] = options.webSocketImpl.split('#');

@@ -120,3 +120,3 @@ return new value_or_promise_1.ValueOrPromise(() => importFn(moduleName))

else {
const websocketImpl = (options === null || options === void 0 ? void 0 : options.webSocketImpl) || isomorphic_ws_1.default;
const websocketImpl = options?.webSocketImpl || isomorphic_ws_1.default;
return websocketImpl;

@@ -126,7 +126,7 @@ }

buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options) {
if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.SSE) {
if (options?.subscriptionsProtocol === SubscriptionProtocol.SSE) {
return this.buildHTTPExecutor(subscriptionsEndpoint, fetch, options);
}
else if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.GRAPHQL_SSE) {
if (!(options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint)) {
else if (options?.subscriptionsProtocol === SubscriptionProtocol.GRAPHQL_SSE) {
if (!options?.subscriptionsEndpoint) {
// when no custom subscriptions endpoint is specified,

@@ -141,7 +141,7 @@ // graphql-sse is recommended to be used on `/graphql/stream`

const executor$ = webSocketImpl$.then(webSocketImpl => {
if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.LEGACY_WS) {
if (options?.subscriptionsProtocol === SubscriptionProtocol.LEGACY_WS) {
return this.buildWSLegacyExecutor(subscriptionsEndpoint, webSocketImpl, options);
}
else {
return this.buildWSExecutor(subscriptionsEndpoint, webSocketImpl, options === null || options === void 0 ? void 0 : options.connectionParams);
return this.buildWSExecutor(subscriptionsEndpoint, webSocketImpl, options?.connectionParams);
}

@@ -153,9 +153,9 @@ });

getExecutor(endpoint, importFn, options) {
const fetch$ = new value_or_promise_1.ValueOrPromise(() => this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, importFn));
const fetch$ = new value_or_promise_1.ValueOrPromise(() => this.getFetch(options?.customFetch, importFn));
const httpExecutor$ = fetch$.then(fetch => {
return this.buildHTTPExecutor(endpoint, fetch, options);
});
if ((options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) != null || (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) !== SubscriptionProtocol.SSE) {
if (options?.subscriptionsEndpoint != null || options?.subscriptionsProtocol !== SubscriptionProtocol.SSE) {
const subscriptionExecutor$ = fetch$.then(fetch => {
const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
const subscriptionsEndpoint = options?.subscriptionsEndpoint || endpoint;
return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);

@@ -165,4 +165,3 @@ });

function getExecutorByRequest(request) {
var _a;
request.operationType = request.operationType || ((_a = (0, utils_1.getOperationASTFromRequest)(request)) === null || _a === void 0 ? void 0 : _a.operation);
request.operationType = request.operationType || (0, utils_1.getOperationASTFromRequest)(request)?.operation;
if (request.operationType === 'subscription' &&

@@ -194,6 +193,6 @@ (0, executor_http_1.isLiveQueryOperationDefinitionNode)((0, utils_1.getOperationASTFromRequest)(request))) {

handleSDL(pointer, fetch, options) {
const defaultMethod = this.getDefaultMethodFromOptions(options === null || options === void 0 ? void 0 : options.method, 'GET');
const defaultMethod = this.getDefaultMethodFromOptions(options?.method, 'GET');
return new value_or_promise_1.ValueOrPromise(() => fetch(pointer, {
method: defaultMethod,
headers: typeof (options === null || options === void 0 ? void 0 : options.headers) === 'function' ? options.headers() : options === null || options === void 0 ? void 0 : options.headers,
headers: typeof options?.headers === 'function' ? options.headers() : options?.headers,
}))

@@ -212,4 +211,4 @@ .then(response => response.text())

let executor;
if ((options === null || options === void 0 ? void 0 : options.handleAsSDL) || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = await this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, asyncImport);
if (options?.handleAsSDL || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = await this.getFetch(options?.customFetch, asyncImport);
source = await this.handleSDL(pointer, fetch, options);

@@ -234,3 +233,3 @@ if (!source.schema && !source.document && !source.rawSDL) {

}
if (options === null || options === void 0 ? void 0 : options.endpoint) {
if (options?.endpoint) {
executor = this.getExecutorAsync(options.endpoint, options);

@@ -242,3 +241,3 @@ }

executor,
batch: options === null || options === void 0 ? void 0 : options.batch,
batch: options?.batch,
});

@@ -256,4 +255,4 @@ }

let executor;
if ((options === null || options === void 0 ? void 0 : options.handleAsSDL) || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, syncImport);
if (options?.handleAsSDL || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = this.getFetch(options?.customFetch, syncImport);
source = this.handleSDL(pointer, fetch, options);

@@ -278,3 +277,3 @@ if (!source.schema && !source.document && !source.rawSDL) {

}
if (options === null || options === void 0 ? void 0 : options.endpoint) {
if (options?.endpoint) {
executor = this.getExecutorSync(options.endpoint, options);

@@ -281,0 +280,0 @@ }

import syncFetchImported from '@ardatan/sync-fetch';
export const defaultSyncFetch = (input, init) => {
if (typeof input === 'string') {
init === null || init === void 0 ? true : delete init.signal;
delete init?.signal;
}

@@ -6,0 +6,0 @@ else {

@@ -35,3 +35,3 @@ import { buildASTSchema, buildSchema } from 'graphql';

}
catch (_a) {
catch {
return false;

@@ -108,3 +108,3 @@ }

getWebSocketImpl(importFn, options) {
if (typeof (options === null || options === void 0 ? void 0 : options.webSocketImpl) === 'string') {
if (typeof options?.webSocketImpl === 'string') {
const [moduleName, webSocketImplName] = options.webSocketImpl.split('#');

@@ -116,3 +116,3 @@ return new ValueOrPromise(() => importFn(moduleName))

else {
const websocketImpl = (options === null || options === void 0 ? void 0 : options.webSocketImpl) || WebSocket;
const websocketImpl = options?.webSocketImpl || WebSocket;
return websocketImpl;

@@ -122,7 +122,7 @@ }

buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options) {
if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.SSE) {
if (options?.subscriptionsProtocol === SubscriptionProtocol.SSE) {
return this.buildHTTPExecutor(subscriptionsEndpoint, fetch, options);
}
else if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.GRAPHQL_SSE) {
if (!(options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint)) {
else if (options?.subscriptionsProtocol === SubscriptionProtocol.GRAPHQL_SSE) {
if (!options?.subscriptionsEndpoint) {
// when no custom subscriptions endpoint is specified,

@@ -137,7 +137,7 @@ // graphql-sse is recommended to be used on `/graphql/stream`

const executor$ = webSocketImpl$.then(webSocketImpl => {
if ((options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.LEGACY_WS) {
if (options?.subscriptionsProtocol === SubscriptionProtocol.LEGACY_WS) {
return this.buildWSLegacyExecutor(subscriptionsEndpoint, webSocketImpl, options);
}
else {
return this.buildWSExecutor(subscriptionsEndpoint, webSocketImpl, options === null || options === void 0 ? void 0 : options.connectionParams);
return this.buildWSExecutor(subscriptionsEndpoint, webSocketImpl, options?.connectionParams);
}

@@ -149,9 +149,9 @@ });

getExecutor(endpoint, importFn, options) {
const fetch$ = new ValueOrPromise(() => this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, importFn));
const fetch$ = new ValueOrPromise(() => this.getFetch(options?.customFetch, importFn));
const httpExecutor$ = fetch$.then(fetch => {
return this.buildHTTPExecutor(endpoint, fetch, options);
});
if ((options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) != null || (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) !== SubscriptionProtocol.SSE) {
if (options?.subscriptionsEndpoint != null || options?.subscriptionsProtocol !== SubscriptionProtocol.SSE) {
const subscriptionExecutor$ = fetch$.then(fetch => {
const subscriptionsEndpoint = (options === null || options === void 0 ? void 0 : options.subscriptionsEndpoint) || endpoint;
const subscriptionsEndpoint = options?.subscriptionsEndpoint || endpoint;
return this.buildSubscriptionExecutor(subscriptionsEndpoint, fetch, importFn, options);

@@ -161,4 +161,3 @@ });

function getExecutorByRequest(request) {
var _a;
request.operationType = request.operationType || ((_a = getOperationASTFromRequest(request)) === null || _a === void 0 ? void 0 : _a.operation);
request.operationType = request.operationType || getOperationASTFromRequest(request)?.operation;
if (request.operationType === 'subscription' &&

@@ -190,6 +189,6 @@ isLiveQueryOperationDefinitionNode(getOperationASTFromRequest(request))) {

handleSDL(pointer, fetch, options) {
const defaultMethod = this.getDefaultMethodFromOptions(options === null || options === void 0 ? void 0 : options.method, 'GET');
const defaultMethod = this.getDefaultMethodFromOptions(options?.method, 'GET');
return new ValueOrPromise(() => fetch(pointer, {
method: defaultMethod,
headers: typeof (options === null || options === void 0 ? void 0 : options.headers) === 'function' ? options.headers() : options === null || options === void 0 ? void 0 : options.headers,
headers: typeof options?.headers === 'function' ? options.headers() : options?.headers,
}))

@@ -208,4 +207,4 @@ .then(response => response.text())

let executor;
if ((options === null || options === void 0 ? void 0 : options.handleAsSDL) || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = await this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, asyncImport);
if (options?.handleAsSDL || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = await this.getFetch(options?.customFetch, asyncImport);
source = await this.handleSDL(pointer, fetch, options);

@@ -230,3 +229,3 @@ if (!source.schema && !source.document && !source.rawSDL) {

}
if (options === null || options === void 0 ? void 0 : options.endpoint) {
if (options?.endpoint) {
executor = this.getExecutorAsync(options.endpoint, options);

@@ -238,3 +237,3 @@ }

executor,
batch: options === null || options === void 0 ? void 0 : options.batch,
batch: options?.batch,
});

@@ -252,4 +251,4 @@ }

let executor;
if ((options === null || options === void 0 ? void 0 : options.handleAsSDL) || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = this.getFetch(options === null || options === void 0 ? void 0 : options.customFetch, syncImport);
if (options?.handleAsSDL || pointer.endsWith('.graphql') || pointer.endsWith('.graphqls')) {
const fetch = this.getFetch(options?.customFetch, syncImport);
source = this.handleSDL(pointer, fetch, options);

@@ -274,3 +273,3 @@ if (!source.schema && !source.document && !source.rawSDL) {

}
if (options === null || options === void 0 ? void 0 : options.endpoint) {
if (options?.endpoint) {
executor = this.getExecutorSync(options.endpoint, options);

@@ -277,0 +276,0 @@ }

{
"name": "@graphql-tools/url-loader",
"version": "8.0.0-rc-20230519104353-b09f3180",
"version": "8.0.0-rc-20230519104627-f6fea064",
"description": "A set of utils for faster development of GraphQL tools",

@@ -10,8 +10,8 @@ "sideEffects": false,

"dependencies": {
"@graphql-tools/delegate": "10.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/executor-http": "1.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/executor-graphql-ws": "1.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/executor-legacy-ws": "1.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/utils": "10.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/wrap": "10.0.0-rc-20230519104353-b09f3180",
"@graphql-tools/delegate": "10.0.0-rc-20230519104627-f6fea064",
"@graphql-tools/executor-http": "1.0.0-rc-20230519104627-f6fea064",
"@graphql-tools/executor-graphql-ws": "1.0.0-rc-20230519104627-f6fea064",
"@graphql-tools/executor-legacy-ws": "1.0.0-rc-20230519104627-f6fea064",
"@graphql-tools/utils": "10.0.0-rc-20230519104627-f6fea064",
"@graphql-tools/wrap": "10.0.0-rc-20230519104627-f6fea064",
"@ardatan/sync-fetch": "^0.0.1",

@@ -18,0 +18,0 @@ "@whatwg-node/fetch": "^0.9.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc