Type-safe API Calls
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
.graphqlor.gqlfile in thesrc/api/gql_operationsdirectory. - Utilizes the
graphQLRequestfunction queryFns and mutationFns - maintaining ability to mock with msw (hopefully).
