@graphql-ez/client
Advanced tools
+9
-18
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
| import type { IncomingHttpHeaders } from 'http'; | ||
| import { Client } from 'undici'; | ||
| import { Client, Dispatcher } from 'undici'; | ||
| import type { SubscribeFunction } from './types'; | ||
@@ -18,3 +18,3 @@ import { GraphQLWSClientOptions } from './websockets/graphql-ws'; | ||
| } | ||
| export declare type QueryFunctionPostGet = <TData, TVariables = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { | ||
| export interface QueryOptions<TVariables = {}> { | ||
| variables?: TVariables; | ||
@@ -28,19 +28,10 @@ headers?: IncomingHttpHeaders; | ||
| operationName?: string; | ||
| }) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type QueryFunctionPost = <TData, TVariables = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { | ||
| variables?: TVariables; | ||
| headers?: IncomingHttpHeaders; | ||
| extensions?: Record<string, unknown>; | ||
| operationName?: string; | ||
| }) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type AssertedQuery = <TData = any, TVariables = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: { | ||
| variables?: TVariables; | ||
| headers?: IncomingHttpHeaders; | ||
| /** | ||
| * @default "POST" | ||
| * Customize and/or override the default undici request options | ||
| */ | ||
| method?: 'GET' | 'POST'; | ||
| extensions?: Record<string, unknown>; | ||
| operationName?: string; | ||
| }) => Promise<TData>; | ||
| requestOptions?: Partial<Dispatcher.RequestOptions>; | ||
| } | ||
| export declare type QueryFunctionPostGet = <TData, TVariables = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type QueryFunctionPost = <TData, TVariables = {}, TExtensions = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: Omit<QueryOptions, 'method'>) => Promise<ExecutionResult<TData, TExtensions>>; | ||
| export declare type AssertedQuery = <TData = any, TVariables = {}>(document: TypedDocumentNode<TData, TVariables> | string, options?: QueryOptions) => Promise<TData>; | ||
| export declare function EZClient(options: EZClientOptions): { | ||
@@ -66,3 +57,3 @@ query: QueryFunctionPostGet; | ||
| opaque: import("stream").PassThrough; | ||
| done: Promise<import("undici/types/dispatcher").StreamData>; | ||
| done: Promise<Dispatcher.StreamData>; | ||
| stop: () => void; | ||
@@ -69,0 +60,0 @@ }; |
+16
-28
@@ -38,4 +38,6 @@ 'use strict'; | ||
| super(message); | ||
| this.locations = locations; | ||
| this.extensions = extensions; | ||
| if (locations) | ||
| this.locations = locations; | ||
| if (extensions) | ||
| this.extensions = extensions; | ||
| } | ||
@@ -56,9 +58,9 @@ } | ||
| } | ||
| const query = async function query2(document, { variables, headers: headersArg, method = "POST", extensions, operationName } = {}) { | ||
| 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" ? { | ||
| 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", | ||
@@ -68,11 +70,14 @@ headers: __spreadValues({ | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables }), | ||
| 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"))) { | ||
| const errorBody = await body.text().catch((err) => { | ||
| console.error(err); | ||
| }) || "No body"; | ||
| console.error({ | ||
| body: await body.text(), | ||
| body: errorBody, | ||
| headers: headers2 | ||
| }); | ||
| throw Error("Unexpected content type received: " + headers2["content-type"]); | ||
| throw Error(`Unexpected content type received: ${headers2["content-type"]}, BodyText: ${errorBody}`); | ||
| } | ||
@@ -82,21 +87,4 @@ const json = await body.json(); | ||
| }; | ||
| const queryPost = async function queryPost2(document, { variables, headers: headersArg, extensions, operationName } = {}) { | ||
| var _a; | ||
| const { body, headers: headers2 } = await client.request({ | ||
| method: "POST", | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: utils.getQueryString(document), variables, operationName, extensions }), | ||
| path: endpointPathname | ||
| }); | ||
| if (!((_a = headers2["content-type"]) == null ? void 0 : _a.startsWith("application/json"))) { | ||
| console.error({ | ||
| body: await body.text(), | ||
| headers: headers2 | ||
| }); | ||
| throw Error("Unexpected content type received: " + headers2["content-type"]); | ||
| } | ||
| const json = await body.json(); | ||
| return json; | ||
| const queryPost = function queryPost2(document, options2) { | ||
| return query(document, __spreadProps(__spreadValues({}, options2), { method: "POST" })); | ||
| }; | ||
@@ -103,0 +91,0 @@ const assertedQuery = async (document, options2) => { |
+16
-28
@@ -34,4 +34,6 @@ import { documentParamsToURIParams } from '@graphql-ez/utils/clientURI'; | ||
| super(message); | ||
| this.locations = locations; | ||
| this.extensions = extensions; | ||
| if (locations) | ||
| this.locations = locations; | ||
| if (extensions) | ||
| this.extensions = extensions; | ||
| } | ||
@@ -52,9 +54,9 @@ } | ||
| } | ||
| const query = async function query2(document, { variables, headers: headersArg, method = "POST", extensions, operationName } = {}) { | ||
| 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" ? { | ||
| 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", | ||
@@ -64,11 +66,14 @@ headers: __spreadValues({ | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: getQueryString(document), variables }), | ||
| body: JSON.stringify({ query: getQueryString(document), extensions, operationName, variables }), | ||
| path: endpointPathname | ||
| }); | ||
| }, requestOptions)); | ||
| if (!((_a = headers2["content-type"]) == null ? void 0 : _a.startsWith("application/json"))) { | ||
| const errorBody = await body.text().catch((err) => { | ||
| console.error(err); | ||
| }) || "No body"; | ||
| console.error({ | ||
| body: await body.text(), | ||
| body: errorBody, | ||
| headers: headers2 | ||
| }); | ||
| throw Error("Unexpected content type received: " + headers2["content-type"]); | ||
| throw Error(`Unexpected content type received: ${headers2["content-type"]}, BodyText: ${errorBody}`); | ||
| } | ||
@@ -78,21 +83,4 @@ const json = await body.json(); | ||
| }; | ||
| const queryPost = async function queryPost2(document, { variables, headers: headersArg, extensions, operationName } = {}) { | ||
| var _a; | ||
| const { body, headers: headers2 } = await client.request({ | ||
| method: "POST", | ||
| headers: __spreadValues({ | ||
| "content-type": "application/json" | ||
| }, getHeaders(headersArg)), | ||
| body: JSON.stringify({ query: getQueryString(document), variables, operationName, extensions }), | ||
| path: endpointPathname | ||
| }); | ||
| if (!((_a = headers2["content-type"]) == null ? void 0 : _a.startsWith("application/json"))) { | ||
| console.error({ | ||
| body: await body.text(), | ||
| headers: headers2 | ||
| }); | ||
| throw Error("Unexpected content type received: " + headers2["content-type"]); | ||
| } | ||
| const json = await body.json(); | ||
| return json; | ||
| const queryPost = function queryPost2(document, options2) { | ||
| return query(document, __spreadProps(__spreadValues({}, options2), { method: "POST" })); | ||
| }; | ||
@@ -99,0 +87,0 @@ const assertedQuery = async (document, options2) => { |
+2
-2
| { | ||
| "name": "@graphql-ez/client", | ||
| "version": "0.4.2", | ||
| "version": "0.5.0", | ||
| "sideEffects": false, | ||
@@ -17,3 +17,3 @@ "peerDependencies": { | ||
| "@graphql-ez/utils": "^0.1.4", | ||
| "undici": "^4.16.0" | ||
| "undici": "^5.0.0" | ||
| }, | ||
@@ -20,0 +20,0 @@ "repository": { |
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
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
588404
-1.16%3390
-1.63%+ Added
+ Added
- Removed
Updated