|
7 | 7 | from jinja2 import Environment
|
8 | 8 | from typing_extensions import TypedDict
|
9 | 9 |
|
10 |
| -GRAPHIQL_VERSION = "1.4.7" |
| 10 | +GRAPHIQL_VERSION = "2.2.0" |
11 | 11 |
|
12 | 12 | GRAPHIQL_TEMPLATE = """<!--
|
13 | 13 | The request to this GraphQL server provided the header "Accept: text/html"
|
|
34 | 34 | }
|
35 | 35 | </style>
|
36 | 36 | <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> |
41 | 41 | <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> |
44 | 43 | </head>
|
45 | 44 | <body>
|
46 | 45 | <div id="graphiql">Loading...</div>
|
|
75 | 74 | otherParams[k] = parameters[k];
|
76 | 75 | }
|
77 | 76 | }
|
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 |
| - } |
90 | 77 | 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}}' |
106 | 84 | });
|
| 85 | + } else { |
| 86 | + graphQLFetcher = GraphiQL.createFetcher({ url: fetchURL }); |
107 | 87 | }
|
108 | 88 | // When the query and variables string is edited, update the URL bar so
|
109 | 89 | // that it can be easily shared.
|
|
129 | 109 | // Render <GraphiQL /> into the body.
|
130 | 110 | ReactDOM.render(
|
131 | 111 | React.createElement(GraphiQL, {
|
132 |
| - fetcher: subscriptionsFetcher || graphQLFetcher, |
| 112 | + fetcher: graphQLFetcher, |
133 | 113 | onEditQuery: onEditQuery,
|
134 | 114 | onEditVariables: onEditVariables,
|
135 | 115 | onEditHeaders: onEditHeaders,
|
|
140 | 120 | headers: {{headers|tojson}},
|
141 | 121 | operationName: {{operation_name|tojson}},
|
142 | 122 | defaultQuery: {{default_query|tojson}},
|
143 |
| - headerEditorEnabled: {{header_editor_enabled|tojson}}, |
| 123 | + isHeadersEditorEnabled: {{header_editor_enabled|tojson}}, |
144 | 124 | shouldPersistHeaders: {{should_persist_headers|tojson}}
|
145 | 125 | }),
|
146 | 126 | document.getElementById('graphiql')
|
|
0 commit comments