graphql

Django GraphQL with Graphene

Graphene brings GraphQL to Django. I define types mapping to models and create resolvers for queries and mutations. Clients request exactly the data they need, reducing over-fetching. I use DjangoObjectType for automatic schema generation from models.

GraphQL persisted queries (hash allowlist)

GraphQL endpoints can be abused with huge queries that are expensive to parse and execute. Persisted queries let clients send a hash (e.g. sha256:...) instead of the full query, and the server only executes queries it recognizes. This reduces payload

N+1 avoidance with DataLoader (GraphQL)

GraphQL makes it very easy to accidentally create N+1 query explosions. DataLoader batches requests for the same resource during a single tick and gives you per-request caching. The trick is scoping: loaders must be per-request, not global singletons,