@graphql-ez/client
Advanced tools
+3
-3
@@ -32,5 +32,5 @@ /// <reference types="node" /> | ||
| } | ||
| export declare type QueryFunctionPostGet = <TData, TVariables extends Record<string, any> = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions<TVariables>) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type QueryFunctionPost = <TData, TVariables extends Record<string, any> = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: Omit<QueryOptions<TVariables>, 'method'>) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type AssertedQuery = <TData = any, TVariables extends Record<string, any> = Record<string, unknown>>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions<TVariables>) => Promise<TData>; | ||
| export type QueryFunctionPostGet = <TData, TVariables extends Record<string, any> = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions<TVariables>) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export type QueryFunctionPost = <TData, TVariables extends Record<string, any> = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: Omit<QueryOptions<TVariables>, 'method'>) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export type AssertedQuery = <TData = any, TVariables extends Record<string, any> = Record<string, unknown>>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions<TVariables>) => Promise<TData>; | ||
| export declare function EZClient(options: EZClientOptions): EZClientInstance; | ||
@@ -37,0 +37,0 @@ export interface EZClientInstance { |
+32
-36
@@ -16,21 +16,2 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| class GraphQLErrorJSON extends Error { | ||
@@ -47,27 +28,42 @@ constructor(message, locations, extensions) { | ||
| const endpoint = new URL(options.endpoint); | ||
| const websocketEndpoint = url.getURLWebsocketVersion(typeof options.endpoint === "string" ? options.endpoint : options.endpoint.href).href; | ||
| const websocketEndpoint = url.getURLWebsocketVersion( | ||
| typeof options.endpoint === "string" ? options.endpoint : options.endpoint.href | ||
| ).href; | ||
| const endpointHref = endpoint.href; | ||
| const endpointOrigin = endpoint.origin; | ||
| const endpointPathname = endpoint.pathname; | ||
| const client = new undici.Pool(endpointOrigin, __spreadValues({}, options.undiciOptions)); | ||
| const client = new undici.Pool(endpointOrigin, { | ||
| ...options.undiciOptions | ||
| }); | ||
| const graphqlWS = graphqlWs.createGraphQLWSWebsocketsClient(websocketEndpoint, options.graphQLWSClientOptions); | ||
| const legacyTransport = subscriptionsTransport.createSubscriptionsTransportWebsocketsClient(websocketEndpoint, options.subscriptionsTransportClientOptions); | ||
| const legacyTransport = subscriptionsTransport.createSubscriptionsTransportWebsocketsClient( | ||
| websocketEndpoint, | ||
| options.subscriptionsTransportClientOptions | ||
| ); | ||
| const headers = object.cleanObject(options.headers); | ||
| function getHeaders(headersArg) { | ||
| return object.cleanObject(__spreadValues(__spreadValues({}, headers), headersArg)); | ||
| return object.cleanObject({ | ||
| ...headers, | ||
| ...headersArg | ||
| }); | ||
| } | ||
| const query = async function query2(document, { variables, headers: headersArg, method = "POST", extensions, operationName, requestOptions } = {}) { | ||
| var _a; | ||
| const { body, headers: headers2 } = await client.request(method === "GET" ? __spreadValues({ | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + clientURI.documentParamsToURIParams({ query: utils.getQueryString(document), extensions, operationName, variables }) | ||
| }, requestOptions) : __spreadValues({ | ||
| method: "POST", | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), extensions, operationName, variables }), | ||
| path: endpointPathname | ||
| }, requestOptions)); | ||
| const { body, headers: headers2 } = await client.request( | ||
| method === "GET" ? { | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + clientURI.documentParamsToURIParams({ query: utils.getQueryString(document), extensions, operationName, variables }), | ||
| ...requestOptions | ||
| } : { | ||
| method: "POST", | ||
| headers: { | ||
| "content-type": "application/json", | ||
| ...getHeaders(headersArg) | ||
| }, | ||
| body: JSON.stringify({ query: utils.getQueryString(document), extensions, operationName, variables }), | ||
| path: endpointPathname, | ||
| ...requestOptions | ||
| } | ||
| ); | ||
| if (!((_a = headers2["content-type"]) == null ? void 0 : _a.startsWith("application/json"))) { | ||
@@ -81,3 +77,3 @@ const errorBody = await body.text().catch(() => null) || "No body"; | ||
| const queryPost = function queryPost2(document, options2) { | ||
| return query(document, __spreadProps(__spreadValues({}, options2), { method: "POST" })); | ||
| return query(document, { ...options2, method: "POST" }); | ||
| }; | ||
@@ -84,0 +80,0 @@ const assertedQuery = async (document, options2) => { |
+32
-36
@@ -12,21 +12,2 @@ import { documentParamsToURIParams } from '@graphql-ez/utils/clientURI'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| class GraphQLErrorJSON extends Error { | ||
@@ -43,27 +24,42 @@ constructor(message, locations, extensions) { | ||
| const endpoint = new URL(options.endpoint); | ||
| const websocketEndpoint = getURLWebsocketVersion(typeof options.endpoint === "string" ? options.endpoint : options.endpoint.href).href; | ||
| const websocketEndpoint = getURLWebsocketVersion( | ||
| typeof options.endpoint === "string" ? options.endpoint : options.endpoint.href | ||
| ).href; | ||
| const endpointHref = endpoint.href; | ||
| const endpointOrigin = endpoint.origin; | ||
| const endpointPathname = endpoint.pathname; | ||
| const client = new Pool(endpointOrigin, __spreadValues({}, options.undiciOptions)); | ||
| const client = new Pool(endpointOrigin, { | ||
| ...options.undiciOptions | ||
| }); | ||
| const graphqlWS = createGraphQLWSWebsocketsClient(websocketEndpoint, options.graphQLWSClientOptions); | ||
| const legacyTransport = createSubscriptionsTransportWebsocketsClient(websocketEndpoint, options.subscriptionsTransportClientOptions); | ||
| const legacyTransport = createSubscriptionsTransportWebsocketsClient( | ||
| websocketEndpoint, | ||
| options.subscriptionsTransportClientOptions | ||
| ); | ||
| const headers = cleanObject(options.headers); | ||
| function getHeaders(headersArg) { | ||
| return cleanObject(__spreadValues(__spreadValues({}, headers), headersArg)); | ||
| return cleanObject({ | ||
| ...headers, | ||
| ...headersArg | ||
| }); | ||
| } | ||
| const query = async function query2(document, { variables, headers: headersArg, method = "POST", extensions, operationName, requestOptions } = {}) { | ||
| var _a; | ||
| const { body, headers: headers2 } = await client.request(method === "GET" ? __spreadValues({ | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + documentParamsToURIParams({ query: getQueryString(document), extensions, operationName, variables }) | ||
| }, requestOptions) : __spreadValues({ | ||
| method: "POST", | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: getQueryString(document), extensions, operationName, variables }), | ||
| path: endpointPathname | ||
| }, requestOptions)); | ||
| const { body, headers: headers2 } = await client.request( | ||
| method === "GET" ? { | ||
| method: "GET", | ||
| headers: getHeaders(headersArg), | ||
| path: endpointPathname + documentParamsToURIParams({ query: getQueryString(document), extensions, operationName, variables }), | ||
| ...requestOptions | ||
| } : { | ||
| method: "POST", | ||
| headers: { | ||
| "content-type": "application/json", | ||
| ...getHeaders(headersArg) | ||
| }, | ||
| body: JSON.stringify({ query: getQueryString(document), extensions, operationName, variables }), | ||
| path: endpointPathname, | ||
| ...requestOptions | ||
| } | ||
| ); | ||
| if (!((_a = headers2["content-type"]) == null ? void 0 : _a.startsWith("application/json"))) { | ||
@@ -77,3 +73,3 @@ const errorBody = await body.text().catch(() => null) || "No body"; | ||
| const queryPost = function queryPost2(document, options2) { | ||
| return query(document, __spreadProps(__spreadValues({}, options2), { method: "POST" })); | ||
| return query(document, { ...options2, method: "POST" }); | ||
| }; | ||
@@ -80,0 +76,0 @@ const assertedQuery = async (document, options2) => { |
+4
-5
| { | ||
| "name": "@graphql-ez/client", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "sideEffects": false, | ||
@@ -16,4 +16,4 @@ "peerDependencies": { | ||
| "dependencies": { | ||
| "@graphql-ez/utils": "^0.1.4", | ||
| "undici": "^5.0.0" | ||
| "@graphql-ez/utils": "^0.2.0", | ||
| "undici": "^5.14.0" | ||
| }, | ||
@@ -41,4 +41,3 @@ "repository": { | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "readme": "# @graphql-ez/client\n\nFully feature GraphQL Client for Node.js\n\n## Features\n\n- [x] [@graphql-typed-document-node](https://www.npmjs.com/package/@graphql-typed-document-node/core) support\n- [x] High performance HTTP/s using [undici](https://github.com/nodejs/undici)\n- [x] [graphql-ws](https://github.com/enisdenjo/graphql-ws) support\n- [x] Legacy [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) support\n- [x] [Defer and Stream](https://github.com/graphql/graphql-js/pull/2319) support\n- [x] [graphql-helix](https://github.com/contra/graphql-helix) SSE support\n- [x] [GraphQL Upload](https://github.com/jaydenseric/graphql-upload) support\n\n> By default if you only use the traditional GraphQL over HTTP, any other external dependency is not imported\n\n## Usage\n\n```ts\nimport { EZClient } from '@graphql-ez/client';\n\nexport const ezClient = EZClient({\n endpoint: 'http://localhost:8080/api/graphql',\n});\n```\n\n### HTTP\n\n```ts\nawait ezClient.query('query($n: Int!) { hello(n: $n) }', {\n variables: {\n n: 10,\n },\n // \"POST\" by default\n method: 'GET',\n});\n\nawait ezClient.mutation('mutation { hello }', {\n headers: {\n authorization: 'foo',\n },\n});\n\n// Automatically throw if any error is returned\nawait ezClient.assertedQuery('mutation { hello }', {\n // ...\n});\n```\n\n### Websockets\n\n#### graphql-ws\n\n```ts\nconst { iterator, unsubscribe } = ezClient.websockets.subscribe('subscription{ping}');\n\nfor await (const value of iterator) {\n console.log(value);\n}\n\nawait unsubscribe();\n\n(await ezClient.websockets.client).dispose();\n```\n\n#### Legacy subscriptions-transport-ws\n\n```ts\nconst { iterator, unsubscribe } = ezClient.websockets.legacy.subscribe('subscription{ping}');\n\nfor await (const value of iterator) {\n console.log(value);\n}\n\nawait unsubscribe();\n\n(await ezClient.websockets.legacy.client).close();\n```\n\n### Defer and Stream\n\n```ts\nconst { iterator } = ezClient.stream('{stream @stream(initialCount: 1)}');\n\nlet i = 0;\nfor await (const value of iterator) {\n switch (++i) {\n case 1:\n expect(value).toContain(`{\"data\":{\"stream\":[\"A\"]},\"hasNext\":true}`);\n break;\n case 2:\n expect(value).toContain(`{\"data\":\"B\",\"path\":[\"stream\",1],\"hasNext\":true}`);\n break;\n case 3:\n expect(value).toContain(`{\"data\":\"C\",\"path\":[\"stream\",2],\"hasNext\":true}`);\n break;\n }\n}\n```\n\n### SSE\n\n```ts\nconst { iterator, unsubscribe } = ezClient.sseSubscribe('subscription{ping}');\n\nfor await (const value of iterator) {\n console.log(value);\n}\n\nawait unsubscribe();\n```\n\n### GraphQL Upload\n\n```ts\nconst { data, errors } = await ezClient.uploadQuery('mutation($file: Upload!) { uploadFile(file:$file) }', {\n variables: {\n file: Buffer.from('hello-world'),\n },\n});\n```\n\n## LICENSE\n\nMIT\n" | ||
| } | ||
| } |
+1
-2
@@ -1,2 +0,1 @@ | ||
| /// <reference types="eventsource" /> | ||
| /// <reference types="node" /> | ||
@@ -6,5 +5,5 @@ import type { IncomingHttpHeaders } from 'http'; | ||
| import type { SubscribeFunction } from './types'; | ||
| export declare type SubscribeSSE = SubscribeFunction<EventSourceInitDict & { | ||
| export type SubscribeSSE = SubscribeFunction<EventSourceInitDict & { | ||
| headers?: Partial<IncomingHttpHeaders>; | ||
| }>; | ||
| export declare function createSSESubscription(href: string, getHeaders: (headers: IncomingHttpHeaders | undefined) => IncomingHttpHeaders): SubscribeSSE; |
+15
-48
@@ -9,48 +9,11 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| var __objRest = (source, exclude) => { | ||
| var target = {}; | ||
| for (var prop in source) | ||
| if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
| target[prop] = source[prop]; | ||
| if (source != null && __getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(source)) { | ||
| if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
| target[prop] = source[prop]; | ||
| } | ||
| return target; | ||
| }; | ||
| function createSSESubscription(href, getHeaders) { | ||
| const subscribe = function subscribe2(document, _a = {}) { | ||
| var _b = _a, { | ||
| variables, | ||
| extensions, | ||
| operationName, | ||
| onData, | ||
| headers | ||
| } = _b, rest = __objRest(_b, [ | ||
| "variables", | ||
| "extensions", | ||
| "operationName", | ||
| "onData", | ||
| "headers" | ||
| ]); | ||
| const subscribe = function subscribe2(document, { | ||
| variables, | ||
| extensions, | ||
| operationName, | ||
| onData, | ||
| headers, | ||
| ...rest | ||
| } = {}) { | ||
| let deferValuePromise = promise.createDeferredPromise(); | ||
@@ -60,5 +23,9 @@ let eventSource; | ||
| const { EventSource } = await utils.lazyDeps; | ||
| 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) | ||
| })); | ||
| 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) : ""}`, | ||
| { | ||
| ...rest, | ||
| headers: getHeaders(headers) | ||
| } | ||
| ); | ||
| try { | ||
@@ -65,0 +32,0 @@ eventSource.onerror = (evt) => { |
+15
-48
@@ -5,48 +5,11 @@ import { createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| var __objRest = (source, exclude) => { | ||
| var target = {}; | ||
| for (var prop in source) | ||
| if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
| target[prop] = source[prop]; | ||
| if (source != null && __getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(source)) { | ||
| if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
| target[prop] = source[prop]; | ||
| } | ||
| return target; | ||
| }; | ||
| function createSSESubscription(href, getHeaders) { | ||
| const subscribe = function subscribe2(document, _a = {}) { | ||
| var _b = _a, { | ||
| variables, | ||
| extensions, | ||
| operationName, | ||
| onData, | ||
| headers | ||
| } = _b, rest = __objRest(_b, [ | ||
| "variables", | ||
| "extensions", | ||
| "operationName", | ||
| "onData", | ||
| "headers" | ||
| ]); | ||
| const subscribe = function subscribe2(document, { | ||
| variables, | ||
| extensions, | ||
| operationName, | ||
| onData, | ||
| headers, | ||
| ...rest | ||
| } = {}) { | ||
| let deferValuePromise = createDeferredPromise(); | ||
@@ -56,5 +19,9 @@ let eventSource; | ||
| const { EventSource } = await lazyDeps; | ||
| 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) | ||
| })); | ||
| 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) : ""}`, | ||
| { | ||
| ...rest, | ||
| headers: getHeaders(headers) | ||
| } | ||
| ); | ||
| try { | ||
@@ -61,0 +28,0 @@ eventSource.onerror = (evt) => { |
+2
-1
| /// <reference types="node" /> | ||
| /// <reference types="node" /> | ||
| import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
@@ -6,3 +7,3 @@ import type { IncomingHttpHeaders } from 'http'; | ||
| import type { Pool, Dispatcher } from 'undici'; | ||
| export declare type Stream = <TData, TVariables extends Record<string, unknown> = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { | ||
| export type Stream = <TData, TVariables extends Record<string, unknown> = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { | ||
| variables?: TVariables; | ||
@@ -9,0 +10,0 @@ headers?: IncomingHttpHeaders; |
+27
-39
@@ -10,18 +10,2 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createStreamHelper(pool, path, getHeaders) { | ||
@@ -50,27 +34,31 @@ return function stream$1(document, { | ||
| }; | ||
| const done = pool.stream({ | ||
| path, | ||
| method: "POST", | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables, extensions, operationName }), | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| opaque | ||
| }, ({ opaque: opaque2 }) => { | ||
| assert["default"](opaque2 instanceof stream.PassThrough); | ||
| (async () => { | ||
| try { | ||
| for await (const chunk of opaque2) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(chunk); | ||
| deferValuePromise = promise.createDeferredPromise(); | ||
| const done = pool.stream( | ||
| { | ||
| path, | ||
| method: "POST", | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables, extensions, operationName }), | ||
| headers: { | ||
| "content-type": "application/json", | ||
| ...getHeaders(headersArg) | ||
| }, | ||
| opaque | ||
| }, | ||
| ({ opaque: opaque2 }) => { | ||
| assert["default"](opaque2 instanceof stream.PassThrough); | ||
| (async () => { | ||
| try { | ||
| for await (const chunk of opaque2) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(chunk); | ||
| deferValuePromise = promise.createDeferredPromise(); | ||
| } | ||
| } catch (err) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| } | ||
| } catch (err) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| } | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| })(); | ||
| return opaque2; | ||
| }); | ||
| })(); | ||
| return opaque2; | ||
| } | ||
| ); | ||
| assert["default"](opaque instanceof stream.PassThrough); | ||
@@ -77,0 +65,0 @@ return { |
+27
-39
@@ -6,18 +6,2 @@ import { createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createStreamHelper(pool, path, getHeaders) { | ||
@@ -46,27 +30,31 @@ return function stream(document, { | ||
| }; | ||
| const done = pool.stream({ | ||
| path, | ||
| method: "POST", | ||
| body: JSON.stringify({ query: getQueryString(document), variables, extensions, operationName }), | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| opaque | ||
| }, ({ opaque: opaque2 }) => { | ||
| assert(opaque2 instanceof PassThrough); | ||
| (async () => { | ||
| try { | ||
| for await (const chunk of opaque2) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(chunk); | ||
| deferValuePromise = createDeferredPromise(); | ||
| const done = pool.stream( | ||
| { | ||
| path, | ||
| method: "POST", | ||
| body: JSON.stringify({ query: getQueryString(document), variables, extensions, operationName }), | ||
| headers: { | ||
| "content-type": "application/json", | ||
| ...getHeaders(headersArg) | ||
| }, | ||
| opaque | ||
| }, | ||
| ({ opaque: opaque2 }) => { | ||
| assert(opaque2 instanceof PassThrough); | ||
| (async () => { | ||
| try { | ||
| for await (const chunk of opaque2) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(chunk); | ||
| deferValuePromise = createDeferredPromise(); | ||
| } | ||
| } catch (err) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| } | ||
| } catch (err) { | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| } | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| })(); | ||
| return opaque2; | ||
| }); | ||
| })(); | ||
| return opaque2; | ||
| } | ||
| ); | ||
| assert(opaque instanceof PassThrough); | ||
@@ -73,0 +61,0 @@ return { |
+1
-1
| import type { ExecutionResult } from 'graphql'; | ||
| import type { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
| export declare type SubscribeOptions<TResult, TVariables extends Record<string, unknown>, TExtensions extends Record<string, unknown> = Record<string, unknown>, TExtra extends {} = {}> = { | ||
| export type SubscribeOptions<TResult, TVariables extends Record<string, unknown>, TExtensions extends Record<string, unknown> = Record<string, unknown>, TExtra extends {} = {}> = { | ||
| onData?: (data: ExecutionResult<TResult>) => void; | ||
@@ -5,0 +5,0 @@ variables?: TVariables; |
+2
-21
@@ -8,21 +8,2 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| function createUploadQuery(endpoint, getHeaders, defaultQuery) { | ||
@@ -41,3 +22,3 @@ return async function(document, { variables, headers: headersArg, extensions, operationName } = {}) { | ||
| const form = new FormData(); | ||
| form.append("operations", JSON.stringify(__spreadProps(__spreadValues({}, extracted.clone), { extensions }))); | ||
| form.append("operations", JSON.stringify({ ...extracted.clone, extensions })); | ||
| const map = {}; | ||
@@ -55,3 +36,3 @@ let i = 0; | ||
| method: "POST", | ||
| headers: __spreadValues(__spreadValues({}, getHeaders(headersArg)), form.getHeaders()), | ||
| headers: { ...getHeaders(headersArg), ...form.getHeaders() }, | ||
| body: form | ||
@@ -58,0 +39,0 @@ }); |
+2
-21
| import { ReadStream } from 'fs'; | ||
| import { lazyDeps, getQueryString } from './utils.mjs'; | ||
| var __defProp = Object.defineProperty; | ||
| var __defProps = Object.defineProperties; | ||
| var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
| function createUploadQuery(endpoint, getHeaders, defaultQuery) { | ||
@@ -36,3 +17,3 @@ return async function(document, { variables, headers: headersArg, extensions, operationName } = {}) { | ||
| const form = new FormData(); | ||
| form.append("operations", JSON.stringify(__spreadProps(__spreadValues({}, extracted.clone), { extensions }))); | ||
| form.append("operations", JSON.stringify({ ...extracted.clone, extensions })); | ||
| const map = {}; | ||
@@ -50,3 +31,3 @@ let i = 0; | ||
| method: "POST", | ||
| headers: __spreadValues(__spreadValues({}, getHeaders(headersArg)), form.getHeaders()), | ||
| headers: { ...getHeaders(headersArg), ...form.getHeaders() }, | ||
| body: form | ||
@@ -53,0 +34,0 @@ }); |
+27
-39
@@ -8,26 +8,11 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createGraphQLWSWebsocketsClient(wsEndpoint, options = {}) { | ||
| const client = promise.LazyPromise(async () => { | ||
| const { ws, createGraphQLWSClient } = await utils.lazyDeps; | ||
| return createGraphQLWSClient(__spreadValues({ | ||
| return createGraphQLWSClient({ | ||
| url: wsEndpoint, | ||
| webSocketImpl: ws, | ||
| lazy: true | ||
| }, options)); | ||
| lazy: true, | ||
| ...options | ||
| }); | ||
| }); | ||
@@ -53,24 +38,27 @@ const subscribe = function subscribe2(query, { onData, variables, operationName, extensions } = {}) { | ||
| try { | ||
| unsubscribeFn = (await client).subscribe({ | ||
| query: utils.getQueryString(query), | ||
| variables, | ||
| operationName, | ||
| extensions | ||
| }, { | ||
| next(value) { | ||
| onData == null ? void 0 : onData(value); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(value); | ||
| deferValuePromise = promise.createDeferredPromise(); | ||
| unsubscribeFn = (await client).subscribe( | ||
| { | ||
| query: utils.getQueryString(query), | ||
| variables, | ||
| operationName, | ||
| extensions | ||
| }, | ||
| error(err) { | ||
| reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| }, | ||
| complete() { | ||
| resolve(); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| { | ||
| next(value) { | ||
| onData == null ? void 0 : onData(value); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(value); | ||
| deferValuePromise = promise.createDeferredPromise(); | ||
| }, | ||
| error(err) { | ||
| reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| }, | ||
| complete() { | ||
| resolve(); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| } | ||
| } | ||
| }); | ||
| ); | ||
| } catch (err) { | ||
@@ -77,0 +65,0 @@ reject(err); |
| import { LazyPromise, createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import { lazyDeps, getQueryString } from '../utils.mjs'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createGraphQLWSWebsocketsClient(wsEndpoint, options = {}) { | ||
| const client = LazyPromise(async () => { | ||
| const { ws, createGraphQLWSClient } = await lazyDeps; | ||
| return createGraphQLWSClient(__spreadValues({ | ||
| return createGraphQLWSClient({ | ||
| url: wsEndpoint, | ||
| webSocketImpl: ws, | ||
| lazy: true | ||
| }, options)); | ||
| lazy: true, | ||
| ...options | ||
| }); | ||
| }); | ||
@@ -48,24 +33,27 @@ const subscribe = function subscribe2(query, { onData, variables, operationName, extensions } = {}) { | ||
| try { | ||
| unsubscribeFn = (await client).subscribe({ | ||
| query: getQueryString(query), | ||
| variables, | ||
| operationName, | ||
| extensions | ||
| }, { | ||
| next(value) { | ||
| onData == null ? void 0 : onData(value); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(value); | ||
| deferValuePromise = createDeferredPromise(); | ||
| unsubscribeFn = (await client).subscribe( | ||
| { | ||
| query: getQueryString(query), | ||
| variables, | ||
| operationName, | ||
| extensions | ||
| }, | ||
| error(err) { | ||
| reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| }, | ||
| complete() { | ||
| resolve(); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| { | ||
| next(value) { | ||
| onData == null ? void 0 : onData(value); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(value); | ||
| deferValuePromise = createDeferredPromise(); | ||
| }, | ||
| error(err) { | ||
| reject(err); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.reject(err); | ||
| deferValuePromise = null; | ||
| }, | ||
| complete() { | ||
| resolve(); | ||
| deferValuePromise == null ? void 0 : deferValuePromise.resolve(null); | ||
| deferValuePromise = null; | ||
| } | ||
| } | ||
| }); | ||
| ); | ||
| } catch (err) { | ||
@@ -72,0 +60,0 @@ reject(err); |
@@ -8,24 +8,13 @@ 'use strict'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createSubscriptionsTransportWebsocketsClient(wsEndpoint, options = {}) { | ||
| const client = promise.LazyPromise(async () => { | ||
| const { SubscriptionsTransportClient, ws } = await utils.lazyDeps; | ||
| return new SubscriptionsTransportClient(wsEndpoint, __spreadValues({ | ||
| lazy: true | ||
| }, options), ws); | ||
| return new SubscriptionsTransportClient( | ||
| wsEndpoint, | ||
| { | ||
| lazy: true, | ||
| ...options | ||
| }, | ||
| ws | ||
| ); | ||
| }); | ||
@@ -32,0 +21,0 @@ const subscribe = function subscribe2(query, { onData, variables, operationName, extensions } = {}) { |
| import { LazyPromise, createDeferredPromise } from '@graphql-ez/utils/promise'; | ||
| import { lazyDeps, getQueryString } from '../utils.mjs'; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __spreadValues = (a, b) => { | ||
| for (var prop in b || (b = {})) | ||
| if (__hasOwnProp.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| if (__getOwnPropSymbols) | ||
| for (var prop of __getOwnPropSymbols(b)) { | ||
| if (__propIsEnum.call(b, prop)) | ||
| __defNormalProp(a, prop, b[prop]); | ||
| } | ||
| return a; | ||
| }; | ||
| function createSubscriptionsTransportWebsocketsClient(wsEndpoint, options = {}) { | ||
| const client = LazyPromise(async () => { | ||
| const { SubscriptionsTransportClient, ws } = await lazyDeps; | ||
| return new SubscriptionsTransportClient(wsEndpoint, __spreadValues({ | ||
| lazy: true | ||
| }, options), ws); | ||
| return new SubscriptionsTransportClient( | ||
| wsEndpoint, | ||
| { | ||
| lazy: true, | ||
| ...options | ||
| }, | ||
| ws | ||
| ); | ||
| }); | ||
@@ -27,0 +16,0 @@ const subscribe = function subscribe2(query, { onData, variables, operationName, extensions } = {}) { |
Sorry, the diff of this file is too big to display
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
574215
-1.86%3116
-5.55%19
18.75%+ Added
- Removed
Updated
Updated