Skip to content
0:00 / 0:00

#graphql#apolloclient#graphql-codegen

Apollo Codegen In React - Generate Typescript Types from GraphQL Schema and Queries

Code with Vlad

9.9K subscribers • 5 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Linked in the descriptionvladwulf/apollo-codegen-tutorial
  • May be out of date. The tools, versions or practices it shows have likely moved on.

Intermediate. Assumes working knowledge.

14K views4 years ago1 recommendation

Web developmentProgramming languagesTypeScriptReactHTTP, REST and GraphQL

This tutorial explains how to automate the generation of TypeScript types from a GraphQL schema and queries using Apollo Codegen in a React app.

Graphql codegen / Apollo codegen is a great feature! When working with GraphQL and Typescript in React, we want to be able to have typescript autocompletion on the variables we pass to our queries and mutations as well as on the data that is being returned from them. You can do it manually by inserting a type or an interface as a generic inside your useQuery() or useMutation() hook. However, this process is extremely error-prone and is not DRY. In this tutorial, we are going to see how to automate the generation of typescript types from the GraphQL schema. Github link: github.com/vladwulf/apollo-codegen-tutorial Introduction Generate typescript from GraphQL Inject Query Data Generic Inject Query Variables Generic

Why it's here

1 person recommends this

u/slowRoastedPinguinin r/node • Recommends

Apollo Codegen In React - Generate Typescript Types from GraphQL Schema and Queries