-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Replace GraphQL Explorer with GraphiQL (#23423)
## Summary & Motivation In OSS, eliminate GraphQL Playground (which is EOL, unsupported, and broken) and replace it with GraphiQL. This approach uses the CDN-based static example provided in the GraphiQL repo ([link](https://github.com/graphql/graphiql/blob/main/examples/graphiql-cdn/index.html)) but replaces the CDN host with the local template string. The static assets are therefore checked in as part of this PR, to be served locally, just as graphql-playground's assets were. (It seems prudent not to depend on unpkg for this.) <img width="914" alt="Screenshot 2024-08-05 at 12 42 12" src="https://github.com/user-attachments/assets/3910b209-07c8-414e-95ef-4d09106d9261"> ## How I Tested These Changes Run `dagster dev -p 3333`, view GraphiQL at `http://localhost:3333/graphql`. Verify that the UI loads and renders correctly, and that I can successfully query the GraphQL backend.
- Loading branch information
Showing
15 changed files
with
93,697 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
include README.rst | ||
include LICENSE | ||
include dagster_webserver/py.typed | ||
recursive-include dagster_webserver/graphql-playground * | ||
recursive-include dagster_webserver/graphiql * | ||
recursive-include dagster_webserver/webapp/build * | ||
recursive-include dagster_webserver/templates/assets * |
1 change: 1 addition & 0 deletions
1
...n_modules/dagster-webserver/dagster_webserver/graphiql/graphiql-plugin-explorer-style.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
python_modules/dagster-webserver/dagster_webserver/graphiql/graphiql-plugin-explorer.umd.js
Large diffs are not rendered by default.
Oops, something went wrong.
2,646 changes: 2,646 additions & 0 deletions
2,646
python_modules/dagster-webserver/dagster_webserver/graphiql/graphiql.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
90,664 changes: 90,664 additions & 0 deletions
90,664
python_modules/dagster-webserver/dagster_webserver/graphiql/graphiql.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
267 changes: 267 additions & 0 deletions
267
python_modules/dagster-webserver/dagster_webserver/graphiql/react-dom.production.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
python_modules/dagster-webserver/dagster_webserver/graphiql/react.production.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file removed
BIN
-4.94 KB
python_modules/dagster-webserver/dagster_webserver/graphql-playground/favicon.png
Binary file not shown.
53 changes: 0 additions & 53 deletions
53
python_modules/dagster-webserver/dagster_webserver/graphql-playground/index.css
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
python_modules/dagster-webserver/dagster_webserver/graphql-playground/middleware.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
python_modules/dagster-webserver/dagster_webserver/templates/graphiql.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# TODO - figure out how to use files as templates | ||
|
||
TEMPLATE = """ | ||
<!-- | ||
* Copyright (c) 2021 GraphQL Contributors | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
--> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>GraphiQL</title> | ||
<style> | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
width: 100%; | ||
overflow: hidden; | ||
} | ||
#graphiql { | ||
height: 100vh; | ||
} | ||
</style> | ||
<!-- | ||
This GraphiQL example depends on Promise and fetch, which are available in | ||
modern browsers, but can be "polyfilled" for older browsers. | ||
GraphiQL itself depends on React DOM. | ||
If you do not want to rely on a CDN, you can host these files locally or | ||
include them directly in your favored resource bundler. | ||
--> | ||
<script | ||
src="{{ app_path_prefix }}/vendor/graphiql/react.production.min.js" | ||
></script> | ||
<script | ||
src="{{ app_path_prefix }}/vendor/graphiql/react-dom.production.min.js" | ||
></script> | ||
<!-- | ||
These two files can be found in the npm module, however you may wish to | ||
copy them directly into your environment, or perhaps include them in your | ||
favored resource bundler. | ||
--> | ||
<script | ||
src="{{ app_path_prefix }}/vendor/graphiql/graphiql.min.js" | ||
type="application/javascript" | ||
></script> | ||
<link rel="stylesheet" href="{{ app_path_prefix }}/vendor/graphiql/graphiql.min.css" /> | ||
<!-- | ||
These are imports for the GraphIQL Explorer plugin. | ||
--> | ||
<script | ||
src="{{ app_path_prefix }}/vendor/graphiql/graphiql-plugin-explorer.umd.js" | ||
></script> | ||
<link | ||
rel="stylesheet" | ||
href="{{ app_path_prefix }}/vendor/graphiql/graphiql-plugin-explorer-style.css" | ||
/> | ||
</head> | ||
<body> | ||
<div id="graphiql">Loading...</div> | ||
<script> | ||
const root = ReactDOM.createRoot(document.getElementById('graphiql')); | ||
const hostAndPath = `${document.location.host}${document.location.pathname}`; | ||
const fetcher = GraphiQL.createFetcher({ | ||
url: `${document.location.protocol}//${hostAndPath}`, | ||
subscriptionUrl: `ws://${hostAndPath}`, | ||
headers: { | ||
'credentials': 'same-origin' | ||
}, | ||
}); | ||
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin(); | ||
root.render( | ||
React.createElement(GraphiQL, { | ||
fetcher, | ||
defaultEditorToolsVisibility: true, | ||
plugins: [explorerPlugin], | ||
}), | ||
); | ||
</script> | ||
</body> | ||
</html>""" |
Oops, something went wrong.