/* This section is copied from graphql-request rather than importing because of the following error: error TS2742: The inferred type of 'createVendiaClient' cannot be named without a reference to '.pnpm/graphql-request@4.3.0_graphql@15.8.0/node_modules/graphql-request'. This is likely not portable. A type annotation is necessary context: https://github.com/microsoft/TypeScript/issues/42873 more context: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189 Just doing this so we can get the ClientError type for our errors... :/ UPDATE - this isn't enough, problem still occurs with PNPM ONLY due to imports from graphql-request in other files. So far, the only solution I've tested that works is to add an .npmrc to the root of the repo with the following: node-linker = hoisted Explained here - https://github.com/microsoft/TypeScript/issues/42873#issuecomment-1464721715 */ type Variables = { [key: string]: any } interface GraphQLError { message: string locations?: { line: number column: number }[] path?: string[] extensions?: any } interface GraphQLResponse { data?: T errors?: GraphQLError[] extensions?: any status: number [key: string]: any } interface GraphQLRequestContext { query: string | string[] variables?: V } declare class ClientError extends Error { response: GraphQLResponse request: GraphQLRequestContext constructor(response: GraphQLResponse, request: GraphQLRequestContext) private static extractMessage } /* END copied types from graphql-request */ export interface Credentials { token?: string apiKey?: string } export interface ApiCredentials { clientId: string clientSecret: string } export interface ClientOptions { apiUrl: string apiKey?: string websocketUrl?: string apiCredentials?: ApiCredentials /** * Provide a function which will be called when any request/subscription errors. */ onError?: (error: ClientError | Error) => void getCredentials?: () => Promise fetch?: any retries?: number debug?: boolean } export type Logger = (formatter: any, ...args: any[]) => void