DEV Community

Discussion on: Fullstack, Type safe application with React and GraphQL codegen

Collapse
 
redbar0n profile image
Magne

See: The Problems of "Schema-First" GraphQL Server Development

The red pill path is:

  • Back-end: Code-first (aka. resolver-first) using Nexus GraphQL, which outputs both GraphQL schema and TS types and keeps them in sync. Possibly with the Prisma (ORM) plugin to quickly expose DB fields without having to write resolvers.

  • Front-end: GQty (runtime gen). Alternatively GraphQL codegen (compiletime gen) to generate React useNamedQuery hooks with TS typings from the GraphQL schema (which is schema-introspected from the back-end). Possibly with graphql-codegen plugin called typescript-urql if using URQL GraphQL client (which is recommended).