Skip to main content

Client

Configuration

const client = new Client({
url: "/path/to/gql",
});

Params

  • url (mandatory): the URL of your GraphQL API
  • schemaConfig (mandatory): your generated schema config
  • headers (optional): the default headers to send
  • makeRequest (optional): function that performs the request and returns a Future<Result<unknown, ClientError>> (e.g. to add request IDs, custom parsing of the payload, logging & custom error handling)

Perform a query

client.query(query, variables).tap((result) => {
console.log(result);
});

Perform a mutation

client.commitMutation(mutation, variables).tap((result) => {
console.log(result);
});