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

SDL as an Artifact: Code-First Schemas and GraphQL Nexus

SDL as an Artifact: Code-First Schemas and GraphQL Nexus

GraphQLConf '19

Tim Griesser

June 20, 2019
Tweet

More Decks by Tim Griesser

Other Decks in Programming

Transcript

  1. vs

  2. – Me, when beginning to use Graphene “Oh no, this

    library doesn’t develop the SDL first”
  3. – Me, after spending a few more months in Graphene

    “Hey, this is actually pretty nice… scales really well to multiple teams”
  4. Stats from Generated SDL: 307 object types 129 input types

    89 enum types 10 interfaces 5 custom scalars 1 union type 0 custom directives 2542 output fields 581 input fields 717 enum members 35 deprecations ~ 18 developers, 4 teams contributing to the same schema
  5. GitHub Public API SDL: 326 object types 90 input types

    70 enum types 25 interfaces 8 custom scalars 20 union types 0 custom directives 2085 output fields 307 input fields 299 enum members 6 deprecations https://github.com/octokit/graphql-schema
  6. 2015: graphql-js Later 2015 - 2016: graph.ql graphql-tools 2017: Graphene

    (Python) 2018: GraphQL Ruby Also 2018: graphql-tools + graphql-code-generator
  7. – Marc-André Giroux during Q&A after at GraphQL NYC “…I’m

    not sure - SDL first seems to be unique to the JavaScript community”
  8. Why not SDL first? Related Tooling in the Ecosystem GraphQL

    Nexus How SDL is Still Incredibly Useful
  9. Implemented 16 times in GitHub’s Public API… Adding a new

    field with SDL first would mean finding all 16 locations and adding the new field
  10. “makeSchema”
 Generates Types Generated types are 
 Inferred by
 TypeScript

    Outputs SDL Schema Artifact Creates GraphQL schema Outputs TypeScript Types Imported type “registry” wired up
  11. “makeSchema”
 Generates Types Generated types are 
 Inferred by
 TypeScript

    Changes to
 Schema, Restart 
 the Server IDE Auto-Completion & Type Checking Optional for JS development
  12. “makeSchema”
 Generates Types Generated types are 
 Inferred by
 TypeScript

    Changes to
 Schema, Restart 
 the Server Regenerates SDL & Types files
  13. – GraphQL Documentation “... in a GraphQL type system, every

    field is nullable by default. This is because there are many things which can go awry in a networked service backed by databases and other services. A database could go down, an asynchronous action could fail, an exception could be thrown. Beyond simply system failures, authorization can often be granular, where individual fields within a request can have different authorization rules.”
  14. – GraphQL Documentation “... in a GraphQL type system, every

    field is nullable by default. This is because there are many things which can go awry in a networked service backed by databases and other services. A database could go down, an asynchronous action could fail, an exception could be thrown. Beyond simply system failures, authorization can often be granular, where individual fields within a request can have different authorization rules.”
  15. “makeSchema”
 Generates Types Generated types are 
 Inferred by
 TypeScript

    Changes to
 Code, Restarts
 the Server Requires Some Configuration ?? Chicken / Egg Problem TypeScript errors are sometimes cryptic Dynamic Types & Jump To Code