strawberry-graphql 0.288.3__py3-none-any.whl → 0.288.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,7 +114,38 @@
114
114
  #
115
115
  `;
116
116
 
117
- const fetchURL = window.location.href;
117
+ // Parse URL parameters for sharing queries
118
+ const parameters = {};
119
+
120
+ for (const entry of window.location.search.slice(1).split("&")) {
121
+ const eq = entry.indexOf("=");
122
+ if (eq >= 0) {
123
+ parameters[decodeURIComponent(entry.slice(0, eq))] =
124
+ decodeURIComponent(entry.slice(eq + 1));
125
+ }
126
+ }
127
+
128
+ function updateURL(data) {
129
+ Object.assign(parameters, data);
130
+
131
+ const newSearch =
132
+ "?" +
133
+ Object.keys(parameters)
134
+ .filter(function (key) {
135
+ return Boolean(parameters[key]);
136
+ })
137
+ .map(function (key) {
138
+ return (
139
+ encodeURIComponent(key) +
140
+ "=" +
141
+ encodeURIComponent(parameters[key])
142
+ );
143
+ })
144
+ .join("&");
145
+ history.replaceState(null, null, newSearch);
146
+ }
147
+
148
+ const fetchURL = window.location.href.split("?")[0];
118
149
 
119
150
  function httpUrlToWebSockeUrl(url) {
120
151
  const parsedURL = new URL(url);
@@ -124,33 +155,65 @@
124
155
  return parsedURL.toString();
125
156
  }
126
157
 
127
- const headers = {};
158
+ const defaultHeaders = {};
128
159
  const csrfToken = Cookies.get("csrftoken");
129
160
 
130
161
  if (csrfToken) {
131
- headers["x-csrftoken"] = csrfToken;
162
+ defaultHeaders["x-csrftoken"] = csrfToken;
132
163
  }
133
164
 
134
165
  const subscriptionUrl = httpUrlToWebSockeUrl(fetchURL);
135
166
 
136
167
  const fetcher = GraphiQL.createFetcher({
137
168
  url: fetchURL,
138
- headers: headers,
169
+ headers: defaultHeaders,
139
170
  subscriptionUrl,
140
171
  });
141
172
 
142
- const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
143
-
144
- const root = ReactDOM.createRoot(document.getElementById("graphiql"));
145
-
146
- root.render(
147
- React.createElement(GraphiQL, {
173
+ function GraphiQLWithExplorer() {
174
+ const [query, setQuery] = React.useState(
175
+ parameters.q || EXAMPLE_QUERY,
176
+ );
177
+ const [variables, setVariables] = React.useState(
178
+ parameters.variables,
179
+ );
180
+ const [headers, setHeaders] = React.useState(parameters.headers);
181
+
182
+ function onEditQuery(newQuery) {
183
+ setQuery(newQuery);
184
+ updateURL({ q: newQuery });
185
+ }
186
+
187
+ function onEditVariables(newVariables) {
188
+ setVariables(newVariables);
189
+ updateURL({ variables: newVariables });
190
+ }
191
+
192
+ function onEditHeaders(newHeaders) {
193
+ setHeaders(newHeaders);
194
+ updateURL({ headers: newHeaders });
195
+ }
196
+
197
+ const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
198
+
199
+ return React.createElement(GraphiQL, {
148
200
  fetcher: fetcher,
149
201
  defaultEditorToolsVisibility: true,
150
202
  plugins: [explorerPlugin],
203
+ query: query,
204
+ variables: variables,
205
+ headers: headers,
206
+ onEditQuery: onEditQuery,
207
+ onEditVariables: onEditVariables,
208
+ onEditHeaders: onEditHeaders,
151
209
  inputValueDeprecation: true,
152
- }),
153
- );
210
+ isHeadersEditorEnabled: true,
211
+ shouldPersistHeaders: true,
212
+ });
213
+ }
214
+
215
+ const root = ReactDOM.createRoot(document.getElementById("graphiql"));
216
+ root.render(React.createElement(GraphiQLWithExplorer));
154
217
  </script>
155
218
  </body>
156
219
  </html>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: strawberry-graphql
3
- Version: 0.288.3
3
+ Version: 0.288.4
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -31,9 +31,9 @@ Provides-Extra: quart
31
31
  Provides-Extra: sanic
32
32
  Requires-Dist: Django (>=3.2) ; extra == "django"
33
33
  Requires-Dist: aiohttp (>=3.7.4.post0,<4) ; extra == "aiohttp"
34
- Requires-Dist: asgiref (>=3.2,<4.0) ; extra == "channels"
35
- Requires-Dist: asgiref (>=3.2,<4.0) ; extra == "django"
36
- Requires-Dist: chalice (>=1.22,<2.0) ; extra == "chalice"
34
+ Requires-Dist: asgiref (>=3.2) ; extra == "channels"
35
+ Requires-Dist: asgiref (>=3.2) ; extra == "django"
36
+ Requires-Dist: chalice (>=1.22) ; extra == "chalice"
37
37
  Requires-Dist: channels (>=3.0.5) ; extra == "channels"
38
38
  Requires-Dist: cross-web (>=0.4.0)
39
39
  Requires-Dist: fastapi (>=0.65.2) ; extra == "fastapi"
@@ -47,8 +47,8 @@ Requires-Dist: opentelemetry-api (<2) ; extra == "opentelemetry"
47
47
  Requires-Dist: opentelemetry-sdk (<2) ; extra == "opentelemetry"
48
48
  Requires-Dist: packaging (>=23)
49
49
  Requires-Dist: pydantic (>1.6.1) ; extra == "pydantic"
50
+ Requires-Dist: pygments (>=2.3) ; extra == "cli"
50
51
  Requires-Dist: pygments (>=2.3) ; extra == "debug-server"
51
- Requires-Dist: pygments (>=2.3,<3.0) ; extra == "cli"
52
52
  Requires-Dist: pyinstrument (>=4.0.0) ; extra == "pyinstrument"
53
53
  Requires-Dist: python-dateutil (>=2.7)
54
54
  Requires-Dist: python-multipart (>=0.0.7) ; extra == "asgi"
@@ -189,7 +189,7 @@ strawberry/schema_codegen/__init__.py,sha256=HzgwI-rudoloXqJa5R9zyxXNTKLhdSXgSn7
189
189
  strawberry/schema_directive.py,sha256=H5tv1npCkEa-mUkzQ9nilNI3zTGEAhyagRcDwj5Rujw,2025
190
190
  strawberry/schema_directives.py,sha256=KGKFWCODjm1Ah9qNV_bBwbic7Mld4qLWnWQkev-PG8A,175
191
191
  strawberry/static/apollo-sandbox.html,sha256=2XzkbE0dqsFHqehE-jul9_J9TFOpwA6Ylrlo0Kdx_9w,973
192
- strawberry/static/graphiql.html,sha256=0e3pvTnAet-lNEqA_pgJ8Ak2CdMt34zPKMMMzpAkEVU,4257
192
+ strawberry/static/graphiql.html,sha256=czHhXGdLguz8k59237XKvWFIaMuUw91oe91nZ8fy6CI,6237
193
193
  strawberry/static/pathfinder.html,sha256=0DPx9AmJ2C_sJstFXnWOz9k5tVQHeHaK7qdVY4lAlmk,1547
194
194
  strawberry/streamable.py,sha256=8dqvKAv_Nhp8vEi4PUYyziCt3SUyCr6ZuqCNZ46Mqno,611
195
195
  strawberry/subscriptions/__init__.py,sha256=1VGmiCzFepqRFyCikagkUoHHdoTG3XYlFu9GafoQMws,170
@@ -238,8 +238,8 @@ strawberry/utils/logging.py,sha256=Dnivjd0ZhK_lAvjvuyCDkEWDhuURBoK9d3Kt_mIqbRg,7
238
238
  strawberry/utils/operation.py,sha256=Qs3ttbuC415xEVqmJ6YsWQpJNUo8CZJq9AoMB-yV65w,1215
239
239
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
240
240
  strawberry/utils/typing.py,sha256=eE9NeMfASeXRstbjLnQFfOPymcSX8xwg3FGw_HCp95E,11828
241
- strawberry_graphql-0.288.3.dist-info/METADATA,sha256=3J3c_1M5jyi-DmVmNV0QVPWpgWG3OueKWrfp37AEhbM,7647
242
- strawberry_graphql-0.288.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
243
- strawberry_graphql-0.288.3.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
244
- strawberry_graphql-0.288.3.dist-info/licenses/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
- strawberry_graphql-0.288.3.dist-info/RECORD,,
241
+ strawberry_graphql-0.288.4.dist-info/METADATA,sha256=LiS09hr9ulZqpMfHbqvHv4rVtV7Ej_WIgApx4CQU-C0,7627
242
+ strawberry_graphql-0.288.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
243
+ strawberry_graphql-0.288.4.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
244
+ strawberry_graphql-0.288.4.dist-info/licenses/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
245
+ strawberry_graphql-0.288.4.dist-info/RECORD,,