From 5bfe90298b3073f3782d4c374d9e66486ddd86b8 Mon Sep 17 00:00:00 2001 From: "Miguel Escribano (miguescri)" Date: Sat, 7 Nov 2020 14:39:48 +0100 Subject: [PATCH 1/5] Update GraphiQL template in GraphQLApp The GraphiQL editor bundled with Starlette is obsolete and doesn't support modern utilities. The HTML template for the editor has been updated with the example from GraphiQL's repo: https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html This example has been modified to enable the editor's functionality to manage the headers of the requests. --- starlette/graphql.py | 137 +++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 90 deletions(-) diff --git a/starlette/graphql.py b/starlette/graphql.py index e67be3f1b..6b46454f4 100644 --- a/starlette/graphql.py +++ b/starlette/graphql.py @@ -143,9 +143,11 @@ async def handle_graphiql(self, request: Request) -> Response: return HTMLResponse(text) +# GraphiQL example from https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html +# Modified to enable header edition using content from https://github.com/graphql/graphiql/issues/59#issuecomment-643688951 GRAPHIQL = """ - - - - - + + + + + +
Loading...
+ + -""" # noqa: E501 +""" + From 54a872bd01fb87214e044296dc96cb5bf9ac62a6 Mon Sep 17 00:00:00 2001 From: "Miguel Escribano (miguescri)" Date: Sat, 7 Nov 2020 14:50:39 +0100 Subject: [PATCH 2/5] Remove trailing newline --- starlette/graphql.py | 1 - 1 file changed, 1 deletion(-) diff --git a/starlette/graphql.py b/starlette/graphql.py index 6b46454f4..8718b53d3 100644 --- a/starlette/graphql.py +++ b/starlette/graphql.py @@ -232,4 +232,3 @@ async def handle_graphiql(self, request: Request) -> Response: """ - From 90160ffe2a6453b18c6df6c12c0be3ae6efb7802 Mon Sep 17 00:00:00 2001 From: "Miguel Escribano (miguescri)" Date: Sat, 7 Nov 2020 14:53:17 +0100 Subject: [PATCH 3/5] Add noqa: E501 --- starlette/graphql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starlette/graphql.py b/starlette/graphql.py index 8718b53d3..e4aba0671 100644 --- a/starlette/graphql.py +++ b/starlette/graphql.py @@ -231,4 +231,4 @@ async def handle_graphiql(self, request: Request) -> Response: -""" +""" # noqa: E501 From 52e9e2f8bb5ed519b9016eeb5f386a8ca45e6ba0 Mon Sep 17 00:00:00 2001 From: "Miguel Escribano (miguescri)" Date: Sat, 7 Nov 2020 14:56:48 +0100 Subject: [PATCH 4/5] Divide long comment in different lines --- starlette/graphql.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/starlette/graphql.py b/starlette/graphql.py index e4aba0671..f20441111 100644 --- a/starlette/graphql.py +++ b/starlette/graphql.py @@ -143,8 +143,13 @@ async def handle_graphiql(self, request: Request) -> Response: return HTMLResponse(text) -# GraphiQL example from https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html -# Modified to enable header edition using content from https://github.com/graphql/graphiql/issues/59#issuecomment-643688951 +''' +GraphiQL example from +https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html + +Modified to enable header edition using content from +https://github.com/graphql/graphiql/issues/59#issuecomment-643688951 +''' GRAPHIQL = """