Skip to content

Commit

Permalink
Merge branch 'main' into feature/multipart
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 committed Mar 1, 2024
2 parents 4935201 + 364d152 commit 492b6af
Show file tree
Hide file tree
Showing 89 changed files with 1,658 additions and 1,265 deletions.
6 changes: 3 additions & 3 deletions .github/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.ruff]
extend = "../pyproject.toml"
extend-ignore = [
"T201",
]

[tool.ruff.lint]
extend-ignore = ["T201"]
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.2.1
hooks:
- id: ruff-format
exclude: ^tests/\w+/snapshots/
Expand All @@ -14,7 +14,7 @@ repos:
exclude: (CHANGELOG|TWEET).md

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: '^docs/.*\.mdx?$'
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"proseWrap": "always",
"printWidth": 80
}
83 changes: 59 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
CHANGELOG
=========

0.219.2 - 2024-02-06
--------------------

This releases updates the dependency of `python-multipart` to be at least `0.0.7` (which includes a security fix).

It also removes the upper bound for `python-multipart` so you can always install the latest version (if compatible) 😊

Contributed by [Srikanth](https://github.com/XChikuX) via [PR #3375](https://github.com/strawberry-graphql/strawberry/pull/3375/)


0.219.1 - 2024-01-28
--------------------

- Improved error message when supplying in incorrect before or after argument with using relay and pagination.
- Add extra PR requirement in README.md

Contributed by [SD](https://github.com/sdobbelaere) via [PR #3361](https://github.com/strawberry-graphql/strawberry/pull/3361/)


0.219.0 - 2024-01-24
--------------------

Expand Down Expand Up @@ -128,6 +147,32 @@ class Query:
The old way of adding permissions using `permission_classes` is still
supported via the automatic addition of a `PermissionExtension` on the field.

### ⚠️ Breaking changes

Previously the `kwargs` argument keys for the `has_permission` method were
using camel casing (depending on your schema configuration), now they will
always follow the python name defined in your resolvers.

```python
class IsAuthorized(BasePermission):
message = "User is not authorized"

def has_permission(
self, source, info, **kwargs: typing.Any
) -> bool: # pragma: no cover
# kwargs will have a key called "a_key"
# instead of `aKey`

return False


@strawberry.type
class Query:
@strawberry.field(permission_classes=[IsAuthorized])
def name(self, a_key: str) -> str: # pragma: no cover
return "Erik"
```

Using the new `PermissionExtension` API, permissions support even more features:

#### Silent errors
Expand Down Expand Up @@ -882,13 +927,11 @@ class Node:


@strawberry.type
class Video(Node):
...
class Video(Node): ...


@strawberry.type
class Image(Node):
...
class Image(Node): ...


@strawberry.type
Expand Down Expand Up @@ -1699,8 +1742,9 @@ if TYPE_CHECKING:
@strawberry.type
class MyType:
@strawberry.field
async def other_type(self) -> Annotated[OtherType, strawberry.lazy("some.module")]:
...
async def other_type(
self,
) -> Annotated[OtherType, strawberry.lazy("some.module")]: ...
```

Contributed by [Thiago Bellini Ribeiro](https://github.com/bellini666) via [PR #2744](https://github.com/strawberry-graphql/strawberry/pull/2744/)
Expand Down Expand Up @@ -2540,8 +2584,7 @@ class UserPydantic(pydantic.BaseModel):


@strawberry.experimental.pydantic.type(UserPydantic, all_fields=True)
class User:
...
class User: ...


@strawberry.type
Expand Down Expand Up @@ -2904,8 +2947,7 @@ class Foo(Generic[T]):


@strawberry.type
class IntFoo(Foo[int]):
...
class IntFoo(Foo[int]): ...


@strawberry.type
Expand Down Expand Up @@ -4008,8 +4050,7 @@ class MyModel(BaseModel):


@strawberry.experimental.pydantic.input(model=MyModel, all_fields=True)
class MyModelStrawberry:
...
class MyModelStrawberry: ...


MyModelStrawberry(email="").to_pydantic()
Expand Down Expand Up @@ -5844,8 +5885,7 @@ class Example(BaseModel):
@strawberry.experimental.pydantic.input(model=Example, all_fields=True)
class ExampleGQL:
...
class ExampleGQL: ...
@strawberry.type
Expand Down Expand Up @@ -6826,13 +6866,11 @@ from strawberry.tools import merge_types
@strawberry.type
class QueryA:
...
class QueryA: ...
@strawberry.type
class QueryB:
...
class QueryB: ...
ComboQuery = merge_types("ComboQuery", (QueryB, QueryA))
Expand Down Expand Up @@ -7194,8 +7232,7 @@ Word = strawberry.union("Word", types=(Noun, Verb))
@strawberry.field
def add_word(word: Word) -> bool:
...
def add_word(word: Word) -> bool: ...
```
Contributed by [Mohammad Hossein Yazdani](https://github.com/MAM-SYS) [PR #1222](https://github.com/strawberry-graphql/strawberry/pull/1222/)
Expand Down Expand Up @@ -7362,8 +7399,7 @@ def name() -> str:
MyType = create_type("MyType", [name])
class Query(MyType):
...
class Query(MyType): ...
```
Contributed by [Patrick Arminio](https://github.com/patrick91) [PR #1175](https://github.com/strawberry-graphql/strawberry/pull/1175/)
Expand Down Expand Up @@ -9041,8 +9077,7 @@ class Query:
@strawberry.field
def user_by_id(
id: Annotated[str, strawberry.argument(description="The ID of the user")]
) -> User:
...
) -> User: ...
```
which results in the following schema:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ poetry install --with integrations
poetry run pytest
```

This will install all the dependencies (including dev ones) and run the tests.
For all further detail, check out the [Contributing Page](CONTRIBUTING.md)


### Pre commit

Expand Down
1 change: 1 addition & 0 deletions docs/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: List of breaking changes and deprecations

# List of breaking changes and deprecations

- [Version 0.217.0 - 18 December 2023](./breaking-changes/0.217.0.md)
- [Version 0.213.0 - 8 November 2023](./breaking-changes/0.213.0.md)
- [Version 0.180.0 - 31 May 2023](./breaking-changes/0.180.0.md)
- [Version 0.169.0 - 5 April 2023](./breaking-changes/0.169.0.md)
Expand Down
6 changes: 2 additions & 4 deletions docs/breaking-changes/0.159.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ The old style hooks are still supported but will be removed in future releases.

```python
class MyExtension(Extension):
def on_executing_start(self):
...
def on_executing_start(self): ...

def on_executing_end(self):
...
def on_executing_end(self): ...
```

## After
Expand Down
9 changes: 3 additions & 6 deletions docs/breaking-changes/0.169.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ Both `get_root_value` and `get_context` now receive the request as a parameter.
If you're customizing these methods you can change the signature to:

```python
def get_root_value(self, request: Request) -> Any:
...
def get_root_value(self, request: Request) -> Any: ...


def get_context(self, request: Request, response: Response) -> Any:
...
def get_context(self, request: Request, response: Response) -> Any: ...
```

The same is true for the async version of the view.
Expand All @@ -29,6 +27,5 @@ async.
If you're customizing this method you can change the signature to:

```python
async def get_root_value(self, request: Request) -> Any:
...
async def get_root_value(self, request: Request) -> Any: ...
```
25 changes: 13 additions & 12 deletions docs/breaking-changes/0.180.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ title: 0.180.0 Breaking changes

# v0.180.0 introduces a breaking change for the Django Channels HTTP integration

The context object is now a `dict`. This means that you should access the context
value using the `["key"]` syntax instead of the `.key` syntax.
The context object is now a `dict`. This means that you should access the
context value using the `["key"]` syntax instead of the `.key` syntax.

For the HTTP integration, there is also no `ws` key anymore and `request` is a custom
request object containing the full request instead of a `GraphQLHTTPConsumer` instance.
If you need to access the `GraphQLHTTPConsumer` instance in a HTTP connection, you can
access it via `info.context["request"].consumer`.
For the HTTP integration, there is also no `ws` key anymore and `request` is a
custom request object containing the full request instead of a
`GraphQLHTTPConsumer` instance. If you need to access the `GraphQLHTTPConsumer`
instance in a HTTP connection, you can access it via
`info.context["request"].consumer`.

For the WebSockets integration, the context keys did not change, e.g. the values for
`info.context["ws"]`, `info.context["request"]` and `info.context["connection_params"]`
are the same as before.
For the WebSockets integration, the context keys did not change, e.g. the values
for `info.context["ws"]`, `info.context["request"]` and
`info.context["connection_params"]` are the same as before.

If you still want to use the `.key` syntax, you can override `get_context()`
to return a custom dataclass there. See the Channels integration documentation
for an example.
If you still want to use the `.key` syntax, you can override `get_context()` to
return a custom dataclass there. See the Channels integration documentation for
an example.
6 changes: 4 additions & 2 deletions docs/breaking-changes/0.213.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ title: 0.213.0 Deprecation
# v0.213.0 introduces a deprecation for `graphiql` parameter

All HTTP integration now will use `graphql_ide` instead of `graphiql` parameter.
If you're not using the `graphiql` parameter, you can safely ignore this deprecation.
If you're not using the `graphiql` parameter, you can safely ignore this
deprecation.

If you're using the `graphiql` parameter, you should change it to `graphql_ide` instead.
If you're using the `graphiql` parameter, you should change it to `graphql_ide`
instead.

Here's an example of the changes:

Expand Down
29 changes: 29 additions & 0 deletions docs/breaking-changes/0.217.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: 0.217 Breaking Changes
---

# v0.217.0 changes how kwargs are passed to `has_permission` method

Previously the `kwargs` argument keys for the `has_permission` method were using
camel casing (depending on your schema configuration), now they will always
follow the python name defined in your resolvers.

```python
class IsAuthorized(BasePermission):
message = "User is not authorized"

def has_permission(
self, source, info, **kwargs: typing.Any
) -> bool: # pragma: no cover
# kwargs will have a key called "a_key"
# instead of `aKey`

return False


@strawberry.type
class Query:
@strawberry.field(permission_classes=[IsAuthorized])
def name(self, a_key: str) -> str: # pragma: no cover
return "Erik"
```
10 changes: 4 additions & 6 deletions docs/codegen/query-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ class QueryCodegenPlugin:
"""
self.query = query

def on_start(self) -> None:
...
def on_start(self) -> None: ...

def on_end(self, result: CodegenResult) -> None:
...
def on_end(self, result: CodegenResult) -> None: ...

def generate_code(
self, types: List[GraphQLType], operation: GraphQLOperation
Expand All @@ -147,8 +145,8 @@ class QueryCodegenPlugin:

### Console plugin

There is also a plugin that helps to orchestrate the codegen process and notify the
user about what the current codegen process is doing.
There is also a plugin that helps to orchestrate the codegen process and notify
the user about what the current codegen process is doing.

The interface for the ConsolePlugin looks like:

Expand Down
8 changes: 4 additions & 4 deletions docs/concepts/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ title: Async

# Async

Async is a concurrent programming design that has been supported in Python
since version 3.4. To learn more about async in Python refer to
Async is a concurrent programming design that has been supported in Python since
version 3.4. To learn more about async in Python refer to
[Real Python’s Async walkthrough](https://realpython.com/async-io-python/).

Strawberry supports both async and non async resolvers, so you can mix and
match them in your code. Here’s an example of an async resolver:
Strawberry supports both async and non async resolvers, so you can mix and match
them in your code. Here’s an example of an async resolver:

```python
import asyncio
Expand Down
4 changes: 2 additions & 2 deletions docs/editors/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ title: Visual studio code
Strawberry comes with support for both MyPy and Pylance, Microsoft's own
language server for Python.

This guide will explain how to configure Visual Studio Code and Pylance to
work with Strawberry.
This guide will explain how to configure Visual Studio Code and Pylance to work
with Strawberry.

## Install Pylance

Expand Down
4 changes: 2 additions & 2 deletions docs/errors/missing-arguments-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Query:
schema = strawberry.Schema(query=Query)
```

This happens because Strawberry needs to know the type of every argument to be able to
generate the correct GraphQL type.
This happens because Strawberry needs to know the type of every argument to be
able to generate the correct GraphQL type.

## How to fix this error

Expand Down
Loading

0 comments on commit 492b6af

Please sign in to comment.