Skip to main content

Graphql API (and client) integrates a powerful GraphQL client that simplifies data fetching and management. The GraphQL client provides an intuitive interface for making queries and mutations, enabling efficient communication with backend services and retrieving data in a structured & typed manner.****

Because of the dynamic nature of the GraphQL client, there is an intermediary build step that must be done to use the client to call the API that's generated from the schema. This build step is done by running npm run build in the solution's root. This will generate the graphql.ts file in the src/graphql/generated directory of the solution. This file is then used by the GraphQL client to call the API. For example:

import { graphql } from "../generated/graphql/index.js";

const CREATE_PATIENT = graphql(`
mutation CreateOnePatient($data: PatientCreateInput!) {
createOnePatient(data: $data) {

Please note: queries and mutations both must have operation names for the generation to work properly; this allows you to have typed queries and responses. No more `console.log(request); console.log(request.body), console.log(!

Armed with this client, you may use it to populate custom components or to manipulate data in your functions.