New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/graphql-client

Package Overview
Dependencies
Maintainers
24
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/graphql-client - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

7

dist/graphql-client.d.ts

@@ -1,6 +0,8 @@

type CustomFetchApi = (url: string, init?: {
interface CustomRequestInit {
method?: string;
headers?: HeadersInit;
body?: string;
}) => Promise<Response>;
signal?: AbortSignal;
}
type CustomFetchApi = (url: string, init?: CustomRequestInit) => Promise<Response>;
type OperationVariables$1 = Record<string, any>;

@@ -70,2 +72,3 @@ type DataChunk = Buffer | Uint8Array;

retries?: number;
signal?: AbortSignal;
}

@@ -72,0 +75,0 @@ type RequestParams = [operation: string, options?: RequestOptions];

@@ -17,3 +17,3 @@ 'use strict';

// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = '1.1.0';
const DEFAULT_CLIENT_VERSION = '1.2.0';
const RETRY_WAIT_TIME = 1000;

@@ -20,0 +20,0 @@ const RETRIABLE_STATUS_CODES = [429, 503];

@@ -57,3 +57,3 @@ 'use strict';

return async (operation, options = {}) => {
const { variables, headers: overrideHeaders, url: overrideUrl, retries: overrideRetries, } = options;
const { variables, headers: overrideHeaders, url: overrideUrl, retries: overrideRetries, signal, } = options;
const body = JSON.stringify({

@@ -81,2 +81,3 @@ query: operation,

body,
signal,
},

@@ -83,0 +84,0 @@ ];

import { LogContentTypes, LogContent, Logger as BaseLogger, Headers, ClientResponse, FetchResponseBody, ClientStreamIterator } from '../graphql-client/types';
import { AllOperations, OperationVariables, ResponseWithType, ReturnData } from './operation-types';
export { AllOperations, InputMaybe, OperationVariables, ReturnData, ResponseWithType, } from './operation-types';
export type { AllOperations, InputMaybe, OperationVariables, ReturnData, ResponseWithType, } from './operation-types';
export interface UnsupportedApiVersionLog extends LogContent {

@@ -5,0 +5,0 @@ type: 'Unsupported_Api_Version';

@@ -1,6 +0,8 @@

export type CustomFetchApi = (url: string, init?: {
interface CustomRequestInit {
method?: string;
headers?: HeadersInit;
body?: string;
}) => Promise<Response>;
signal?: AbortSignal;
}
export type CustomFetchApi = (url: string, init?: CustomRequestInit) => Promise<Response>;
type OperationVariables = Record<string, any>;

@@ -70,2 +72,3 @@ export type DataChunk = Buffer | Uint8Array;

retries?: number;
signal?: AbortSignal;
}

@@ -72,0 +75,0 @@ export type RequestParams = [operation: string, options?: RequestOptions];

@@ -1,2 +0,2 @@

/*! shopify/graphql-client@1.1.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
/*! shopify/graphql-client@1.2.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
(function (global, factory) {

@@ -22,3 +22,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// This is value is replaced with package.json version during rollup build process
const DEFAULT_CLIENT_VERSION = '1.1.0';
const DEFAULT_CLIENT_VERSION = '1.2.0';
const RETRY_WAIT_TIME = 1000;

@@ -186,3 +186,3 @@ const RETRIABLE_STATUS_CODES = [429, 503];

return async (operation, options = {}) => {
const { variables, headers: overrideHeaders, url: overrideUrl, retries: overrideRetries, } = options;
const { variables, headers: overrideHeaders, url: overrideUrl, retries: overrideRetries, signal, } = options;
const body = JSON.stringify({

@@ -210,2 +210,3 @@ query: operation,

body,
signal,
},

@@ -212,0 +213,0 @@ ];

@@ -1,3 +0,3 @@

/*! shopify/graphql-client@1.1.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ShopifyGraphQLClient={})}(this,(function(e){"use strict";const r="GraphQL Client",t=0,n=3,s="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",o="Response returned unexpected Content-Type:",a="An unknown error has occurred. The API did not return a data object or any errors in its response.",i={json:"application/json",multipart:"multipart/mixed"},c="X-SDK-Variant",u="X-SDK-Version",d="shopify-graphql-client",l="1.1.0",f=1e3,h=[429,503],y=/@(defer)\b/i,p=/boundary="?([^=";]+)"?/i,m="\r\n\r\n";function w(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function g(e){return e instanceof Error?e.message:JSON.stringify(e)}function b(e){return e instanceof Error&&e.cause?e.cause:void 0}function x(e){return e.flatMap((({errors:e})=>e??[]))}function E({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<t||r>n))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than ${t} or greater than ${n}`)}function S(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function A(e,r){if(0===e.length)return r;const t={[e.pop()]:r};return 0===e.length?t:A(e,t)}function T(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=T(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function $([e,...r]){return r.reduce(T,{...e})}function j({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=f,retriableCodes:o=h}){const a=async(r,i,c)=>{const u=i+1,d=c+1;let l;try{if(l=await t(...r),e({type:"HTTP-Response",content:{requestParams:r,response:l}}),!l.ok&&o.includes(l.status)&&u<=d)throw new Error;return l}catch(t){if(u<=d){const t=l?.headers.get("Retry-After");return await async function(e){return new Promise((r=>setTimeout(r,e)))}(t?parseInt(t,10):s),e({type:"HTTP-Retry",content:{requestParams:r,lastResponse:l,retryAttempt:i,maxRetries:c}}),a(r,u,c)}throw new Error(w(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${g(t)}`,n))}};return a}async function k(e){const{errors:r,data:t,extensions:n}=await e.json();return{...S("data",t),...S("extensions",n),headers:e.headers,...r||!t?{errors:{networkStatusCode:e.status,message:w(r?s:a),...S("graphQLErrors",r),response:e}}:{}}}function R(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${g(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...S("errors",o),...S("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?A(r,e):{},...S("errors",t)})));return{data:1===a.length?a[0].data:$([...a.map((({data:e})=>e))]),...S("errors",x(a)),hasNext:n}}))}function I(e,r){if(e.length>0)throw new Error(s,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(a)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:n=fetch,retries:s=0,logger:a}){E({client:r,retries:s});const h={headers:e,url:t,retries:s},A=function(e){return r=>{e&&e(r)}}(a),T=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:i,headers:f,url:h,retries:y}=a,p=JSON.stringify({query:o,variables:i});E({client:r,retries:y});const m=Object.entries({...n,...f}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});m[c]||m[u]||(m[c]=d,m[u]=l);return e([h??t,{method:"POST",headers:m,body:p}],1,y??s)}}(j({customFetchApi:n,clientLogger:A,defaultRetryWaitTime:f}),h),L=function(e){return async(...r)=>{if(y.test(r[0]))throw new Error(w("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:n,statusText:s}=t,a=t.headers.get("content-type")||"";return t.ok?a.includes(i.json)?k(t):{errors:{networkStatusCode:n,message:w(`${o} ${a}`),response:t}}:{errors:{networkStatusCode:n,message:w(s),response:t}}}catch(e){return{errors:{message:g(e)}}}}}(T),N=function(e){return async(...r)=>{if(!y.test(r[0]))throw new Error(w("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:n}=t;if(!t.ok)throw new Error(n,{cause:t});const s=t.headers.get("content-type")||"";switch(!0){case s.includes(i.json):return function(e){return{async*[Symbol.asyncIterator](){const r=await k(e);yield{...r,hasNext:!1}}}}(t);case s.includes(i.multipart):return function(e,r){const t=(r??"").match(p),n=`--${t?t[1]:"-"}`;if(!e.body?.getReader&&!e.body[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});const s=async function*(e){const r=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(const t of e.body)yield r.decode(t);else{const t=e.body.getReader();let n;try{for(;!(n=await t.read()).done;)yield r.decode(n.value)}finally{t.cancel()}}}(e);let o,a={};return{async*[Symbol.asyncIterator](){try{let e=!0;for await(const r of function(e,r){return{async*[Symbol.asyncIterator](){try{let t="";for await(const n of e)if(t+=n,t.indexOf(r)>-1){const e=t.lastIndexOf(r),n=t.slice(0,e).split(r).filter((e=>e.trim().length>0)).map((e=>e.slice(e.indexOf(m)+m.length).trim()));n.length>0&&(yield n),t=t.slice(e+r.length),"--"===t.trim()&&(t="")}}catch(e){throw new Error(`Error occured while processing stream payload - ${g(e)}`)}}}}(s,n)){const t=R(r);o=t.find((e=>e.extensions))?.extensions??o;const n=x(t);a=$([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,I(n,a),yield{...S("data",a),...S("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=b(r);yield{...S("data",a),...S("extensions",o),errors:{message:w(g(r)),networkStatusCode:e.status,...S("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,s);default:throw new Error(`${o} ${s}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=b(e);yield{errors:{message:w(g(e)),...S("networkStatusCode",r?.status),...S("response",r)},hasNext:!1}}}}}}(T);return{config:h,fetch:T,request:L,requestStream:N}}}));
/*! shopify/graphql-client@1.2.0 -- Copyright (c) 2023-present, Shopify Inc. -- license (MIT): https://github.com/Shopify/shopify-app-js/blob/main/LICENSE.md */
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ShopifyGraphQLClient={})}(this,(function(e){"use strict";const r="GraphQL Client",t=0,n=3,s="An error occurred while fetching from the API. Review 'graphQLErrors' for details.",o="Response returned unexpected Content-Type:",a="An unknown error has occurred. The API did not return a data object or any errors in its response.",i={json:"application/json",multipart:"multipart/mixed"},c="X-SDK-Variant",u="X-SDK-Version",d="shopify-graphql-client",l="1.2.0",f=1e3,h=[429,503],y=/@(defer)\b/i,p=/boundary="?([^=";]+)"?/i,m="\r\n\r\n";function w(e,t=r){return e.startsWith(`${t}`)?e:`${t}: ${e}`}function g(e){return e instanceof Error?e.message:JSON.stringify(e)}function b(e){return e instanceof Error&&e.cause?e.cause:void 0}function x(e){return e.flatMap((({errors:e})=>e??[]))}function E({client:e,retries:r}){if(void 0!==r&&("number"!=typeof r||r<t||r>n))throw new Error(`${e}: The provided "retries" value (${r}) is invalid - it cannot be less than ${t} or greater than ${n}`)}function S(e,r){return r&&("object"!=typeof r||Array.isArray(r)||"object"==typeof r&&Object.keys(r).length>0)?{[e]:r}:{}}function A(e,r){if(0===e.length)return r;const t={[e.pop()]:r};return 0===e.length?t:A(e,t)}function T(e,r){return Object.keys(r||{}).reduce(((t,n)=>("object"==typeof r[n]||Array.isArray(r[n]))&&e[n]?(t[n]=T(e[n],r[n]),t):(t[n]=r[n],t)),Array.isArray(e)?[...e]:{...e})}function $([e,...r]){return r.reduce(T,{...e})}function j({clientLogger:e,customFetchApi:t=fetch,client:n=r,defaultRetryWaitTime:s=f,retriableCodes:o=h}){const a=async(r,i,c)=>{const u=i+1,d=c+1;let l;try{if(l=await t(...r),e({type:"HTTP-Response",content:{requestParams:r,response:l}}),!l.ok&&o.includes(l.status)&&u<=d)throw new Error;return l}catch(t){if(u<=d){const t=l?.headers.get("Retry-After");return await async function(e){return new Promise((r=>setTimeout(r,e)))}(t?parseInt(t,10):s),e({type:"HTTP-Retry",content:{requestParams:r,lastResponse:l,retryAttempt:i,maxRetries:c}}),a(r,u,c)}throw new Error(w(`${c>0?`Attempted maximum number of ${c} network retries. Last message - `:""}${g(t)}`,n))}};return a}async function k(e){const{errors:r,data:t,extensions:n}=await e.json();return{...S("data",t),...S("extensions",n),headers:e.headers,...r||!t?{errors:{networkStatusCode:e.status,message:w(r?s:a),...S("graphQLErrors",r),response:e}}:{}}}function R(e){return e.map((e=>{try{return JSON.parse(e)}catch(e){throw new Error(`Error in parsing multipart response - ${g(e)}`)}})).map((e=>{const{data:r,incremental:t,hasNext:n,extensions:s,errors:o}=e;if(!t)return{data:r||{},...S("errors",o),...S("extensions",s),hasNext:n};const a=t.map((({data:e,path:r,errors:t})=>({data:e&&r?A(r,e):{},...S("errors",t)})));return{data:1===a.length?a[0].data:$([...a.map((({data:e})=>e))]),...S("errors",x(a)),hasNext:n}}))}function I(e,r){if(e.length>0)throw new Error(s,{cause:{graphQLErrors:e}});if(0===Object.keys(r).length)throw new Error(a)}e.createGraphQLClient=function({headers:e,url:t,customFetchApi:n=fetch,retries:s=0,logger:a}){E({client:r,retries:s});const h={headers:e,url:t,retries:s},A=function(e){return r=>{e&&e(r)}}(a),T=function(e,{url:t,headers:n,retries:s}){return async(o,a={})=>{const{variables:i,headers:f,url:h,retries:y,signal:p}=a,m=JSON.stringify({query:o,variables:i});E({client:r,retries:y});const w=Object.entries({...n,...f}).reduce(((e,[r,t])=>(e[r]=Array.isArray(t)?t.join(", "):t.toString(),e)),{});w[c]||w[u]||(w[c]=d,w[u]=l);return e([h??t,{method:"POST",headers:w,body:m,signal:p}],1,y??s)}}(j({customFetchApi:n,clientLogger:A,defaultRetryWaitTime:f}),h),L=function(e){return async(...r)=>{if(y.test(r[0]))throw new Error(w("This operation will result in a streamable response - use requestStream() instead."));try{const t=await e(...r),{status:n,statusText:s}=t,a=t.headers.get("content-type")||"";return t.ok?a.includes(i.json)?k(t):{errors:{networkStatusCode:n,message:w(`${o} ${a}`),response:t}}:{errors:{networkStatusCode:n,message:w(s),response:t}}}catch(e){return{errors:{message:g(e)}}}}}(T),N=function(e){return async(...r)=>{if(!y.test(r[0]))throw new Error(w("This operation does not result in a streamable response - use request() instead."));try{const t=await e(...r),{statusText:n}=t;if(!t.ok)throw new Error(n,{cause:t});const s=t.headers.get("content-type")||"";switch(!0){case s.includes(i.json):return function(e){return{async*[Symbol.asyncIterator](){const r=await k(e);yield{...r,hasNext:!1}}}}(t);case s.includes(i.multipart):return function(e,r){const t=(r??"").match(p),n=`--${t?t[1]:"-"}`;if(!e.body?.getReader&&!e.body[Symbol.asyncIterator])throw new Error("API multipart response did not return an iterable body",{cause:e});const s=async function*(e){const r=new TextDecoder;if(e.body[Symbol.asyncIterator])for await(const t of e.body)yield r.decode(t);else{const t=e.body.getReader();let n;try{for(;!(n=await t.read()).done;)yield r.decode(n.value)}finally{t.cancel()}}}(e);let o,a={};return{async*[Symbol.asyncIterator](){try{let e=!0;for await(const r of function(e,r){return{async*[Symbol.asyncIterator](){try{let t="";for await(const n of e)if(t+=n,t.indexOf(r)>-1){const e=t.lastIndexOf(r),n=t.slice(0,e).split(r).filter((e=>e.trim().length>0)).map((e=>e.slice(e.indexOf(m)+m.length).trim()));n.length>0&&(yield n),t=t.slice(e+r.length),"--"===t.trim()&&(t="")}}catch(e){throw new Error(`Error occured while processing stream payload - ${g(e)}`)}}}}(s,n)){const t=R(r);o=t.find((e=>e.extensions))?.extensions??o;const n=x(t);a=$([a,...t.map((({data:e})=>e))]),e=t.slice(-1)[0].hasNext,I(n,a),yield{...S("data",a),...S("extensions",o),hasNext:e}}if(e)throw new Error("Response stream terminated unexpectedly")}catch(r){const t=b(r);yield{...S("data",a),...S("extensions",o),errors:{message:w(g(r)),networkStatusCode:e.status,...S("graphQLErrors",t?.graphQLErrors),response:e},hasNext:!1}}}}}(t,s);default:throw new Error(`${o} ${s}`,{cause:t})}}catch(e){return{async*[Symbol.asyncIterator](){const r=b(e);yield{errors:{message:w(g(e)),...S("networkStatusCode",r?.status),...S("response",r)},hasNext:!1}}}}}}(T);return{config:h,fetch:T,request:L,requestStream:N}}}));
//# sourceMappingURL=graphql-client.min.js.map
{
"name": "@shopify/graphql-client",
"version": "1.1.0",
"version": "1.2.0",
"description": "Shopify GraphQL Client - A lightweight generic GraphQL JS client to interact with Shopify GraphQL APIs",

@@ -32,13 +32,2 @@ "repository": {

},
"scripts": {
"lint": "eslint . --ext .js,.ts",
"build": "yarn tsc -p ./tsconfig.build.json && yarn run rollup",
"test": "jest",
"test:ci": "yarn test",
"rollup": "rollup -c --bundleConfigAsCjs",
"clean": "rimraf dist/*",
"changeset": "changeset",
"version": "changeset version",
"release": "yarn build && changeset publish"
},
"jest": {

@@ -97,3 +86,15 @@ "projects": [

},
"homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/api-clients/graphql-client#readme"
}
"homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/api-clients/graphql-client#readme",
"scripts": {
"lint": "eslint . --ext .js,.ts",
"build": "pnpm tsc -p ./tsconfig.build.json && pnpm rollup",
"tsc": "tsc",
"test": "jest",
"test:ci": "pnpm test",
"rollup": "rollup -c --bundleConfigAsCjs",
"clean": "rimraf dist/*",
"changeset": "changeset",
"version": "changeset version",
"release": "pnpm build && changeset publish"
}
}

@@ -87,9 +87,11 @@ # GraphQL Client

| Name | Type | Description |
| ---------- | --------------------- | ---------------------------------------------------------------- |
| variables? | `Record<string, any>` | Variable values needed in the graphQL operation |
| url? | `string` | Alternative request API URL |
| headers? | `Record<string, string \| string[]>` | Additional and/or replacement headers to be used in the request |
| retries? | `number` | Alternative number of retries for the request. Retries only occur for requests that were abandoned or if the server responds with a `Too Many Request (429)` or `Service Unavailable (503)` response. Minimum value is `0` and maximum value is `3`.|
| Name | Type | Description |
| ---------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| variables? | `Record<string, any>` | Variable values needed in the graphQL operation |
| url? | `string` | Alternative request API URL |
| headers? | `Record<string, string \| string[]>` | Additional and/or replacement headers to be used in the request |
| retries? | `number` | Alternative number of retries for the request. Retries only occur for requests that were abandoned or if the server responds with a `Too Many Request (429)` or `Service Unavailable (503)` response. Minimum value is `0` and maximum value is `3`. |
| signal? | `AbortSignal` | If this option is set, the request can be canceled by calling `abort()` on the corresponding `AbortController`. |
## `ClientResponse<TData>`

@@ -96,0 +98,0 @@

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

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