Skip to main content

Apollo-compatible persisted queries for Strawberry

Project description

🍓Strawberry Persisted Queries

PyPI GitHub Sponsors

Apollo-compatible persisted queries for Strawberry.

Usage

Add PersistedQueriesExtension() to your extensions.

import strawberry
from strawberry_persisted_queries import PersistedQueriesExtension

schema = strawberry.Schema(
    query=Query,
    extensions=[
        PersistedQueriesExtension(),
    ],
)

Django

For Django users, a Django cache backend is available. This uses the default cache set in Django.

from strawberry_persisted_queries.django_cache import DjangoPersistedQueryCache

PersistedQueriesExtension(cache_backend=DjangoPersistedQueryCache())

Safelisted Queries

DictSafelist can be used to require persisted queries to already be saved. This can be used with a build tool to ensure only queries used within an app are available.

from strawberry_persisted_queries.safelisting import DictSafelist

PersistedQueriesExtension(safelist=DictSafelist({
    'sha256Hash': 'query {...}',
}))

Custom Cache Backends

Custom cache backends allow using another cache for persisted queries, such as memcached or a database. Custom cache backends can inherit from strawberry_persisted_queries.PersistedQueryCache.

from strawberry_persisted_queries.cache import PersistedQueryCache

class MyCache(PersistedQueryCache):
    def get(self, query_hash):
        return cache.get(query_hash)

    def set(self, query_hash, value):
        cache.set(query_hash, value)

PersistedQueriesExtension(cache_backend=MyCache())

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

strawberry_persisted_queries-1.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strawberry_persisted_queries-1.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file strawberry_persisted_queries-1.1.0.tar.gz.

File metadata

  • Download URL: strawberry_persisted_queries-1.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-1018-azure

File hashes

Hashes for strawberry_persisted_queries-1.1.0.tar.gz
Algorithm Hash digest
SHA256 32aa8afa40e9de10e62c2fb208f773ea939bc7ca4236e6471cf5c75c3100254b
MD5 ce1c42ecbfafff97c47efaebce283d9b
BLAKE2b-256 454dadea372d7aa3b617b088a42cc13b512ea549c51cd05f8bf32cde9aba4c1a

See more details on using hashes here.

File details

Details for the file strawberry_persisted_queries-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for strawberry_persisted_queries-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c581f0cb90d3cd85a548965c9fb36abd67204245aea077843133da91dd71477
MD5 75fbdd412cdeca98b376820cbd07b535
BLAKE2b-256 5c43177945d17d1ca8e7b6653b3c2718ba481df82182196d79e31d93d07a78ad

See more details on using hashes here.

Supported by

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