E2E type safety with GraphQLΒ 

About me πŸ€“

  • Write code! - mostly for fun πŸ˜ƒ
  • Love to play Football ⚽
  • Working with Prisma (prisma.io) on OSS 😼
  • Twitter (and across internet): @divyenduz 🐦

Dynamic Languages πŸŽƒ

  • Javascript
  • PHP
  • Python

Typed Languages 😼

  • Scala
  • Haskell
  • Java
  • Typescript πŸ‘€

Advantages of types!

  • Static analysis
  • Autocompletion
  • Contract across interfaces (API)

Are types important?

  • Large scale code bases (Flow, TS, Pyre)
  • CI/CD - Interface contracts
  • Code generation πŸ€”

Downsides of type safety

  • Verbosity 🀯
  • Learning curve πŸ“ˆ

Code generation

To the rescue!

GraphQL is strongly typed

  • Introspect to generate type interfaces
  • Introspect to scaffold resolvers
  • Profit via "graphql-resolver-codegen"

Demo

Note: Demo interfaces and scaffolding generation for a GraphQL schema for Typescript but do mention that the tool itself is language agnostic.

Challenges

  • Keeping resolvers up to date
  • Workflow for running the generation
  • Developer experience

Questions?

Thank you πŸ™‚

E2E type safety with GraphQL

By Divyendu Singh

E2E type safety with GraphQL

Live demo of graphql-resolver-codegen

  • 31