Skip to main content

DjraphQL builds a flexible & performant GraphQL schema by examining your Django models.

Project description

DjraphQL

Check out the documentation!

What

DjraphQL ("GiraffeQL") is a library that examines your Django models and builds a flexible, performant GraphQL schema using Graphene. No resolvers necessary.

You can of course extend this schema, reference the defined types and build custom business logic into your own resolvers. The goal is to remove the monotonous 90% of boilerplate generalized C.R.U.D. and allow you to focus on stuff that can't be auto-generated.

How

You provide a list of Django models and some associated metadata. For example, you can define the QuerySet that will be used for each fetch of a certain model type (you have access to the Django request object in the definition lambda for the QuerySet). By providing a QuerySet that is already filtered by e.g., user account, the library will use that QuerySet in the resolvers it generates. The requirement that you must remember to filter by account is all but eliminated.

It builds each relationship into the schema, so you can traverse from Label to Artist to Album to Song in a single query (both in the result-set and via filtering), still retrieving only the data you need.

You can specify arbitrarily complex SQL statements: the schema allows specifying filtering via where, orderBy, offset, limit, or distinct.

It allows smooth (nested, if you're bold enough!) updates & inserts.

Perhaps best of all, it automatically generates select_related and prefetch_related calls to your QuerySet. This avoids the classic GraphQL N+1 problem usually solved by things like dataloader. Additionally, it fetches only the columns necessary to satisfy the query. No over fetching!

A hand-rolled schema providing all of this for a single model would be hundreds of lines of code. Multiply that by a realistic, mature application with a hundred or more models, and you have an unmaintainable mess. This library auto-generates it for you, leaving the fun stuff for you.

Contributing

See CONTRIBUTING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djraphql-0.1.15.tar.gz (35.6 kB view details)

Uploaded Source

File details

Details for the file djraphql-0.1.15.tar.gz.

File metadata

  • Download URL: djraphql-0.1.15.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for djraphql-0.1.15.tar.gz
Algorithm Hash digest
SHA256 c1ab2a109c2dc7795b13940f6ed37e2512d69fd5582c177c65189980f45a21c3
MD5 34db273571e8409c8c92112562b68744
BLAKE2b-256 9cbf779d9149fe3ae927a5ea36fe7af43bfaf4b8dd103d58b1b0fcdf050a3a81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page