Skip to content

Instantly share code, notes, and snippets.

View dicknetherlands's full-sized avatar

Richard Holland dicknetherlands

  • LanzaTech
  • Dunedin, NZ
View GitHub Profile
@dicknetherlands
dicknetherlands / streamlined_graphene.py
Last active February 3, 2025 17:38
Graphene speedup
# This gist shows how to speed up graphene_django by short-cutting the field and type resolution of the returned JSON and
# using a bit of caching to avoid having to repeat our discovery/decision process across multiple fields of the same
# type. It relies on trusting the developer to always return the correct types and respect non-nullability.
# Assumes that:
# 1. You're not using async code
# 2. You're using graphql_sync_dataloader to solve the N+1 problem
# 3. You're not using any graphene middleware other than for authentication
# 4. Your resolvers will all respect the schema
# 5. See code comments for further limitations