Principles

It’s common to for an exposed API to closely match the underlying models. Building and exposing a large GraphQL schema containing many types that generally match the underlying Django models is where DjraphQL shines brighest.

To serve this use-case, DjraphQL adheres to a couple principles that drive its developer experience.

Automate the mundane

A Django model schema is itself a graph, and thus lends well to automated generation of types based on the models and the relationships between them.

This is exactly what DjraphQL does.

By taking a set of Django models as its input, it’s able to generate a highly flexible and performant GraphQL schema that is focused on productivity for the engineers working on the application consuming the API.

Readability is key

Engineers should be able to look at the backing classes for an API and easily understand what and how is served.

That said, it’s often difficult to strike the right balance between readability and flexibility. DjraphQL strives to cover the most common use-cases by utilizing an API based on generic hooks to achieve complex logic specific to an application.

For example, in a SaaS product, it’s extremely important to prevent cross-account access to data. Another common use-case is having to perform some validation or formatting of an object before it’s saved to the database. Or checking permissions of the logged-in users before executing their mutation.

All of these cases are achievable via generic hooks that allow the engineer to use their existing tooling to serve these requirements in a declarative way.

Pluggable schema generation

The schema generated by DjraphQL is focused on ease of use by the consumers of the API. But if a team would rather work with a Relay-based schema, they can simply create their own schema type builders.