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

GraphQL Schema Design Principles adopted by NEWT

GraphQL Schema Design Principles adopted by NEWT

Agenda:

1) NEWT Stack
2) One Graph
3) Demand Oriented Schema Design

Avatar for Rodrigo Ramirez

Rodrigo Ramirez

March 27, 2024
Tweet

More Decks by Rodrigo Ramirez

Other Decks in Programming

Transcript

  1. © 2023 Reiwa Travel, Inc.
 Profile • Nationality: Argentinian •

    Language: Spanish, English, Japanese • Full Stack Developer (+10y) Career • 󰎆 2006~: Freelance • 󰎆 2008~: PowerSite ( CEO/CTO ) ◦ Email Marketing SaaS • 󰏦 2015~: Travelience ( CTO ) ◦ Tour Guide Marketplace • 󰏦 2021~: ReiwaTravel ( Senior Engineer ) ◦ Backend → Frontend → Backend Senior Engineer / Product-Dev Rodrigo Ramirez
  2. AGENDA
 © 2023 Reiwa Travel, Inc.
 1. NEWT Stack 2.

    One Graph 3. Demand Oriented Schema Design
  3. © 2023 Reiwa Travel, Inc.
 One Graph • Single Endpoint

    • Central Data Catalog • Portability Across Teams • Unified Access Control
  4. © 2023 Reiwa Travel, Inc.
 One Graph Extending the Graph

    Apollo Federation, Schema Stitching, Schema Merging, …
  5. © 2023 Reiwa Travel, Inc.
 One Graph Extending the Graph

    Apollo Federation, Schema Stitching, Schema Merging, …
  6. © 2023 Reiwa Travel, Inc.
 One Graph Apollo Federation, Schema

    Stitching, Schema Merging, … Extending the Graph
  7. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design Key

    Points: ① Design Schema around client-specific use cases ② Move business logic to the Backend ③ Close collaboration with Client side engineers Benefits: • Simplified Schema • Reduce Over-fetching • Improved Developer Experience • Easier to Understand and Maintain • Reduce QA cost
  8. © 2023 Reiwa Travel, Inc.
 ② Move Business Logic to

    the Backend Demand Oriented Schema Design
  9. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    Logic needs to be handled on each client (Web, iOS, Android) • More data than needed is requested from the API • QA cost increase to confirm implementation on each client Hotel Card / Spoken Languages
  10. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    Logic is hidden on the backend • Client implementation is simplified • API tests can be written to confirm use cases • QA cost decrease Hotel Card / Spoken Languages
  11. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    The client depend on 2 fields to display the price • The format needed to be coordinated between clients and places • QA cost increase Hotel Card / Price
  12. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    Only one field is needed to display the price • The format is controlled by the Backend, and consistency between apps is simple • QA cost decrease Hotel Card / Price
  13. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    To know if a Hotel is included inside the authenticated user Wishlist, a different query is needed • The client needs to control the logic • QA cost increase • … Hotel Card / Wishlist
  14. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design •

    Things that always need to be displayed together are together • Client logic is simplified, and business logic is hidden on the backend • QA cost decreases • … Hotel Card / Wishlist
  15. © 2023 Reiwa Travel, Inc.
 ③ Close collaboration with Client

    side engineers Demand Oriented Schema Design
  16. © 2023 Reiwa Travel, Inc.
 Demand Oriented Schema Design Close

    collaboration with Client side engineers • Prioritize client needs, but not just one client's needs • Client teams should be consulted early on in the API design process. • Schema should be approved by client teams before implementation Spec Check Schema Proposal Mock Implementation Final Implementation Backend + Client engineers involved in all process
  17. © 2023 Reiwa Travel, Inc.
 1) One Graph: • 1

    schema / 1 endpoint 2) Demand Oriented Schema Design: • Schema Design based on Client use cases • Reduce client-side complexity by moving Business Logic to the backend • Close collaboration with Client side engineers Summary