Skip to content

Commit 3e8685f

Browse files
committed
chore: update GraphiQL to 2.2.0
1 parent d6b4458 commit 3e8685f

File tree

1 file changed

+16
-36
lines changed

1 file changed

+16
-36
lines changed

graphql_server/render_graphiql.py

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from jinja2 import Environment
88
from typing_extensions import TypedDict
99

10-
GRAPHIQL_VERSION = "1.4.7"
10+
GRAPHIQL_VERSION = "2.2.0"
1111

1212
GRAPHIQL_TEMPLATE = """<!--
1313
The request to this GraphQL server provided the header "Accept: text/html"
@@ -34,13 +34,12 @@
3434
}
3535
</style>
3636
<link href="//cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.css" rel="stylesheet" />
37-
<script src="//cdn.jsdelivr.net/npm/[email protected].0/dist/polyfill.min.js"></script>
38-
<script src="//cdn.jsdelivr.net/npm/unfetch@4.2.0/dist/unfetch.umd.js"></script>
39-
<script src="//cdn.jsdelivr.net/npm/react@16.14.0/umd/react.production.min.js"></script>
40-
<script src="//cdn.jsdelivr.net/npm/react-dom@16.14.0/umd/react-dom.production.min.js"></script>
37+
<script src="//cdn.jsdelivr.net/npm/[email protected].3/dist/polyfill.min.js"></script>
38+
<script src="//cdn.jsdelivr.net/npm/unfetch@5.0.0/dist/unfetch.umd.js"></script>
39+
<script src="//cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js"></script>
40+
<script src="//cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js"></script>
4141
<script src="//cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.min.js"></script>
42-
<script src="//cdn.jsdelivr.net/npm/[email protected]/browser/client.js"></script>
43-
<script src="//cdn.jsdelivr.net/npm/[email protected]/browser/client.js"></script>
42+
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/graphql-ws.min.js"></script>
4443
</head>
4544
<body>
4645
<div id="graphiql">Loading...</div>
@@ -75,35 +74,16 @@
7574
otherParams[k] = parameters[k];
7675
}
7776
}
78-
// Configure the subscription client
79-
let subscriptionsFetcher = null;
80-
if ('{{subscription_url}}') {
81-
let subscriptionsClient = new SubscriptionsTransportWs.SubscriptionClient(
82-
'{{ subscription_url }}',
83-
{ reconnect: true }
84-
);
85-
subscriptionsFetcher = GraphiQLSubscriptionsFetcher.graphQLFetcher(
86-
subscriptionsClient,
87-
graphQLFetcher
88-
);
89-
}
9077
var fetchURL = locationQuery(otherParams);
91-
// Defines a GraphQL fetcher using the fetch API.
92-
function graphQLFetcher(graphQLParams, opts) {
93-
return fetch(fetchURL, {
94-
method: 'post',
95-
headers: Object.assign(
96-
{
97-
'Accept': 'application/json',
98-
'Content-Type': 'application/json'
99-
},
100-
opts && opts.headers,
101-
),
102-
body: JSON.stringify(graphQLParams),
103-
credentials: 'include',
104-
}).then(function (response) {
105-
return response.json();
78+
// Defines a GraphQL fetcher.
79+
var graphQLFetcher;
80+
if ('{{subscription_url}}') {
81+
graphQLFetcher = GraphiQL.createFetcher({
82+
url: fetchURL,
83+
subscription_url: '{{subscription_url}}'
10684
});
85+
} else {
86+
graphQLFetcher = GraphiQL.createFetcher({ url: fetchURL });
10787
}
10888
// When the query and variables string is edited, update the URL bar so
10989
// that it can be easily shared.
@@ -129,7 +109,7 @@
129109
// Render <GraphiQL /> into the body.
130110
ReactDOM.render(
131111
React.createElement(GraphiQL, {
132-
fetcher: subscriptionsFetcher || graphQLFetcher,
112+
fetcher: graphQLFetcher,
133113
onEditQuery: onEditQuery,
134114
onEditVariables: onEditVariables,
135115
onEditHeaders: onEditHeaders,
@@ -140,7 +120,7 @@
140120
headers: {{headers|tojson}},
141121
operationName: {{operation_name|tojson}},
142122
defaultQuery: {{default_query|tojson}},
143-
headerEditorEnabled: {{header_editor_enabled|tojson}},
123+
isHeadersEditorEnabled: {{header_editor_enabled|tojson}},
144124
shouldPersistHeaders: {{should_persist_headers|tojson}}
145125
}),
146126
document.getElementById('graphiql')

0 commit comments

Comments
 (0)