Metadata-Version: 2.1
Name: strawberry_persisted_queries
Version: 1.1.0
Summary: Apollo-compatible persisted queries for Strawberry
Home-page: https://github.com/catgirlinspace/strawberry_persisted_queries.git
License: MIT
Author: Rosalina
Author-email: catgirl@catgirlin.space
Requires-Python: >=3.10,<4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: django
Requires-Dist: django (>=5.0.3,<6.0.0) ; extra == "django"
Requires-Dist: strawberry-graphql (>=0.226)
Project-URL: Repository, https://github.com/catgirlinspace/strawberry_persisted_queries.git
Description-Content-Type: text/markdown

# 🍓Strawberry Persisted Queries

[![PyPI](https://img.shields.io/pypi/v/strawberry_persisted_queries?logo=pypi&logoColor=white&style=for-the-badge)](https://pypi.org/project/strawberry_persisted_queries/)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/catgirlinspace?style=for-the-badge&logo=githubsponsors)](https://github.com/sponsors/catgirlinspace)

Apollo-compatible persisted queries for Strawberry. 

## Usage

Add `PersistedQueriesExtension()` to your extensions.

```python
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. 
```python
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.

```python
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`. 

```python
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())
```

