GraphQLClient class
GraphQL client for executing raw queries and mutations against a Data API Builder endpoint.
Prefer the fluent entity API (dataApi.<Entity>) for typical access; use
this client when you need to send a hand-written GraphQL document.
Constructors
| Graph |
Methods
| mutation<T>(string, Record<string, any>) | Execute a GraphQL mutation. |
| query<T>(string, Record<string, any>) | Execute a GraphQL query. |
| request<T>(string, Record<string, any>, string) | Execute a GraphQL query or mutation. |
Constructor Details
GraphQLClient(ApiClient, string)
new GraphQLClient(apiClient: ApiClient, endpoint?: string)
Parameters
- apiClient
- ApiClient
The <xref:ApiClient> used to send HTTP requests.
- endpoint
-
string
The GraphQL endpoint path. Defaults to /graphql.
Method Details
mutation<T>(string, Record<string, any>)
Execute a GraphQL mutation.
function mutation<T>(mutation: string, variables?: Record<string, any>): Promise<T>
Parameters
- mutation
-
string
The GraphQL mutation document to execute.
- variables
-
Record<string, any>
Optional variables referenced by the document.
Returns
Promise<T>
The data payload from the response.
query<T>(string, Record<string, any>)
Execute a GraphQL query.
function query<T>(query: string, variables?: Record<string, any>): Promise<T>
Parameters
- query
-
string
The GraphQL query document to execute.
- variables
-
Record<string, any>
Optional variables referenced by the document.
Returns
Promise<T>
The data payload from the response.
request<T>(string, Record<string, any>, string)
Execute a GraphQL query or mutation.
function request<T>(query: string, variables?: Record<string, any>, operationName?: string): Promise<T>
Parameters
- query
-
string
The GraphQL document to execute.
- variables
-
Record<string, any>
Optional variables referenced by the document.
- operationName
-
string
Optional operation name for multi-operation documents.
Returns
Promise<T>
The data payload from the response.