From 0db1aab9e551846e635f881899b70d5b1445aed2 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 30 Oct 2024 12:46:00 -0400 Subject: [PATCH] Fixes #17895: Ensure GraphiQL UI resources are served locally --- netbox/netbox/graphql/views.py | 1 - netbox/templates/{ => graphql}/graphiql.html | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) rename netbox/templates/{ => graphql}/graphiql.html (87%) diff --git a/netbox/netbox/graphql/views.py b/netbox/netbox/graphql/views.py index 85a01f02501..46a073c9336 100644 --- a/netbox/netbox/graphql/views.py +++ b/netbox/netbox/graphql/views.py @@ -14,7 +14,6 @@ class NetBoxGraphQLView(GraphQLView): """ Extends strawberry's GraphQLView to support DRF's token-based authentication. """ - graphiql_template = 'graphiql.html' @csrf_exempt def dispatch(self, request, *args, **kwargs): diff --git a/netbox/templates/graphiql.html b/netbox/templates/graphql/graphiql.html similarity index 87% rename from netbox/templates/graphiql.html rename to netbox/templates/graphql/graphiql.html index 0281012dc2f..f50648f1fce 100644 --- a/netbox/templates/graphiql.html +++ b/netbox/templates/graphql/graphiql.html @@ -1,15 +1,8 @@ +{% load static %} {% comment %} This template derives from the strawberry-graphql project: https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/static/graphiql.html {% endcomment %} - -{% load static %} @@ -112,10 +105,7 @@ headers["x-csrftoken"] = csrfToken; } - const subscriptionsEnabled = JSON.parse("{{ SUBSCRIPTION_ENABLED }}"); - const subscriptionUrl = subscriptionsEnabled - ? httpUrlToWebSockeUrl(fetchURL) - : null; + const subscriptionUrl = httpUrlToWebSockeUrl(fetchURL); const fetcher = GraphiQL.createFetcher({ url: fetchURL,