Docs > Technical Docs > Hasura
Hasura
We use Hasura to manage graphql queries and mutations on top of the Postgres database.
This is a brief overview of helpful mechanics for development - note installation and self hosting will require a separate guide.
Queries and Mutations
We use a typescript code gen tool to build out all corresponding types for new queries and mutations. To make a new graphql action, create a const in the /graphql/queries or graphql/mutations files. Example:
// get markdown from the page
const getPage = gql`
query getPage($id: uuid!) {
pages_by_pk(id: $id) {
name,
markdown,
}
}
`
Then run
yarn generate
You will then be able to use the query.
useQuery
To fetch data - use the custom graphql query that is configured to authenticate calls to the Hasura. An example below:
const { data } = useQuery(`getPage`, {
id: 'ssadasrasrasr',
},
{
enabled: Boolean(token),
});