{"id":26060995,"url":"https://github.com/flavors/django-graphql-persist","last_synced_at":"2025-04-11T08:46:28.269Z","repository":{"id":57420309,"uuid":"128070601","full_name":"flavors/django-graphql-persist","owner":"flavors","description":"Persisted queries for Graphene Django","archived":false,"fork":false,"pushed_at":"2019-02-09T21:15:13.000Z","size":68,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T06:21:43.225Z","etag":null,"topics":["cache","django","graphene","graphql","persist","persisted","versioning"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/django-graphql-persist","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flavors.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-04T14:02:49.000Z","updated_at":"2024-07-17T10:26:17.000Z","dependencies_parsed_at":"2022-09-15T02:51:06.771Z","dependency_job_id":null,"html_url":"https://github.com/flavors/django-graphql-persist","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavors%2Fdjango-graphql-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flavors","download_url":"https://codeload.github.com/flavors/django-graphql-persist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248362890,"owners_count":21091220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","django","graphene","graphql","persist","persisted","versioning"],"created_at":"2025-03-08T14:47:49.281Z","updated_at":"2025-04-11T08:46:28.244Z","avatar_url":"https://github.com/flavors.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Django GraphQL Persist\n======================\n\n|Pypi| |Wheel| |Build Status| |Codecov| |Code Climate|\n\n\n**Persisted queries** for `Django GraphQL`_\n\n.. _Django GraphQL: https://github.com/graphql-python/graphene-django\n\n\nDependencies\n------------\n\n* Django ≥ 1.11\n* Python ≥ 3.4\n\n\nInstallation\n------------\n\nInstall last stable version from Pypi.\n\n.. code:: sh\n\n    pip install django-graphql-persist\n\n\nInclude the ``PersistMiddleware`` middleware in your *MIDDLEWARE* settings:\n\n.. code:: python\n\n    MIDDLEWARE = [\n        ...\n        'graphql_persist.middleware.PersistMiddleware',\n        ...\n    ]\n\n\nLoaders\n-------\n\n*Django-graphql-persist* searches for documents directories in a number of places, depending on your ``DEFAULT_LOADER_CLASSES`` variable.\n\nBy default, *Django-graphql-persist* uses these document loaders:\n\n* **AppDirectoriesLoader**\n\nLoads documents from Django apps on the filesystem. For each app in ``INSTALLED_APPS``, the loader looks for a ``documents/`` subdirectory defined by ``APP_DOCUMENT_DIR`` variable.\n\n* **FilesystemLoader**\n\nLoads documents from the filesystem, according to ``DOCUMENTS_DIRS`` variable.\n\n* **URLLoader**\n\nLoads documents from urls, according to ``DOCUMENTS_DIRS``.\n\n.. code:: python\n\n    GRAPHQL_PERSIST = {\n        'DOCUMENTS_DIRS': [\n            '/app/documents',  # FilesystemLoader\n            'https:// ... /documents',  # URLLoader\n        ],\n    }\n\n**Cached Loader**\n\nBy default, the document system reads your documents every time they're rendered.\n\nConfigure the ``CachedEngine`` engine for caching documents.\n\n\n.. code:: python\n\n    GRAPHQL_PERSIST = {\n        'DEFAULT_LOADER_ENGINE_CLASS': [\n            graphql_persist.loaders.CachedEngine',\n        ],\n    }\n\nPersisted Query definition\n--------------------------\n\nYou can split schemas into separate files...\n\n``documents/fragments.graphql``\n\n.. code:: graphql\n\n    fragment userFields on UserType {\n      id\n      email\n    }\n\nand define Pythonic imports prefixed with ``#``.\n\n``documents/GetViewer.graphql``\n\n.. code:: graphql\n\n    # from fragments import userFields\n\n    {\n      viewer {\n        ...userFields\n      }\n    }\n\n\n**Persisted Query by** ``id``\n\n.. code:: json\n\n    {\n      \"id\": \"GetViewer\",\n      \"variables\": {}\n    }\n\n\nMultiple Operations\n-------------------\n\n``documents/users.graphql``\n\n.. code:: graphql\n\n    # from fragments import userFields\n\n    query GetViewer {\n      viewer {\n        ...userFields\n      }\n    }\n\n    query GetUsers($last: Int!) {\n      users(last: $last) {\n        ...userFields\n      }\n    }\n\n\n**Persisted Query by** ``id`` and ``operationName``\n\n.. code:: json\n\n    {\n      \"id\": \"users\",\n      \"operationName\": \"GetUsers\",\n      \"variables\": {\n        \"last\": 2\n      }\n    }\n\n\n✋ Versioning\n-------------\n\nThe versioning scheme is defined by the ``DEFAULT_VERSIONING_CLASS`` setting variable.\n\n.. code:: python\n\n    GRAPHQL_PERSIST = {\n        'DEFAULT_VERSIONING_CLASS': 'graphql_persist.versioning.AcceptHeaderVersioning'\n    }\n\nThis is the full **list of versioning classes**.\n\n+--------------------------+-------------------------------------+\n| DEFAULT_VERSIONING_CLASS |               Example               |\n+==========================+=====================================+\n|  AcceptHeaderVersioning  |  ``application/json; version=v1``   |\n+--------------------------+-------------------------------------+\n|   VendorTreeVersioning   | ``application/vnd.example.v1+json`` |\n+--------------------------+-------------------------------------+\n| QueryParameterVersioning |          ``?version=v1``            |\n+--------------------------+-------------------------------------+\n|    HostNameVersioning    |         ``v1.example.com``          |\n+--------------------------+-------------------------------------+\n\nConfigure the versioning scheme and storage the GraphQL documents according to the version.\n\n👇 **Example**\n\n.. code::\n\n    POST /graphql HTTP/1.1\n    Accept: application/json; version=v1.full\n\n    {\n      \"id\": \"GetViewer\",\n      \"variables\": {}\n    }\n\n.. code::\n\n    documents/\n    |\n    ├── v1/\n    │   ├── full/\n    │   |     └── GetViewer.graphql 👈\n    │   └── basic/\n    |   |     └── GetViewer.graphql\n    |   └── fragments/\n    |         └── users.graphql\n    └── v2/\n        └── full/\n        └── basic/\n\n👉 ``documents/v1/full/GetViewer.graphql``\n\n.. code:: graphql\n\n    # from ..fragments.users import userFields\n\n    {\n      viewer {\n        ...userFields\n      }\n    }\n\n\nSettings\n--------\n\nHere's a **list of settings** available in *Django-graphql-persist* and their default values.\n\n**DOCUMENTS_DIRS**\n\n::\n\n    List of directories or urls searched for GraphQL SDL definitions\n    Default: () \n\n**CACHE_NAME**\n\n::\n\n    Cache key name `CACHES[name]` to cache the queries results\n    Default: 'default'\n\n**QUERY_KEY_HANDLER**\n\n::\n\n    A custom function `f(query_id, request)` to generate the persisted query keys\n    Default: 'graphql_persist.query.query_key_handler'\n\n\n**DEFAULT_VERSIONING_CLASS**\n\n::\n\n    A versioning class to determine the `request.version` attribute\n    Default: None\n\n**DEFAULT_LOADER_ENGINE_CLASS**\n\n::\n\n    Class that takes a list of template loaders and attempts to load templates from them in order\n    Default: 'graphql_persist.loaders.Engine'\n    Note: Set variable to 'graphql_persist.loaders.CachedEngine' for caching documents\n\n**DEFAULT_LOADER_CLASSES**\n\n::\n\n    A list of loader classes to import documents from a particular source\n    Default: (\n        'graphql_persist.loaders.AppDirectoriesLoader',\n        'graphql_persist.loaders.FilesystemLoader',\n        'graphql_persist.loaders.URLLoader',\n    )\n\n**APP_DOCUMENT_DIR**\n\n::\n\n    Subdirectory of installed applications for searches documents\n    Default: 'documents'\n\n**DOCUMENTS_EXT**\n\n::\n\n    GraphQL document file extension\n    Default: '.graphql'\n\n**DEFAULT_RENDERER_CLASSES**\n\n::\n\n    A list of renderer classes that may be used when returning a persisted query response\n    Default: ()\n\n\n.. |Pypi| image:: https://img.shields.io/pypi/v/django-graphql-persist.svg\n   :target: https://pypi.python.org/pypi/django-graphql-persist\n\n.. |Wheel| image:: https://img.shields.io/pypi/wheel/django-graphql-persist.svg\n   :target: https://pypi.python.org/pypi/django-graphql-persist\n\n.. |Build Status| image:: https://travis-ci.org/flavors/django-graphql-persist.svg?branch=master\n   :target: https://travis-ci.org/flavors/django-graphql-persist\n\n.. |Codecov| image:: https://img.shields.io/codecov/c/github/flavors/django-graphql-persist.svg\n   :target: https://codecov.io/gh/flavors/django-graphql-persist\n\n.. |Code Climate| image:: https://api.codeclimate.com/v1/badges/46eaf45a95441d5470a4/maintainability\n   :target: https://codeclimate.com/github/flavors/django-graphql-persist\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavors%2Fdjango-graphql-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflavors%2Fdjango-graphql-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavors%2Fdjango-graphql-persist/lists"}