liveBook · Manning

Graphene

As explained in Django in Action

Graphene is a library for building GraphQL schemas and APIs in Python applications.

Graphene is a Python library for building GraphQL APIs in Django applications. Instead of many REST URLs and HTTP verbs, clients send JSON-like queries to one endpoint and request the fields they need. section 11.3

A Graphene API is organized around:

  • Schemas that describe returned data and map it to the Django ORM. section 11.3
  • Query classes that define available actions, including operations analogous to CRUD. section 11.3
  • A GraphQLView registered as the application’s single API endpoint. section 11.3

Request only the fields you need

A client can request an object while limiting the response to selected fields, much like choosing specific columns in an SQL query. This can reduce bandwidth, but complex queries can increase server load and make clients responsible for writing more query logic. section 11.3

How Django in Action covers it

How deep it goes
Defines schemas, ORM mappings, query classes, and endpoint registration, but stops short of implementation code.
Examples
Uses field-limited object queries to illustrate reduced responses and bandwidth usage.
What you can do after
Build it from scratch by defining schemas and query classes, then registering them with GraphQLView.
How it connects
Connects GraphQL with Django, the ORM, query classes, CRUD operations, GraphQLView, and REST APIs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.