Have you used GraphQL yet? If you haven't, you're likely to encounter the technology soon. If you have, you might have questions about how to scale your team and what best practices large and small companies are following. What principles should I be following when developing a new GraphQL API? What tooling is available to help me be more productive and spend less time writing boilerplate code? How can many teams with many apps across one company share one graph?
GraphQL Conf 2019 just wrapped up in Berlin where I was fortunate to hear meet thoughtful leaders on these and other subjects related to GraphQL. So, whether you're brand new to GraphQL or have an active project using GraphQL, I'd like to share some of what I have learned so you can be productive with GraphQL and your teams - while keeping relationships at the center of our work.
5. This is the specification for GraphQL, a query language and
execution engine originally created at Facebook in 2012 for
describing the capabilities and requirements of data models
for client‐server applications. The development of this open
standard started in 2015.
https://graphql.github.io/graphql-spec
31. CORS
Tracing & Analytics
File Uploads
(Uploads have been proposed by Apollo, among others, but do not appear to be destined for the spec)
https://blog.apollographql.com/file-uploads-with-apollo-server-2-0-5db2f3f60675
https://github.com/graphql/graphql-spec/issues/563
https://github.com/graphql/graphql-spec/issues/349
33. “This is the Unix philosophy: Write programs that do one
thing and do it well. Write programs to work together.”
- Doug McIlroy
34. “There are a lot of questions that [GraphQL] very specifically
does not answer… that’s because [these questions] were
already solved by FB in 2012”
- Dan Schafer (GraphQL Co-Creator)
GraphQL before GraphQL — Dan Schafer
https://youtu.be/gb1R-fWP1Yw
45. INTEGRITY
1. One Graph
Your company should have one unified graph, instead of multiple graphs created
by each team.
https://principledgraphql.com/integrity#1-one-graph
46. INTEGRITY
2. Federated Implementation
Though there is only one graph, the implementation of that graph should be
federated across multiple teams.
https://principledgraphql.com/integrity#2-federated-implementation
47. 3. Track the Schema in a Registry
There should be a single source of truth for registering and tracking the graph.
INTEGRITY
https://principledgraphql.com/integrity#3-track-the-schema-in-a-registry
48. 4. Abstract, Demand-Oriented Schema
The schema should act as an abstraction layer that provides flexibility to
consumers while hiding service implementation details.
AGILITY
https://principledgraphql.com/agility#4-abstract-demand-oriented-schema
49. 5. Use an Agile Approach to Schema Development
The schema should be built incrementally based on actual requirements and
evolve smoothly over time.
AGILITY
https://principledgraphql.com/agility#5-use-an-agile-approach-to-schema-development
50. 6. Iteratively Improve Performance
Performance management should be a continuous, data-driven process, adapting
smoothly to changing query loads and service implementations.
AGILITY
https://principledgraphql.com/agility#6-iteratively-improve-performance
51. 7. Use Graph Metadata to Empower Developers
Developers should be equipped with rich awareness of the graph throughout the
entire development process.
AGILITY
https://principledgraphql.com/agility#7-use-graph-metadata-to-empower-developers
52. 8. Access and Demand Control
Grant access to the graph on a per-client basis, and manage what and how
clients can access it.
OPERATIONS
https://principledgraphql.com/operations#8-access-and-demand-control
53. 9. Structured Logging
Capture structured logs of all graph operations and leverage them as the primary
tool for understanding graph usage.
OPERATIONS
https://principledgraphql.com/operations#9-structured-logging
54. 10. Separate the GraphQL Layer from the Service Layer
Adopt a layered architecture with data graph functionality broken into a separate
tier rather than baked into every service.
OPERATIONS
https://principledgraphql.com/operations#10-separate-the-graphql-layer-from-the-service-layer
59. “Though there is only one graph, the implementation of that
graph should be federated across multiple teams.”
- Principled GraphQL: #2
https://principledgraphql.com/integrity#2-federated-implementation
60. What if I want to distribute my schema
authorship across my services?
63. “When we distribute our GraphQL Schema across different
services... what we're saying is 'I want to use GraphQL for my
inter-service communication'”
- Marc-André Giroux (GitHub)
So You Want to Distribute Your GraphQL Schema — Marc-Andre Giroux
https://youtu.be/Vq0ajno-zgw
68. If you do distribute your schema, “stitch”
statically, track changes
https://principledgraphql.com/integrity#3-track-the-schema-in-a-registry
Marc-Andre Giroux: https://youtu.be/Vq0ajno-zgw?t=1102
70. So you Want to Distribute your GraphQL Schema?
Marc Andre-Giroux
30 min
https://youtu.be/Vq0ajno-zgw
Infinite Backwards Compatibility
Adam D. I. Kramer
30 min
https://youtu.be/FGCqA9PjVQk
Apollo Schema Federation
James Baxley
30 min
https://youtu.be/Uw-Z1aUQvgg
71. So, you want to use a GraphQL API
Let’s talk about tools
76. GraphQL
Prisma | 53,771 installs | 185,888 downloads | Free
GraphQL extension for VSCode adds syntax highlighting, validation, and language features like go
to definition, hover information and autocompletion for graphql projects. This extension also
works with queries annotated with gql tag.
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
87. “When apps are developed in a typed language like TypeScript,
Java, or Swift, type information can be propagated all the way
from service type declarations through every line of code in
the app, ensuring fullstack type correctness and instant
feedback on errors.”
- Principled GraphQL: #7
https://principledgraphql.com/agility#7-use-graph-metadata-to-empower-developers
88. Building custom GraphQL tooling for your team
Sashko Stubailo
30 min
https://youtu.be/jegQWT-Wl64
Scaling Your GraphQL Client
Matt Mahoney
30 min
https://youtu.be/Vo8nqjiKI3A
200 OK! Error Handling in GraphQL
Sasha Solomon
30 min
https://youtu.be/A5-H6MtTvqk
90. We’re gunna program like it’s 1999
Lee Byron (GraphQL Co-Creator)
30 min - Closing Keynote
https://youtu.be/ADEav6zlDjg
“The mental model for building for the web largely
hasn’t changed in the last 20 years... This year the web
turns 30, and we look back at the steady march forward
of better abstractions, better syntax, and better mental
models that brought us here.”
94. “Coordination between Engineers happens with GraphQL
schemas as our common language”
- Jon Wong (Coursera)
Evolving the Graph — Jon Wong
https://youtu.be/fmsDlaKTJZs
95. GraphQL is an agreement
(relationship)
between the client and the server