Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Upgrade GraphiQL to 1.11.4 #273

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions lib/absinthe/plug/graphiql/assets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
remote_source: "https://cdn.jsdelivr.net/npm/:package@:version/:file"
]

@react_version "15.6.1"
@react_version "16.13.1"

@assets [
{"whatwg-fetch", "2.0.3",
Expand All @@ -20,9 +20,17 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
]},
{"react", @react_version,
[
{"dist/react.min.js", "react.js"}
{"umd/react.production.min.js", "react.js"}
]},
{"react-dom", @react_version,
[
{"umd/react-dom.production.min.js", "react-dom.js"}
]},
{"react15", "15.4.2",
[
{"dist/react.min.js", "react.js"}
]},
{"react15-dom", "15.4.2",
[
{"dist/react-dom.min.js", "react-dom.js"}
]},
Expand All @@ -35,7 +43,7 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
{"dist/fonts/glyphicons-halflings-regular.svg", "fonts/glyphicons-halflings-regular.svg"},
{"dist/css/bootstrap.min.css", "css/bootstrap.css"}
]},
{"graphiql", "0.11.10",
{"graphiql", "1.11.4",
[
"graphiql.css",
{"graphiql.min.js", "graphiql.js"}
Expand Down Expand Up @@ -132,6 +140,14 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
build_asset_path(:remote_source, asset)
end

defp build_asset_path(:remote_source, {package, version, {real_path, aliased_path}}) do
assets_config()[:remote_source]
|> String.replace(":package", get_package_name(package))
|> String.replace(":version", version)
|> String.replace(":file", real_path)
|> String.replace(":alias", aliased_path)
end

defp build_asset_path(source, {package, version, {real_path, aliased_path}}) do
assets_config()[source]
|> String.replace(":package", package)
Expand All @@ -143,4 +159,10 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
defp build_asset_path(source, {package, version, path}) do
build_asset_path(source, {package, version, {path, path}})
end

def get_package_name(name) do
if Enum.member?(["react15", "react15-dom", "graphiql-beta"], name),
do: String.replace(name, "15", "") |> String.replace("-beta", ""),
else: name
end
end
4 changes: 2 additions & 2 deletions lib/absinthe/plug/graphiql/graphiql_workspace.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ add "&raw" to the end of the URL within a browser.
</head>
<body>
<div id="root" class="graphiql-workspace"></div>
<script src="<%= assets["react/react.js"] %>"></script>
<script src="<%= assets["react-dom/react-dom.js"] %>"></script>
<script src="<%= assets["react15/react.js"] %>"></script>
<script src="<%= assets["react15-dom/react-dom.js"] %>"></script>
<script src="<%= assets["graphiql-workspace/graphiql-workspace.js"] %>"></script>
<script src="<%= assets["@absinthe/socket-graphiql/socket-graphiql.js"] %>"></script>
<script type="text/javascript">
Expand Down