From 5d54c554902f4850d5387ffb8f063ea32f211020 Mon Sep 17 00:00:00 2001 From: Fabian Diehm <59868556+fabiangfd@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:46:45 +0200 Subject: [PATCH 01/15] Added subscription_url parameter for graphiql-explorer --- ariadne/explorer/graphiql.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ariadne/explorer/graphiql.py b/ariadne/explorer/graphiql.py index 8d8915a6d..c177d0c0e 100644 --- a/ariadne/explorer/graphiql.py +++ b/ariadne/explorer/graphiql.py @@ -43,6 +43,7 @@ def __init__( title: str = "Ariadne GraphQL", explorer_plugin: bool = False, default_query: str = DEFAULT_QUERY, + subscription_url: str = "", ) -> None: self.parsed_html = render_template( GRAPHIQL_HTML, @@ -50,6 +51,7 @@ def __init__( "title": title, "enable_explorer_plugin": explorer_plugin, "default_query": escape_default_query(default_query), + "subscription_url": subscription_url, }, ) From 3a72a20b39c810a898a2079e3fc57e37fb9a4acc Mon Sep 17 00:00:00 2001 From: Fabian Diehm <59868556+fabiangfd@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:49:51 +0200 Subject: [PATCH 02/15] Extended graphiql template to use subscription_url parameter (if provided) and use default subscription url (if subscription_url is not provided) --- ariadne/explorer/templates/graphiql.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ariadne/explorer/templates/graphiql.html b/ariadne/explorer/templates/graphiql.html index b52fbdb41..2643d4ae8 100644 --- a/ariadne/explorer/templates/graphiql.html +++ b/ariadne/explorer/templates/graphiql.html @@ -70,6 +70,11 @@ \n \n\n \n\n \n\n \n \n\n' + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' ] snapshots['test_graphiql_html_is_served_on_get_request 1'] = [ - b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' ] snapshots['test_playground_html_is_served_on_get_request 1'] = [ From 7a0ee88227bd52e5cc35e6cbec01d8203dd767b0 Mon Sep 17 00:00:00 2001 From: Fabian Diehm <59868556+fabiangfd@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:48:43 +0200 Subject: [PATCH 04/15] Update ariadne/explorer/templates/graphiql.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rafał Pitoń --- ariadne/explorer/templates/graphiql.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ariadne/explorer/templates/graphiql.html b/ariadne/explorer/templates/graphiql.html index 2643d4ae8..62b59239a 100644 --- a/ariadne/explorer/templates/graphiql.html +++ b/ariadne/explorer/templates/graphiql.html @@ -73,7 +73,7 @@ {% if subscription_url %} subscriptionUrl: "{{ subscription_url }}", {% else %} - subscriptionUrl: (window.location.protocol=="https:"?"wss:":"ws:") + "//" + window.location.host + window.location.pathname, + subscriptionUrl: (window.location.protocol === "https:" ? "wss" : "ws") + "://" + window.location.host + window.location.pathname, {% endif %} }); From 10377003cfeddb6acf626fb8014da35e65200c57 Mon Sep 17 00:00:00 2001 From: Fabian Diehm <59868556+fabiangfd@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:54:17 +0200 Subject: [PATCH 05/15] Update snap_test_explorer.py --- tests/wsgi/snapshots/snap_test_explorer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wsgi/snapshots/snap_test_explorer.py b/tests/wsgi/snapshots/snap_test_explorer.py index 24c910a55..d2bddb13f 100644 --- a/tests/wsgi/snapshots/snap_test_explorer.py +++ b/tests/wsgi/snapshots/snap_test_explorer.py @@ -15,11 +15,11 @@ ] snapshots['test_default_explorer_html_is_served_on_get_request 1'] = [ - b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' ] snapshots['test_graphiql_html_is_served_on_get_request 1'] = [ - b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' ] snapshots['test_playground_html_is_served_on_get_request 1'] = [ From 94f65b5cbe55253c84af30166f5ccddf61fe88cd Mon Sep 17 00:00:00 2001 From: Fabian Diehm <59868556+fabiangfd@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:19:39 +0000 Subject: [PATCH 06/15] updated snapshots for new graphiql template --- tests/asgi/snapshots/snap_test_explorer.py | 6 ++++++ tests/explorers/snapshots/snap_test_explorers.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/asgi/snapshots/snap_test_explorer.py b/tests/asgi/snapshots/snap_test_explorer.py index 7d39910ce..742da3d6c 100644 --- a/tests/asgi/snapshots/snap_test_explorer.py +++ b/tests/asgi/snapshots/snap_test_explorer.py @@ -108,6 +108,9 @@ + + + + + + + + + +''' + snapshots['test_graphiql_explorer_produces_html 1'] = '''