Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate starlite integration. closes #3359 #3492

Merged
merged 6 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.DS_Store


# Created by https://www.gitignore.io/api/macos,linux,python,windows
# Edit at https://www.gitignore.io/?templates=macos,linux,python,windows

Expand Down
17 changes: 17 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Release type: patch

**Deprecations:** This release deprecates the `Starlite` integration in favour of the `LiteStar` integration.
Refer to the [LiteStar](./litestar.md) integration for more information.
LiteStar is a [renamed](https://litestar.dev/about/organization.html#litestar-and-starlite) and upgraded version of Starlite.

Before:

```python
from strawberry.starlite import make_graphql_controller
```

After:

```python
from strawberry.litestar import make_graphql_controller
```
10 changes: 10 additions & 0 deletions docs/integrations/starlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ title: Starlite

# Starlite

## Deprecation Notice

This integration has been deprecated in favor of the `Litestar` integration.
Refer to the [Litestar](./litestar.md) integration for more information.
Litestar is a
[renamed](https://litestar.dev/about/organization.html#litestar-and-starlite)
and upgraded version of Starlite.

## How to use

Strawberry comes with an integration for
[Starlite](https://starliteproject.dev/) by providing a
`make_graphql_controller` function that can be used to create a GraphQL
Expand Down
9 changes: 9 additions & 0 deletions strawberry/starlite/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dataclasses import dataclass
from datetime import timedelta
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Tuple, Union, cast
from typing_extensions import deprecated

from starlite import (
BackgroundTasks,
Expand Down Expand Up @@ -118,6 +119,10 @@ async def get_root_value(self) -> Any:
return await self._get_root_value()


@deprecated(
"The `starlite` integration is deprecated in favor of `litestar` integration",
stacklevel=2,
)
class StarliteRequestAdapter(AsyncHTTPRequestAdapter):
def __init__(self, request: Request[Any, Any]) -> None:
self.request = request
Expand Down Expand Up @@ -153,6 +158,10 @@ def __init__(self) -> None:
self.response: Optional[Response] = None


@deprecated(
"The `starlite` integration is deprecated in favor of `litestar` integration",
stacklevel=2,
)
def make_graphql_controller(
schema: BaseSchema,
path: str = "",
Expand Down
19 changes: 19 additions & 0 deletions tests/starlite/test_context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Dict

import pytest

import strawberry

try:
Expand Down Expand Up @@ -181,3 +183,20 @@

assert response.json() == {"data": {"something": "foo"}}
assert task_complete


def test_starlite_usage_triggers_deprecation_warning():
@strawberry.type
class Query:
@strawberry.field
def abc(self, info: strawberry.Info) -> str:
assert info.context.get("request") is not None
assert info.context.get("strawberry") is None
return "abc"

Check warning on line 195 in tests/starlite/test_context.py

View check run for this annotation

Codecov / codecov/patch

tests/starlite/test_context.py#L193-L195

Added lines #L193 - L195 were not covered by tests

schema = strawberry.Schema(query=Query)
Birdi7 marked this conversation as resolved.
Show resolved Hide resolved

with pytest.deprecated_call(
match="The `starlite` integration is deprecated in favor of `litestar` integration"
):
make_graphql_controller(path="/graphql", schema=schema, context_getter=None)
Loading