Closed iot-resister closed 3 years ago
First off, great library! Thanks for putting it out here. However, I'm a having bit of trouble getting ariadne support.
The following:
test.py
from async_asgi_testclient import TestClient import pytest from src.core.reside import move_to_planet, MoveToPlanetInput @pytest.mark.asyncio async def test_graphql_out_planet_hello() -> None: from src.ui.graphql.main import app async with TestClient(app) as client: query = '{residence(residentName: "Joe"){welcomeMsg}}' result = await client.post( "/graphql", json={"query": query} ).json() assert result["data"]["residence"]["welcomeMsg"] == "Welcome to Tatooine!
yields:
self = <ariadne.asgi.GraphQL object at 0x7ffb8c0bdf40>, scope = {'asgi': {'version': '3.0'}, 'type': 'lifespan'} receive = <bound method Queue.get of <Queue at 0x7ffb8c2b4c10 maxsize=0 _queue=[{'type': 'lifespan.startup'}] tasks=1>> send = <bound method Queue.put of <Queue at 0x7ffb8c2b46d0 maxsize=0 tasks=1>>
Here is my app.py for reference
app,py
from typing import Optional from ariadne import ( make_executable_schema, MutationType, QueryType, ) from ariadne.asgi import GraphQL from apischema.graphql import graphql_schema from graphql import print_schema from src.core.reside import MoveToPlanet, move_to_planet, MoveToPlanetInput, residence mutation = MutationType() type_defs = print_schema(graphql_schema(query=[residence], mutation=[move_to_planet])) @mutation.field("moveToPlanet") def resolve_move_to_planet( *_: None, planetId: str, residentName: str ) -> Optional[MoveToPlanet]: return move_to_planet( MoveToPlanetInput(planet_id=planetId, resident_name=residentName) ) query = QueryType() @query.field("residence") def resolve_residence(*_: None, residentName: str) -> MoveToPlanet: return residence(residentName) schema = make_executable_schema( type_defs, [query, mutation], snake_case_fallback_resolvers ) app = GraphQL(schema)
nvm https://github.com/mirumee/ariadne/issues/286
First off, great library! Thanks for putting it out here. However, I'm a having bit of trouble getting ariadne support.
The following:
test.py
yields:
Here is my app.py for reference
app,py