Skip to content

Commit

Permalink
fix async sdl resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
m.kindritskiy committed Sep 8, 2023
1 parent 72043d3 commit 4f7ee80
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions hiku/federation/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def service_resolver(
return [{"sdl": ctx["__sdl__"]}]

def _async(func: t.Callable) -> t.Callable:
@pass_context
async def wrapper(*args: t.Any, **kwargs: t.Any) -> t.List[t.Dict]:
return func(*args, **kwargs)

Expand Down
20 changes: 19 additions & 1 deletion tests/test_federation/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,31 @@ async def execute_async_v2(query: Dict, graph: Graph):

SDL_QUERY = {'query': '{_service {sdl}}'}

Q = {
'query': """
query __ApolloGetServiceDefinition__ { _service { sdl } }
""",
'variables': None,
'operationName': '__ApolloGetServiceDefinition__',
}


@pytest.mark.parametrize('executor', [
execute_v1,
execute_v2,
])
def test_fetch_sdl(executor):
result = executor(SDL_QUERY, GRAPH)
result = executor(Q, GRAPH)
assert result['data']['_service']['sdl'] is not None


@pytest.mark.parametrize('executor', [
execute_async_v1,
execute_async_v2,
])
@pytest.mark.asyncio
async def test_fetch_sdl_async(executor):
result = await executor(Q, ASYNC_GRAPH)
assert result['data']['_service']['sdl'] is not None


Expand Down

0 comments on commit 4f7ee80

Please sign in to comment.