-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
275 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
import typing | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Optional | ||
|
||
import pytest | ||
from starlette.testclient import TestClient | ||
|
||
import strawberry | ||
from strawberry.asgi import GraphQL | ||
|
||
if TYPE_CHECKING: | ||
from starlette.testclient import TestClient | ||
|
||
|
||
@pytest.fixture | ||
def test_client() -> TestClient: | ||
from starlette.testclient import TestClient | ||
|
||
from strawberry.asgi import GraphQL | ||
|
||
@strawberry.type | ||
class Query: | ||
@strawberry.field | ||
async def hello(self, name: typing.Optional[str] = None) -> str: | ||
async def hello(self, name: Optional[str] = None) -> str: | ||
return f"Hello {name or 'world'}" | ||
|
||
async_schema = strawberry.Schema(Query) | ||
app = GraphQL(async_schema) | ||
app = GraphQL[None, None](async_schema) | ||
return TestClient(app) | ||
|
||
|
||
def test_simple_query(test_client): | ||
def test_simple_query(test_client: TestClient): | ||
response = test_client.post("/", json={"query": "{ hello }"}) | ||
|
||
assert response.json() == {"data": {"hello": "Hello world"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.