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

GraphQL Schema Design @ Scale

GraphQL Schema Design @ Scale

GraphQL Schema Design and Tooling @ GitHub

Marc-Andre Giroux

November 07, 2018
Tweet

More Decks by Marc-Andre Giroux

Other Decks in Programming

Transcript

  1. about { xuorig } • Montreal, Canada ☃ • My

    3rd GraphQL Summit • I work at GitHub! 2
  2. 3

  3. GraphQL @ GitHub • 200+ engineers working on GraphQL schema

    • Teams have to move quickly • Public and Internal Schema + Enterprise. 4
  4. GraphQL @ GitHub: Challenges • Keeping a high quality public

    API across many teams and use cases. • Small API team • Best practices are still emerging, lots and lots of PR reviews to go through, and many new use cases appearing every week. 5
  5. Why we design • Build APIs that are easier to

    evolve: Best way to mitigate breaking changes we don't know about yet • Build APIs that are easier to reason about 10
  6. For a lot of us, it is often an opportunity

    to design from scratch (and maybe get it right this time? ) 18
  7. To let go of our coupling to our database schema,

    our REST resources or our UI 19
  8. 21

  9. • Be an expert at your domain, understand the ins

    and out • Be an expert at GraphQL specific design 21
  10. 23

  11. 34

  12. 35

  13. 36

  14. 37

  15. 38

  16. 39

  17. 40

  18. 42

  19. 47

  20. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 52
  21. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 53
  22. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 54
  23. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 55
  24. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 56
  25. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 57
  26. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 58
  27. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 59
  28. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 60
  29. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 61
  30. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 62
  31. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 63
  32. type User { billingInfo: BillingInfo! email: String! login: String! fullName:

    String! recentIssues: [Issue!]! repositories: [Repository!]! reviewRequests: [ReviewRequest!]! isOwner(repositoryID: ID!): Boolean! starredRepositories: [Repository!]! } 64
  33. We shouldn't be afraid of adding use cases or client

    specific fields if it fits a domain use case 65
  34. 69

  35. 70

  36. 74

  37. 75

  38. 76

  39. 77

  40. 79

  41. 80

  42. 81

  43. 83

  44. 84

  45. 85

  46. 86

  47. 87

  48. 88

  49. 90

  50. 96 query { viewer { login email } } GitHub

    API GraphQL Query Analytics
  51. 97 query { viewer { login email } } GraphQL

    Query Analytics Type: Query Field: viewer App: xxx Type: User Field: login App: xxx ...
  52. 100

  53. 101