DEV Community

Mauricio Reatto Duarte
Mauricio Reatto Duarte

Posted on

 

Production Ready GraphQL Summary — Part I

I'm reading this book with GraphQL content.

Thanks @leonardomso

book

Pagination: Cursor Pagination

  • Cursor pagination is generally a great choice, because of the accuracy and performance
  • Maybe it's the most common pattern in GraphQL at the moment
  • This pattern lets us design more complex use cases, because of Connection and Edge types
  • Relay clients integrate perfectly with your API because of that

Global Identification: Global ID — Node

  • Like Connections, they can be a good pattern even outside of a Relay context
  • Opaque IDs are recommended
  • You necessarily don't need global identification if you're not planning to use Relay
  • Ensure your global identification contains enough context to globally route to a node, especially in a distributed architecture

Non-Nullability

  • It lets clients avoid defensive code/conditionals
  • It helps to build more predictable schemas

tradeoffs/warnings:

  • It's very hard to predict what can be null
  • Non-null fields and arguments are harder to evolve. Going from non-null to null is a breaking change, but the opposite is not

guidelines for nullability:

  • Should almost always nullable fields that return object types that are backed by database associations, network calls, or anything that could potentially fail
  • Non-null for arguments, because it's more predictable and easy to understand API

That's it.
My first part of the book summary. Thank you.

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.