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

Paving a New Path for GraphQL Schemas

Paving a New Path for GraphQL Schemas

GraphQL Conf Asia 2019

Tim Griesser

April 13, 2019
Tweet

More Decks by Tim Griesser

Other Decks in Programming

Transcript

  1. "

  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 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-Andre Giroux during Q&A after at GraphQL NYC “…I’m

    not sure - SDL first seems to be unique to the JavaScript community”
  8. – Again, still just quoting my own thoughts here… “The

    JavaScript ecosystem is really missing out”
  9. Figuratively speaking, when you pave the way for someone, you

    make it easier for them to do something
  10. Why not SDL first? Related Tooling in the Ecosystem GraphQL

    Nexus How SDL is Still Incredibly Useful
  11. 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
  12. “makeSchema”
 Generates Types Generated types are 
 Inferred by
 TypeScript

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

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

    Changes to
 Schema, Restart 
 the Server Regenerates SDL & Types files
  15. – 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.”
  16. – 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.”
  17. Allows user to “override / configure” default Prisma types Allows

    you to “eject” from the Prisma DB conventions Just a thin wrapper over Nexus generated layer Similar approach could be used elsewhere, dynamic - similar to Gatsby’s approach
  18. “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
  19. Middleware Pipeline Progammatic Directives Better interop with SDL snippets “Missing

    field” generation hooks Input Args/Type Validation ???