Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL Finland

GraphQL Finland

Johannes Schickling

October 18, 2018
Tweet

More Decks by Johannes Schickling

Other Decks in Programming

Transcript

  1. Problems of building GraphQL servers Code generation Schema-first Type-safety Lots

    of boilerplate needed for resolvers Inconsistency between resolvers and GraphQL schema Unclear mapping between GraphQL types and resolver return values
  2. graphqlgen • Schema-first: Based on your GraphQL schema • Type-safe:

    Resolvers, arguments, parents… • Codegen based: Minimal boilerplate Now open-source: github.com/prisma/graphqlgen
  3. Getting started • Option A: Starting from scratch • Bootstrap

    new GraphQL server via `npm init graphqlgen` • Option B: Add to existing project • `npm install --dev graphqlgen` • Manually create `graphqlgen.yml` config file • Import generated interface types in your resolvers
  4. Usage workflow • Scenario: Add field to type in GraphQL

    schema backed by model • Run `graphqlgen`. Done. • Scenario: Add type to GraphQL schema • Run `graphqlgen`. Copy & implement scaffolded resolver file. • Scenario: Remove field in model • Run `graphqlgen`. Copy scaffolded resolver function.
  5. Future of graphqlgen • More languages: NodeJS, Flow & Reason

    • Smarter scaffolding workflows • Plugin system & integrations: Prisma, Apollo, …
  6. Key Takeaways Codegeneration for minimal boilerplate Schema-first to avoid inconsistencies

    Type-safety for safe mapping & great developer experience 1 2 3