@graphql-ez/client
Advanced tools
+2
-1
| /// <reference types="node" /> | ||
| /// <reference types="eventsource" /> | ||
| import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
| import { ExecutionResult } from 'graphql'; | ||
| import type { ExecutionResult } from 'graphql'; | ||
| import type { IncomingHttpHeaders } from 'http'; | ||
@@ -15,2 +15,3 @@ import { Client } from 'undici'; | ||
| subscriptionsTransportClientOptions?: SubscriptionsTransportClientOptions; | ||
| unidiClientOptions?: Client.Options; | ||
| } | ||
@@ -17,0 +18,0 @@ export declare type QueryFunctionPostGet = <TData, TVariables = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { |
+5
-7
@@ -8,3 +8,2 @@ 'use strict'; | ||
| const url = require('@graphql-ez/utils/url'); | ||
| const graphql = require('graphql'); | ||
| const undici = require('undici'); | ||
@@ -14,2 +13,3 @@ const sse = require('./sse.js'); | ||
| const upload = require('./upload.js'); | ||
| const utils = require('./utils.js'); | ||
| const graphqlWs = require('./websockets/graphql-ws.js'); | ||
@@ -50,3 +50,3 @@ const subscriptionsTransport = require('./websockets/subscriptions-transport.js'); | ||
| const endpointPathname = endpoint.pathname; | ||
| const client = new undici.Client(endpointOrigin); | ||
| const client = new undici.Client(endpointOrigin, options.unidiClientOptions); | ||
| const graphqlWS = graphqlWs.createGraphQLWSWebsocketsClient(websocketEndpoint, options.graphQLWSClientOptions); | ||
@@ -60,7 +60,6 @@ const legacyTransport = subscriptionsTransport.createSubscriptionsTransportWebsocketsClient(websocketEndpoint, options.subscriptionsTransportClientOptions); | ||
| var _a; | ||
| const queryString = typeof document === "string" ? document : graphql.print(document); | ||
| const { body, headers: headers2 } = await client.request(method === "GET" ? { | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + clientURI.documentParamsToURIParams({ query: queryString, extensions, operationName, variables }) | ||
| path: endpointPathname + clientURI.documentParamsToURIParams({ query: utils.getQueryString(document), extensions, operationName, variables }) | ||
| } : { | ||
@@ -71,3 +70,3 @@ method: "POST", | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: queryString, variables }), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables }), | ||
| path: endpointPathname | ||
@@ -87,3 +86,2 @@ }); | ||
| var _a; | ||
| const queryString = typeof document === "string" ? document : graphql.print(document); | ||
| const { body, headers: headers2 } = await client.request({ | ||
@@ -94,3 +92,3 @@ method: "POST", | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: queryString, variables, operationName, extensions }), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables, operationName, extensions }), | ||
| path: endpointPathname | ||
@@ -97,0 +95,0 @@ }); |
+5
-7
| import { documentParamsToURIParams } from '@graphql-ez/utils/clientURI'; | ||
| import { cleanObject } from '@graphql-ez/utils/object'; | ||
| import { getURLWebsocketVersion } from '@graphql-ez/utils/url'; | ||
| import { print } from 'graphql'; | ||
| import { Client } from 'undici'; | ||
@@ -9,2 +8,3 @@ import { createSSESubscription } from './sse.mjs'; | ||
| import { createUploadQuery } from './upload.mjs'; | ||
| import { getQueryString } from './utils.mjs'; | ||
| import { createGraphQLWSWebsocketsClient } from './websockets/graphql-ws.mjs'; | ||
@@ -45,3 +45,3 @@ import { createSubscriptionsTransportWebsocketsClient } from './websockets/subscriptions-transport.mjs'; | ||
| const endpointPathname = endpoint.pathname; | ||
| const client = new Client(endpointOrigin); | ||
| const client = new Client(endpointOrigin, options.unidiClientOptions); | ||
| const graphqlWS = createGraphQLWSWebsocketsClient(websocketEndpoint, options.graphQLWSClientOptions); | ||
@@ -55,7 +55,6 @@ const legacyTransport = createSubscriptionsTransportWebsocketsClient(websocketEndpoint, options.subscriptionsTransportClientOptions); | ||
| var _a; | ||
| const queryString = typeof document === "string" ? document : print(document); | ||
| const { body, headers: headers2 } = await client.request(method === "GET" ? { | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + documentParamsToURIParams({ query: queryString, extensions, operationName, variables }) | ||
| path: endpointPathname + documentParamsToURIParams({ query: getQueryString(document), extensions, operationName, variables }) | ||
| } : { | ||
@@ -66,3 +65,3 @@ method: "POST", | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: queryString, variables }), | ||
| body: JSON.stringify({ query: getQueryString(document), variables }), | ||
| path: endpointPathname | ||
@@ -82,3 +81,2 @@ }); | ||
| var _a; | ||
| const queryString = typeof document === "string" ? document : print(document); | ||
| const { body, headers: headers2 } = await client.request({ | ||
@@ -89,3 +87,3 @@ method: "POST", | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: queryString, variables, operationName, extensions }), | ||
| body: JSON.stringify({ query: getQueryString(document), variables, operationName, extensions }), | ||
| path: endpointPathname | ||
@@ -92,0 +90,0 @@ }); |
+2
-2
| { | ||
| "name": "@graphql-ez/client", | ||
| "version": "0.4.1", | ||
| "version": "0.4.2", | ||
| "sideEffects": false, | ||
@@ -17,3 +17,3 @@ "peerDependencies": { | ||
| "@graphql-ez/utils": "^0.1.4", | ||
| "undici": "^4.15.1" | ||
| "undici": "^4.16.0" | ||
| }, | ||
@@ -20,0 +20,0 @@ "repository": { |
+1
-2
@@ -55,3 +55,2 @@ 'use strict'; | ||
| ]); | ||
| const queryString = typeof document === "string" ? document : graphql.print(document); | ||
| let deferValuePromise = promise.createDeferredPromise(); | ||
@@ -61,3 +60,3 @@ let eventSource; | ||
| const { EventSource } = await utils.lazyDeps; | ||
| eventSource = new EventSource(`${href}?query=${encodeURIComponent(graphql.stripIgnoredCharacters(queryString))}${variables ? "&variables=" + encodeURIComponent(JSON.stringify(variables)) : ""}${extensions ? "&extensions=" + encodeURIComponent(JSON.stringify(extensions)) : ""}${operationName ? "&operationName=" + encodeURIComponent(operationName) : ""}`, __spreadProps(__spreadValues({}, rest), { | ||
| eventSource = new EventSource(`${href}?query=${encodeURIComponent(graphql.stripIgnoredCharacters(utils.getQueryString(document)))}${variables ? "&variables=" + encodeURIComponent(JSON.stringify(variables)) : ""}${extensions ? "&extensions=" + encodeURIComponent(JSON.stringify(extensions)) : ""}${operationName ? "&operationName=" + encodeURIComponent(operationName) : ""}`, __spreadProps(__spreadValues({}, rest), { | ||
| headers: getHeaders(headers) | ||
@@ -64,0 +63,0 @@ })); |
+3
-4
| import { createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import { print, stripIgnoredCharacters } from 'graphql'; | ||
| import { lazyDeps } from './utils.mjs'; | ||
| import { stripIgnoredCharacters } from 'graphql'; | ||
| import { lazyDeps, getQueryString } from './utils.mjs'; | ||
@@ -51,3 +51,2 @@ var __defProp = Object.defineProperty; | ||
| ]); | ||
| const queryString = typeof document === "string" ? document : print(document); | ||
| let deferValuePromise = createDeferredPromise(); | ||
@@ -57,3 +56,3 @@ let eventSource; | ||
| const { EventSource } = await lazyDeps; | ||
| eventSource = new EventSource(`${href}?query=${encodeURIComponent(stripIgnoredCharacters(queryString))}${variables ? "&variables=" + encodeURIComponent(JSON.stringify(variables)) : ""}${extensions ? "&extensions=" + encodeURIComponent(JSON.stringify(extensions)) : ""}${operationName ? "&operationName=" + encodeURIComponent(operationName) : ""}`, __spreadProps(__spreadValues({}, rest), { | ||
| eventSource = new EventSource(`${href}?query=${encodeURIComponent(stripIgnoredCharacters(getQueryString(document)))}${variables ? "&variables=" + encodeURIComponent(JSON.stringify(variables)) : ""}${extensions ? "&extensions=" + encodeURIComponent(JSON.stringify(extensions)) : ""}${operationName ? "&operationName=" + encodeURIComponent(operationName) : ""}`, __spreadProps(__spreadValues({}, rest), { | ||
| headers: getHeaders(headers) | ||
@@ -60,0 +59,0 @@ })); |
+2
-3
@@ -7,4 +7,4 @@ 'use strict'; | ||
| const assert = require('assert'); | ||
| const graphql = require('graphql'); | ||
| const stream = require('stream'); | ||
| const utils = require('./utils.js'); | ||
@@ -34,3 +34,2 @@ var __defProp = Object.defineProperty; | ||
| } = {}) { | ||
| const queryString = typeof document === "string" ? document : graphql.print(document); | ||
| let deferValuePromise = promise.createDeferredPromise(); | ||
@@ -55,3 +54,3 @@ async function* iteratorGenerator() { | ||
| method: "POST", | ||
| body: JSON.stringify({ query: queryString, variables, extensions, operationName }), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables, extensions, operationName }), | ||
| headers: __spreadValues({ | ||
@@ -58,0 +57,0 @@ "content-type": "application/json" |
+2
-3
| import { createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import assert from 'assert'; | ||
| import { print } from 'graphql'; | ||
| import { PassThrough } from 'stream'; | ||
| import { getQueryString } from './utils.mjs'; | ||
@@ -29,3 +29,2 @@ var __defProp = Object.defineProperty; | ||
| } = {}) { | ||
| const queryString = typeof document === "string" ? document : print(document); | ||
| let deferValuePromise = createDeferredPromise(); | ||
@@ -50,3 +49,3 @@ async function* iteratorGenerator() { | ||
| method: "POST", | ||
| body: JSON.stringify({ query: queryString, variables, extensions, operationName }), | ||
| body: JSON.stringify({ query: getQueryString(document), variables, extensions, operationName }), | ||
| headers: __spreadValues({ | ||
@@ -53,0 +52,0 @@ "content-type": "application/json" |
+1
-3
@@ -6,3 +6,2 @@ 'use strict'; | ||
| const fs = require('fs'); | ||
| const graphql = require('graphql'); | ||
| const utils = require('./utils.js'); | ||
@@ -32,5 +31,4 @@ | ||
| const { extractFiles, FormData, nodeFetch } = await utils.lazyDeps; | ||
| const queryString = typeof document === "string" ? document : graphql.print(document); | ||
| const mainBody = { | ||
| query: queryString, | ||
| query: utils.getQueryString(document), | ||
| variables, | ||
@@ -37,0 +35,0 @@ operationName |
+2
-4
| import { ReadStream } from 'fs'; | ||
| import { print } from 'graphql'; | ||
| import { lazyDeps } from './utils.mjs'; | ||
| import { lazyDeps, getQueryString } from './utils.mjs'; | ||
@@ -27,5 +26,4 @@ var __defProp = Object.defineProperty; | ||
| const { extractFiles, FormData, nodeFetch } = await lazyDeps; | ||
| const queryString = typeof document === "string" ? document : print(document); | ||
| const mainBody = { | ||
| query: queryString, | ||
| query: getQueryString(document), | ||
| variables, | ||
@@ -32,0 +30,0 @@ operationName |
+2
-0
@@ -0,1 +1,3 @@ | ||
| import { DocumentNode } from 'graphql'; | ||
| export declare const lazyDeps: Promise<typeof import("./deps.js")>; | ||
| export declare function getQueryString(document: DocumentNode | string): string; |
+13
-0
@@ -6,5 +6,18 @@ 'use strict'; | ||
| const promise = require('@graphql-ez/utils/promise'); | ||
| const graphql = require('graphql'); | ||
| const lazyDeps = promise.LazyPromise(() => Promise.resolve().then(function () { return require('./deps.js'); })); | ||
| const DocumentPrintCache = /* @__PURE__ */ new WeakMap(); | ||
| function getQueryString(document) { | ||
| if (typeof document === "string") | ||
| return document; | ||
| let queryString = DocumentPrintCache.get(document); | ||
| if (queryString == null) { | ||
| queryString = graphql.print(document); | ||
| DocumentPrintCache.set(document, queryString); | ||
| } | ||
| return queryString; | ||
| } | ||
| exports.getQueryString = getQueryString; | ||
| exports.lazyDeps = lazyDeps; |
+13
-1
| import { LazyPromise } from '@graphql-ez/utils/promise'; | ||
| import { print } from 'graphql'; | ||
| const lazyDeps = LazyPromise(() => import('./deps.js')); | ||
| const DocumentPrintCache = /* @__PURE__ */ new WeakMap(); | ||
| function getQueryString(document) { | ||
| if (typeof document === "string") | ||
| return document; | ||
| let queryString = DocumentPrintCache.get(document); | ||
| if (queryString == null) { | ||
| queryString = print(document); | ||
| DocumentPrintCache.set(document, queryString); | ||
| } | ||
| return queryString; | ||
| } | ||
| export { lazyDeps }; | ||
| export { getQueryString, lazyDeps }; |
@@ -5,5 +5,3 @@ 'use strict'; | ||
| const document = require('@graphql-ez/utils/document'); | ||
| const promise = require('@graphql-ez/utils/promise'); | ||
| const graphql = require('graphql'); | ||
| const utils = require('../utils.js'); | ||
@@ -56,3 +54,3 @@ | ||
| unsubscribeFn = (await client).subscribe({ | ||
| query: document.isDocumentNode(query) ? graphql.print(query) : query, | ||
| query: utils.getQueryString(query), | ||
| variables, | ||
@@ -59,0 +57,0 @@ operationName, |
@@ -1,5 +0,3 @@ | ||
| import { isDocumentNode } from '@graphql-ez/utils/document'; | ||
| import { LazyPromise, createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import { print } from 'graphql'; | ||
| import { lazyDeps } from '../utils.mjs'; | ||
| import { lazyDeps, getQueryString } from '../utils.mjs'; | ||
@@ -51,3 +49,3 @@ var __defProp = Object.defineProperty; | ||
| unsubscribeFn = (await client).subscribe({ | ||
| query: isDocumentNode(query) ? print(query) : query, | ||
| query: getQueryString(query), | ||
| variables, | ||
@@ -54,0 +52,0 @@ operationName, |
@@ -5,5 +5,3 @@ 'use strict'; | ||
| const document = require('@graphql-ez/utils/document'); | ||
| const promise = require('@graphql-ez/utils/promise'); | ||
| const graphql = require('graphql'); | ||
| const utils = require('../utils.js'); | ||
@@ -54,3 +52,3 @@ | ||
| const { subscribe: subscribe3 } = (await client).request({ | ||
| query: document.isDocumentNode(query) ? graphql.print(query) : query, | ||
| query: utils.getQueryString(query), | ||
| variables, | ||
@@ -57,0 +55,0 @@ operationName, |
@@ -1,5 +0,3 @@ | ||
| import { isDocumentNode } from '@graphql-ez/utils/document'; | ||
| import { LazyPromise, createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import { print } from 'graphql'; | ||
| import { lazyDeps } from '../utils.mjs'; | ||
| import { lazyDeps, getQueryString } from '../utils.mjs'; | ||
@@ -49,3 +47,3 @@ var __defProp = Object.defineProperty; | ||
| const { subscribe: subscribe3 } = (await client).request({ | ||
| query: isDocumentNode(query) ? print(query) : query, | ||
| query: getQueryString(query), | ||
| variables, | ||
@@ -52,0 +50,0 @@ operationName, |
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3446
0.23%595294
-0.02%Updated