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 105 of 119

0.31.0

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

Add `process_result` to views for Django, Flask and ASGI. They can be overridden
to provide a custom response and also to process results and errors.

It also removes `request` from Flask view's `get_root_value` and `get_context`
since request in Flask is a global.

Django example:

python
views.py
from django.http import HttpRequest
from strawberry.django.views import GraphQLView as BaseGraphQLView
from strawberry.http import GraphQLHTTPResponse
from strawberry.types import ExecutionResult


class GraphQLView(BaseGraphQLView):
def process_result(
self, request: HttpRequest, result: ExecutionResult
) -> GraphQLHTTPResponse:
return {"data": result.data, "errors": result.errors or []}


Flask example:

python
views.py
from strawberry.flask.views import GraphQLView as BaseGraphQLView
from strawberry.http import GraphQLHTTPResponse
from strawberry.types import ExecutionResult


class GraphQLView(BaseGraphQLView):
def process_result(self, result: ExecutionResult) -> GraphQLHTTPResponse:
return {"data": result.data, "errors": result.errors or []}


ASGI example:

python
from strawberry.asgi import GraphQL as BaseGraphQL
from strawberry.http import GraphQLHTTPResponse
from strawberry.types import ExecutionResult
from starlette.requests import Request

from .schema import schema


class GraphQL(BaseGraphQLView):
async def process_result(
self, request: Request, result: ExecutionResult
) -> GraphQLHTTPResponse:
return {"data": result.data, "errors": result.errors or []}

0.30.1

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

This releases fixes the check for unset values.

0.30.0

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

Add functions `get_root_value` and `get_context` to views for Django, Flask and
ASGI. They can be overridden to provide custom values per request.

Django example:

python
views.py
from strawberry.django.views import GraphQLView as BaseGraphQLView


class GraphQLView(BaseGraphQLView):
def get_context(self, request):
return {
"request": request,
"custom_context_value": "Hi!",
}

def get_root_value(self, request):
return {
"custom_root_value": "🍓",
}


urls.py
from django.urls import path

from .views import GraphQLView
from .schema import schema

urlpatterns = [
path("graphql/", GraphQLView.as_view(schema=schema)),
]


Flask example:

python
views.py
from strawberry.flask.views import GraphQLView as BaseGraphQLView


class GraphQLView(BaseGraphQLView):
def get_context(self, request):
return {
"request": request,
"custom_context_value": "Hi!",
}

def get_root_value(self, request):
return {
"custom_root_value": "🍓",
}


app.py
from flask import Flask

from .views import GraphQLView
from .schema import schema

app = Flask(__name__)

app.add_url_rule(
"/graphql",
view_func=GraphQLView.as_view("graphql_view", schema=schema),
)



ASGI example:

python
app.py
from strawberry.asgi import GraphQL as BaseGraphQL

from .schema import schema


class GraphQL(BaseGraphQLView):
async def get_context(self, request):
return {
"request": request,
"custom_context_value": "Hi!",
}

async def get_root_value(self, request):
return {
"custom_root_value": "🍓",
}


app = GraphQL(schema)

0.29.1

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

Support for `default_value` on inputs.

Usage:
python
class MyInput:
s: Optional[str] = None
i: int = 0

graphql
input MyInput {
s: String = null
i: Int! = 0
}

0.29.0

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

This release adds support for file uploads within Django.

We follow the following spec: https://github.com/jaydenseric/graphql-multipart-request-spec


Example:

python
import strawberry
from strawberry.file_uploads import Upload


strawberry.type
class Mutation:
strawberry.mutation
def read_text(self, text_file: Upload) -> str:
return text_file.read().decode()

0.28.5

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

Fix issue when reusing an interface

Page 105 of 119

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.