Skip to main content

Get data from backend

Cella frontend use react-query and GraphQL to fetch all data we need.

Type-Safety and Code Generation

We used GraphQL-Codegen to generate ready-to-use React Hooks, based on all GraphQL operations. You can find more details and examples here.

Create new query

In graphql folder, you can define any mutation or query you want by creating a file whatever.graphql. Then just put the graphql operation.

login.graphql
mutation Login($username: String!, $password: String!, $warehouseId: ID!) {
login(username: $username, password: $password, warehouseId: $warehouseId) {
accessToken
}
}

Run this command :

yarn gen

This will generated custom type safe hooks directly from your GraphQL schema and GraphQL operations. The output is located in generated/graphql.ts. You will find all available hooks with examples in it.