From 75cb664a8684aa1e9201d0410451fe3b36751861 Mon Sep 17 00:00:00 2001 From: x0y Date: Sun, 30 Jun 2019 15:53:55 +0200 Subject: [PATCH 1/6] [upd] changes made to support the new librery graphql-core-next --- aiohttp_graphql/graphqlview.py | 15 ++++----------- setup.py | 6 ++++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/aiohttp_graphql/graphqlview.py b/aiohttp_graphql/graphqlview.py index 362d87e..723c4fa 100644 --- a/aiohttp_graphql/graphqlview.py +++ b/aiohttp_graphql/graphqlview.py @@ -5,10 +5,9 @@ from promise import Promise from graphql.type.schema import GraphQLSchema -from graphql.execution.executors.asyncio import AsyncioExecutor +from graphql import format_error as default_format_error from graphql_server import ( HttpQueryError, - default_format_error, encode_execution_results, json_encode, load_json_body, @@ -22,7 +21,6 @@ class GraphQLView: # pylint: disable = too-many-instance-attributes def __init__( self, schema=None, - executor=None, root_value=None, context=None, pretty=False, @@ -35,13 +33,12 @@ def __init__( max_age=86400, encoder=None, error_formatter=None, - enable_async=True, + field_resolver=None, ): # pylint: disable=too-many-arguments # pylint: disable=too-many-locals self.schema = schema - self.executor = executor self.root_value = root_value self.context = context self.pretty = pretty @@ -54,10 +51,7 @@ def __init__( self.max_age = max_age self.encoder = encoder or json_encode self.error_formatter = error_formatter or default_format_error - self.enable_async = enable_async and isinstance( - self.executor, - AsyncioExecutor, - ) + self.field_resolver = field_resolver assert isinstance(self.schema, GraphQLSchema), \ 'A Schema is required to be provided to GraphQLView.' @@ -136,11 +130,10 @@ async def __call__(self, request): batch_enabled=self.batch, catch=is_graphiql, # Execute options - return_promise=self.enable_async, root_value=self.root_value, context_value=self.get_context(request), middleware=self.middleware, - executor=self.executor, + field_resolver=self.field_resolver, ) awaited_execution_results = await Promise.all(execution_results) diff --git a/setup.py b/setup.py index a5aa8cc..c0de7b9 100644 --- a/setup.py +++ b/setup.py @@ -21,11 +21,13 @@ keywords='api graphql protocol aiohttp', packages=find_packages(exclude=['tests']), install_requires=[ - 'graphql-core>=2.0.dev,<3', - 'graphql-server-core>=1.0.dev,<2', + 'graphql-core-next', 'aiohttp>=2.0.0', 'pytest-runner', ], + dependency_links=[ + 'https://github.com/x0y-gt/graphql-server-core/tree/master#egg=graphql-server-core-1.1' + ], extras_require={ 'test': [ 'pylint>=1.7.2', From e3814cc00ed1e4f5e5d3c2f1cd6ae73d58a9fba6 Mon Sep 17 00:00:00 2001 From: x0y Date: Sun, 30 Jun 2019 16:53:19 +0200 Subject: [PATCH 2/6] [upd] link dependency fixed --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c0de7b9..b28c6ba 100644 --- a/setup.py +++ b/setup.py @@ -22,11 +22,12 @@ packages=find_packages(exclude=['tests']), install_requires=[ 'graphql-core-next', - 'aiohttp>=2.0.0', + 'aiohttp>=4.0.0a', 'pytest-runner', + 'graphql-server-core', ], dependency_links=[ - 'https://github.com/x0y-gt/graphql-server-core/tree/master#egg=graphql-server-core-1.1' + 'git+https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1' ], extras_require={ 'test': [ From 91ad61c1c837c7bf02eaba203dd98834e5e2cf78 Mon Sep 17 00:00:00 2001 From: x0y Date: Sat, 24 Aug 2019 11:49:00 -0600 Subject: [PATCH 3/6] upd] dependecies changed --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b28c6ba..5252f4f 100644 --- a/setup.py +++ b/setup.py @@ -24,10 +24,9 @@ 'graphql-core-next', 'aiohttp>=4.0.0a', 'pytest-runner', - 'graphql-server-core', - ], - dependency_links=[ - 'git+https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1' + 'graphql-server-core==1.1 @ git+https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1', + 'promise', + 'asyncio', ], extras_require={ 'test': [ From 0d8db15c363aa34b066445309e6d9d8bd31cae50 Mon Sep 17 00:00:00 2001 From: x0y Date: Sat, 24 Aug 2019 11:58:37 -0600 Subject: [PATCH 4/6] [upd] dependecies lnk fixed --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5252f4f..2f979cc 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ 'graphql-core-next', 'aiohttp>=4.0.0a', 'pytest-runner', - 'graphql-server-core==1.1 @ git+https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1', + 'graphql-server-core@https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1', 'promise', 'asyncio', ], From f364afe1fc0162d101719db0e76d63b5e132937b Mon Sep 17 00:00:00 2001 From: x0y Date: Sat, 24 Aug 2019 12:06:02 -0600 Subject: [PATCH 5/6] [fix] fix#2 to link dependencies --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2f979cc..c56ff7f 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ 'graphql-core-next', 'aiohttp>=4.0.0a', 'pytest-runner', - 'graphql-server-core@https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1', + 'graphql-server-core@git+https://github.com/x0y-gt/graphql-server-core#egg=graphql-server-core-1.1', 'promise', 'asyncio', ], From b3255ee9ca784c946d41d9c85058c49c9475f25c Mon Sep 17 00:00:00 2001 From: x0y Date: Wed, 12 Feb 2020 17:29:08 +0100 Subject: [PATCH 6/6] [upd] attach returns the route --- aiohttp_graphql/graphqlview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp_graphql/graphqlview.py b/aiohttp_graphql/graphqlview.py index 14456a4..c20dbe0 100644 --- a/aiohttp_graphql/graphqlview.py +++ b/aiohttp_graphql/graphqlview.py @@ -188,7 +188,7 @@ def process_preflight(self, request): @classmethod def attach(cls, app, *, route_path="/graphql", route_name="graphql", **kwargs): view = cls(**kwargs) - app.router.add_route("*", route_path, _asyncify(view), name=route_name) + return app.router.add_route("*", route_path, _asyncify(view), name=route_name) def _asyncify(handler):