Making queries 🔎
The easiest way to get started is to use the shorthand methods we created for you. For example:
import { Abowire } from "abowire";
const abowire = new Abowire({...});
await abowire.login();
const customer = await abowire.customer.get("customer_1");
You can see a full list of all built-in methods in the Built-in API reference.
Of course, the power of GraphQL is that you can define your own queries and mutations. You can do that by using the query
and mutate
methods:
// Define your own GraphQL queries
const CREATE_CUSTOMER = abowire.gql`
mutation CreateCustomerMutation($input: CreateCustomerInput!) {
createCustomer(input: $input) {
id
name
}
}
`;
const CUSTOMER_LIST = abowire.gql`
query CustomerListQuery {
customers {
items {
id
email
}
}
}
`;
const customer = await abowire.GraphQL.mutate(CREATE_CUSTOMER, {
name: "John Doe",
});
const customers = await abowire.GraphQL.query(CUSTOMER_LIST);
We also provide a set of built-in queries and mutations that you can use out of the box:
const customer = await abowire.GraphQL.query(abowire.queries.GET_CUSTOMER, {
id: "customer_1",
});
You can see a full list of all built-in queries and mutations in the SDK Query reference.