Class: GraphQLClient
Defined in: client/GraphQLClient.ts:159
A GraphQL client for the Propeller eCommerce Platform.
Features:
- Per-operation imports — services bring their own GraphQL documents.
- Secure proxy mode to keep API keys server-side.
- API key routing for order-editor mutations in direct mode.
- Configurable access token provider for SSR / custom storage.
- TypeScript support with full type safety.
SECURITY: Use 'proxy' mode in production to keep API keys server-side.
Constructors
Constructor
new GraphQLClient(
config):GraphQLClient
Defined in: client/GraphQLClient.ts:169
Parameters
config
Client configuration
Returns
GraphQLClient
Methods
clearAccessToken()
clearAccessToken():
void
Defined in: client/GraphQLClient.ts:527
Clear access token (logout).
Returns
void
execute()
execute<
T>(operation):Promise<GraphQLResponse<T>>
Defined in: client/GraphQLClient.ts:338
Execute a GraphQL operation.
Returns the raw GraphQLResponse (with data and/or errors). This is
the low-level entry point; it does not throw on GraphQL errors so callers
who want to inspect partial responses can do so. The higher-level
query() / mutate() helpers and the runOperation helper used by
services throw GraphQLOperationError when errors is non-empty.
Type Parameters
T
T = any
Parameters
operation
Returns
Promise<GraphQLResponse<T>>
getAccessToken()
getAccessToken():
Promise<string|undefined>
Defined in: client/GraphQLClient.ts:537
Get current access token using the configured provider. Returns undefined if no provider yields a token.
Returns
Promise<string | undefined>
getConfig()
getConfig():
Omit<GraphQLClientConfig,"apiKey"|"orderEditorApiKey">
Defined in: client/GraphQLClient.ts:489
Get current client configuration (without sensitive data).
Returns
Omit<GraphQLClientConfig, "apiKey" | "orderEditorApiKey">
getDefaultLanguage()
getDefaultLanguage():
string|undefined
Defined in: client/GraphQLClient.ts:261
Configured default language tag (ISO 639-1), or undefined if not set.
Returns
string | undefined
getFragment()
getFragment(
name):string|undefined
Defined in: client/GraphQLClient.ts:231
Look up a registered fragment by name.
Parameters
name
string
Returns
string | undefined
getFragmentNames()
getFragmentNames():
string[]
Defined in: client/GraphQLClient.ts:246
Names of all registered fragments.
Returns
string[]
getMutation()
getMutation(
name):string|undefined
Defined in: client/GraphQLClient.ts:241
Look up a registered mutation by name.
Parameters
name
string
Returns
string | undefined
getMutationNames()
getMutationNames():
string[]
Defined in: client/GraphQLClient.ts:256
Names of all registered mutations.
Returns
string[]
getQuery()
getQuery(
name):string|undefined
Defined in: client/GraphQLClient.ts:236
Look up a registered query by name.
Parameters
name
string
Returns
string | undefined
getQueryNames()
getQueryNames():
string[]
Defined in: client/GraphQLClient.ts:251
Names of all registered queries.
Returns
string[]
getSecurityMode()
getSecurityMode():
"proxy"|"direct"
Defined in: client/GraphQLClient.ts:495
Get current security mode.
Returns
"proxy" | "direct"
isAuthenticated()
isAuthenticated():
Promise<boolean>
Defined in: client/GraphQLClient.ts:543
True iff the access-token resolver yields a non-empty token.
Returns
Promise<boolean>
isSecureMode()
isSecureMode():
boolean
Defined in: client/GraphQLClient.ts:500
True iff the client is in secure proxy mode.
Returns
boolean
mutate()
mutate<
T>(mutation,variables?,operationName?):Promise<T>
Defined in: client/GraphQLClient.ts:418
Execute a GraphQL mutation, throwing on errors and returning data directly.
Type Parameters
T
T = any
Parameters
mutation
string
variables?
Record<string, any>
operationName?
string
Returns
Promise<T>
mutateByName()
mutateByName<
T>(mutationName,variables?):Promise<T>
Defined in: client/GraphQLClient.ts:461
Execute a registered mutation by name.
Only resolves mutations registered via registerMutation() — see queryByName.
Type Parameters
T
T = any
Parameters
mutationName
string
variables?
Record<string, any>
Returns
Promise<T>
query()
query<
T>(query,variables?,operationName?):Promise<T>
Defined in: client/GraphQLClient.ts:397
Execute a GraphQL query, throwing on errors and returning data directly.
Type Parameters
T
T = any
Parameters
query
string
variables?
Record<string, any>
operationName?
string
Returns
Promise<T>
queryByName()
queryByName<
T>(queryName,variables?):Promise<T>
Defined in: client/GraphQLClient.ts:442
Execute a registered query by name.
Only resolves queries registered via registerQuery() — bundled service
operations are no longer preloaded into the client and should be invoked
through the service factories (productService(client).getProduct(...)).
Type Parameters
T
T = any
Parameters
queryName
string
variables?
Record<string, any>
Returns
Promise<T>
registerFragment()
registerFragment(
name,definition):void
Defined in: client/GraphQLClient.ts:216
Register a GraphQL fragment by name. Fragments are inlined at build time
into service operations; this registration is used by ad-hoc callers who
compose documents themselves via execute().
Parameters
name
string
definition
string
Returns
void
registerMutation()
registerMutation(
name,definition):void
Defined in: client/GraphQLClient.ts:226
Register a custom mutation string under a name for use with mutateByName.
Parameters
name
string
definition
string
Returns
void
registerQuery()
registerQuery(
name,definition):void
Defined in: client/GraphQLClient.ts:221
Register a custom query string under a name for use with queryByName.
Parameters
name
string
definition
string
Returns
void
setAccessToken()
setAccessToken(
token):void
Defined in: client/GraphQLClient.ts:511
Set access token for authentication.
Writes to localStorage['access_token'] in the browser. Only meaningful
when using the default getAccessToken resolver — if a custom resolver
is configured, this method does not affect what that resolver returns.
Parameters
token
string
Returns
void
updateConfig()
updateConfig(
newConfig):void
Defined in: client/GraphQLClient.ts:479
Update client configuration.
Parameters
newConfig
Partial<GraphQLClientConfig>
Returns
void