The API client is the primary way to send queries and mutations to the Vendure backend. It handles channel tokens and authentication automatically.
The API client exposes two main methods:
query - For GraphQL queriesmutate - For GraphQL mutationsThe API client is designed to work seamlessly with TanStack Query for optimal data fetching and caching:
The Dashboard Vite plugin incorporates gql.tada, which gives you type safety any code generation step!
It works by analyzing your Admin API schema (including all your custom fields and other API extensions), and outputs the results
to a file - by default you can find it at src/gql/graphql-env.d.ts.
When you then use the import { graphql } from '@/gql' function to define your queries and mutations, you get automatic
type safety when using the results in your components!
When you have the @/gql path mapping correctly set up as per the getting started guide, you should see that
your IDE is able to infer the TypeScript type of your queries and mutations, including the correct inputs and return
types!
Architecture reviews, custom plugin work, migrations, ongoing support. Get a hand from the team that builds Vendure.
Talk to the team