Skip to content
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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from setuptools import setup, find_packages

required_packages = [
'graphql-core>=1.0',
'graphql-server-core>=1.0.dev',
'graphql-core>=2.1',
'graphql-server-core>=1.1.1',
'sanic>=0.5.1',
'pytest-runner'
]
Expand Down
15 changes: 9 additions & 6 deletions tests/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def resolve_raises(*_):
fields={
'thrower': GraphQLField(GraphQLNonNull(GraphQLString), resolver=resolve_raises),
'request': GraphQLField(GraphQLNonNull(GraphQLString),
resolver=lambda obj, args, context, info: context['request'].args.get('q')),
resolver=lambda obj, info: info.context['request'].args.get('q')),
'context': GraphQLField(GraphQLNonNull(GraphQLString),
resolver=lambda obj, args, context, info: context),
resolver=lambda obj, info: info.context),
'test': GraphQLField(
type=GraphQLString,
args={
'who': GraphQLArgument(GraphQLString)
},
resolver=lambda obj, args, context, info: 'Hello %s' % (args.get('who') or 'World')
resolver=lambda obj, info, who=None: 'Hello %s' % (who or 'World')
)
}
)
Expand All @@ -42,17 +42,20 @@ def resolve_raises(*_):


# Schema with async methods
async def resolver(context, *_):
async def resolver(context, *_, **__):
await asyncio.sleep(0.001)
return 'hey'

async def resolver_2(context, *_):

async def resolver_2(context, *_, **__):
await asyncio.sleep(0.003)
return 'hey2'

def resolver_3(context, *_):

def resolver_3(context, *_, **__):
return 'hey3'


AsyncQueryType = GraphQLObjectType('AsyncQueryType', {
'a': GraphQLField(GraphQLString, resolver=resolver),
'b': GraphQLField(GraphQLString, resolver=resolver_2),
Expand Down
14 changes: 8 additions & 6 deletions tests/test_graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_handles_field_errors_caught_by_graphql(app):
assert response.status == 200
assert response_json(response) == {
'data': None,
'errors': [{'locations': [{'column': 2, 'line': 1}], 'message': 'Throws!'}]
'errors': [{'locations': [{'column': 2, 'line': 1}], 'message': 'Throws!', 'path': ['thrower']}]
}


Expand All @@ -394,9 +394,12 @@ def test_handles_syntax_errors_caught_by_graphql(app):
_, response = app.client.get(uri=url_string(query='syntaxerror'))
assert response.status == 400
assert response_json(response) == {
'errors': [{'locations': [{'column': 1, 'line': 1}],
'message': 'Syntax Error GraphQL request (1:1) '
'Unexpected Name "syntaxerror"\n\n1: syntaxerror\n ^\n'}]
'errors': [
{
'locations': [{'column': 1, 'line': 1}],
'message': 'Syntax Error GraphQL (1:1) Unexpected Name "syntaxerror"\n\n1: syntaxerror\n ^\n'
}
]
}


Expand Down Expand Up @@ -482,10 +485,9 @@ def test_passes_request_into_request_context(app):
def test_supports_pretty_printing(app):
_, response = app.client.get(uri=url_string(query='{context}'))


assert response.status == 200
assert 'data' in response_json(response)
assert response_json(response)['data']['context'] == "{'request': {}}"
assert response_json(response)['data']['context'] == "{'request': <Request: GET /graphql>}"


@parametrize_sync_async_app_test('app')
Expand Down