Strawberry-graphql

Latest version: v0.229.1

Safety actively analyzes 629855 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 67 of 119

0.92.2

Not secure
-------------------

This release adds support for passing `json_encoder` and `json_dumps_params` to Django [`JsonResponse`](https://docs.djangoproject.com/en/stable/ref/request-response/#jsonresponse-objects) via a view.


python
from json import JSONEncoder

from django.urls import path
from strawberry.django.views import AsyncGraphQLView

from .schema import schema

Pass the JSON params to `.as_view`
urlpatterns = [
path(
"graphql",
AsyncGraphQLView.as_view(
schema=schema,
json_encoder=JSONEncoder,
json_dumps_params={"separators": (",", ":")},
),
),
]


… or set them in a custom view
class CustomAsyncGraphQLView(AsyncGraphQLView):
json_encoder = JSONEncoder
json_dumps_params = {"separators": (",", ":")}


Contributed by [Illia Volochii](https://github.com/illia-v) [PR #1472](https://github.com/strawberry-graphql/strawberry/pull/1472/)

0.92.1

Not secure
-------------------

Fix cross-module type resolving for fields and resolvers

The following two issues are now fixed:

- A field with a generic (typeless) resolver looks up the
type relative to the resolver and not the class the field is
defined in. (1448)

- When inheriting fields from another class the origin of the
fields are set to the inheriting class and not the class the
field is defined in.

Both these issues could lead to a rather undescriptive error message:

> TypeError: (...) fields cannot be resolved. Unexpected type 'None'

Contributed by [Michael P. Jung](https://github.com/bikeshedder) [PR #1449](https://github.com/strawberry-graphql/strawberry/pull/1449/)

0.92.0

Not secure
-------------------

This releases fixes an issue where you were not allowed
to return a non-strawberry type for fields that return
an interface. Now this works as long as each type
implementing the interface implements an `is_type_of`
classmethod. Previous automatic duck typing on types
that implement an interface now requires explicit
resolution using this classmethod.

Contributed by [Etty](https://github.com/estyxx) [PR #1299](https://github.com/strawberry-graphql/strawberry/pull/1299/)

0.91.0

Not secure
-------------------

This release adds a `GraphQLTestClient`. It hides the http request's details and asserts that there are no errors in the response (you can always disable this behavior by passing `asserts_errors=False`). This makes it easier to test queries and makes your tests cleaner.

If you are using `pytest` you can add a fixture in `conftest.py`

python
import pytest

from django.test.client import Client

from strawberry.django.test import GraphQLTestClient


pytest.fixture
def graphql_client():
yield GraphQLTestClient(Client())


And use it everywere in your test methods

python
def test_strawberry(graphql_client):
query = """
query Hi($name: String!) {
hi(name: $name)
}
"""

result = graphql_client.query(query, variables={"name": "Marcotte"})

assert result.data == {"hi": "Hi Marcotte!"}


It can be used to test the file uploads as well

python
from django.core.files.uploadedfile import SimpleUploadedFile


def test_upload(graphql_client):
f = SimpleUploadedFile("file.txt", b"strawberry")
query = """
mutation($textFile: Upload!) {
readText(textFile: $textFile)
}
"""

response = graphql_client.query(
query=query,
variables={"textFile": None},
files={"textFile": f},
)

assert response.data["readText"] == "strawberry"


Contributed by [Etty](https://github.com/estyxx) [PR #1225](https://github.com/strawberry-graphql/strawberry/pull/1225/)

0.90.3

Not secure
-------------------

This release fixes an issue that prevented using enums as
arguments for generic types inside unions.

Contributed by [Patrick Arminio](https://github.com/patrick91) [PR #1463](https://github.com/strawberry-graphql/strawberry/pull/1463/)

0.90.2

Not secure
-------------------

This release fixes the message of `InvalidFieldArgument` to properly show the field's name in the error message.

Contributed by [Etty](https://github.com/estyxx) [PR #1322](https://github.com/strawberry-graphql/strawberry/pull/1322/)

Page 67 of 119

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.