Persisted queries for Django GraphQL
Project description
Persisted queries for Django GraphQL
Dependencies
Django ≥ 1.11
Python ≥ 3.4
Installation
Install last stable version from Pypi.
pip install django-graphql-persist
Include the PersistMiddleware middleware in your MIDDLEWARE settings:
MIDDLEWARE = [
...
'graphql_persist.middleware.PersistMiddleware',
...
]
Configure the list of directories searched for GraphQL SDL definitions.
GRAPHQL_PERSIST = {
'DOCUMENTS_DIRS': [
'/app/documents',
],
}
Schema definition
/app/documents/schema.graphql
query GetViewer {
viewer {
...userFields
}
}
query GetUsers {
users {
...userFields
}
}
fragment userFields on UserType {
id
email
}
Query by “id”
{
"id": "schema",
"operationName": "GetViewer",
"variables": {}
}
Operations definition
The server needs to do less processing to parse the query and verify the parameters.
/app/documents/GetViewer.graphql
query GetViewer {
viewer {
...userFields
}
}
fragment userFields on UserType {
id
email
}
Query by “operationName”
{
"operationName": "GetViewer",
"variables": {}
}
Settings
Here’s a list of settings available in Django-graphql-persist and their default values.
DOCUMENTS_DIRS
List of directories searched for GraphQL SDL definitions Default: None
CACHE_NAME
This selects the cache to use. Default: 'default'
CACHE_TIMEOUT_HANDLER
A custom function to generate the timeout, in seconds, to use for the cache Default: lambda query_key: 0 if settings.DEBUG else None
QUERY_KEY_HANDLER
A custom function to generate the persisted query key Default: lambda query_id, request: query_id
DEFAULT_RENDERER_CLASSES
A list or tuple of renderer classes that may be used when returning a persisted query response Default: ()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-graphql-persist-0.0.1.dev1.tar.gz.
File metadata
- Download URL: django-graphql-persist-0.0.1.dev1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c9ea0bcedf843828befe49d55218e5c656441f00ec02f5837711a713dab9203
|
|
| MD5 |
6d086b5e75e6fd7318bb96f8c6f4f4e3
|
|
| BLAKE2b-256 |
442c38318d6e4ee3794594c7e9a44c23bb3c4534b82bfe4f9cfb3ff1abe31314
|
File details
Details for the file django_graphql_persist-0.0.1.dev1-py2.py3-none-any.whl.
File metadata
- Download URL: django_graphql_persist-0.0.1.dev1-py2.py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b3bd8aded544eb92cb352e5d60f5eb440c0a0ace74823856f8e6e19cae08d33
|
|
| MD5 |
002d79c9128d9fd2d55f4c569bc495ad
|
|
| BLAKE2b-256 |
2c02ed28c0d09817e444916b200a4eef7fa30c3611229171ec211445085b39d0
|