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
The timeout, in seconds, to use for the cache (infinite by default). Default: None
KEY_PREFIX
A string that will be automatically prepended to all cache keys used for persisted queries. Default: 'persist'
CACHE_KEY_HANDLER
... Default: lambda document_id, request: document_id
PERSISTED_RESPONSE_HANDLER
... Default: None
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
Hashes for django-graphql-persist-0.0.1.dev0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a66a788991f0b72e8cc830c1ff597e29578689749f57da047b7fcbe675267e73 |
|
MD5 | e27945d824f682ac9ffd6091dd7e151c |
|
BLAKE2b-256 | 647c7379d87813794e628ae0c076ab428dafdf6d495924c97f2a6c141bba1593 |
Hashes for django_graphql_persist-0.0.1.dev0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a438bb597689655b2989c75d580f3660f41e3b8979e15a60b01a4d134b69df87 |
|
MD5 | 01aa359e240ccf1e01b346054c73290d |
|
BLAKE2b-256 | 918ae22955bca8b1c1b9754200ec2646c94725c92812826d58736c7b1258c0be |