Type-safe API Calls


Jun 6, 2025

ACCEPTED

Newgotiate Leads

Technical Story: 34945 - Add GraphQL Code Generation

Context and Problem Statement

To ensure a shared API definition between Conductiv's backend servers and this UI.

Decision Drivers

  • Ability to generate accurate type definitions for our GraphQL server
  • Tooling familiarity

Considered Options

Decision Outcome

Chosen option: graphql-codegen because its already in use for other Conductiv applications, and generates types for the GraphQL schema and operations.

Notes

  • Generates a React-Query hook per operation.
  • Operations must be defined in a .graphql or .gql file in the src/api/gql_operations directory.
  • Utilizes the graphQLRequest function queryFns and mutationFns - maintaining ability to mock with msw (hopefully).