Directive-Driven GraphQL Development - Lenny Burdette, GraphQL Galaxy 2021

Explore the benefits of directive-driven GraphQL development and discover four distinct approaches to building GraphQL APIs, from data-driven to code-first, with a focus on ease of use, maintainability, and scalability.

Key takeaways
  • GraphQL has many benefits over traditional REST APIs, including its declarative query language and flexibility in schema design.
  • Likewise, gRPC has its own benefits, such as performance and ease of use.
  • Directive-driven GraphQL development offers a way to abstract away the underlying complexity and create a more idiomatic GraphQL API.
  • The approach allows for easier API evolution and more control over the GraphQL schema.
  • The speaker proposes four distinct approaches to building GraphQL APIs: data-driven, immutable, schema-first, and code-first.
  • Each approach has its own strengths and weaknesses, and the choice of which to use depends on the specific use case.
  • Data-driven approaches, such as GraphQL Mesh, can simplify the process of building a GraphQL API by abstracting away the underlying complexity.
  • Immutable approaches ensure that the API remains consistent and predictable, but may be more difficult to evolve.
  • Schema-first approaches allow for strong typing and better maintainability, but may require more up-front investment.
  • Code-first approaches allow for rapid development and flexibility, but may lead to more complicated and difficult-to-maintain code.
  • GraphQL directives can be used to add additional behavior to the API, without changing the underlying schema.
  • The speaker’s prototype uses a domain-specific language (DSL) to define the behavior of the API, and a validator to enforce the schema.
  • The approach allows for easy evolution and maintenance of the API, and provides a clear separation of concerns between the presentation layer and the underlying data model.