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: ()
CACHE_NAME
This selects the cache to use Default: 'default'
QUERY_KEY_HANDLER
A custom function to generate the persisted query key Default: 'graphql_persist.query.query_key_handler'
DEFAULT_VERSIONING_CLASS
A versioning class to determine the `request.version` attribute Default: None
DEFAULT_LOADER_CLASSES
A list of documents loader classes. Each Loader class knows how to import documents from a particular source. Default: ( 'graphql_persist.loaders.AppDirectoriesLoader', 'graphql_persist.loaders.FilesystemLoader', 'graphql_persist.loaders.URLLoader', )
DEFAULT_RENDERER_CLASSES
A list 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
Hashes for django-graphql-persist-0.0.1.dev2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67100bad0fa8166abff42fbb072ada6d4ba332f4644daa4b275dff8c02ba6cb |
|
MD5 | ad7cead01d2a3fda6c4230ed6daf0c03 |
|
BLAKE2b-256 | 5281b04cd81dc5b24772f5ff947808a0cff541ad5d6fa93ac395007748592a31 |
Hashes for django_graphql_persist-0.0.1.dev2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4440de7405c5775255190138693d911853f3b5a271c62ae2c1c621d05cc8439 |
|
MD5 | a4cc664f6a624c4af005ffd49ab0d582 |
|
BLAKE2b-256 | ee268a1b4e1fc78ace4d662377f5007a483a552894fc323ee992286985fe37d8 |