Skip to content

Commit 42a7ea4

Browse files
Update laravel-graphiql to 4.0.1 (#2876)
The library we use to provide GraphiQL [recently broke](mll-lab/laravel-graphiql#53) due to an unpinned upstream dependency. This PR fixes the issue by updating `laravel-graphiql` to the newest version which pins dependencies appropriately. I also enabled asset downloading to prevent this issue from occurring in the future if the CDN ever goes down again.
1 parent 4081f52 commit 42a7ea4

File tree

5 files changed

+39
-58
lines changed

5 files changed

+39
-58
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ vendor/*
22
_build/*
33
cypress_cache/*
44
public/assets/*
5+
public/vendor/*
56
resources/js/angular/ui.tabs.js
67
resources/js/angular/tabNavigation.js
78
resources/js/angular/services/renderTimer.js

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"laravel/ui": "4.6.1",
3434
"lcobucci/jwt": "5.5.0",
3535
"league/flysystem-aws-s3-v3": "^3.29",
36-
"mll-lab/laravel-graphiql": "3.3.2",
36+
"mll-lab/laravel-graphiql": "4.0.1",
3737
"nuwave/lighthouse": "6.54.0",
3838
"pear/archive_tar": "1.5.0",
3939
"php-di/php-di": "7.0.10",

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ else
6363
fi
6464
fi
6565

66+
echo "Downloading GraphiQL assets..."
67+
php artisan graphiql:download-assets
68+
6669
echo "Waiting for database to come online..."
6770
until php artisan db:monitor ; do sleep 1; done
6871

resources/views/vendor/graphiql/index.blade.php

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,58 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
@php use MLL\GraphiQL\DownloadAssetsCommand; @endphp
3+
@php use MLL\GraphiQL\GraphiQLAsset; @endphp
44
<head>
5-
<meta charset=utf-8/>
6-
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta name="csrf-token" content="{{ csrf_token() }}">
88
<title>GraphiQL</title>
99
<style>
1010
body {
11-
height: 100%;
1211
margin: 0;
13-
width: 100%;
14-
overflow: hidden;
12+
overflow: hidden; /* in Firefox */
1513
}
1614
1715
#graphiql {
18-
height: 100vh;
19-
}
20-
21-
/* Make the explorer feel more integrated */
22-
.docExplorerWrap {
23-
overflow: auto !important;
24-
width: 100% !important;
25-
height: auto !important;
26-
}
27-
28-
.doc-explorer-title-bar {
29-
font-weight: var(--font-weight-medium);
30-
font-size: var(--font-size-h2);
31-
overflow-x: hidden;
32-
text-overflow: ellipsis;
33-
white-space: nowrap;
34-
}
35-
36-
.doc-explorer-rhs {
37-
display: none;
38-
}
39-
40-
.doc-explorer-contents {
41-
margin: var(--px-16) 0 0;
16+
height: 100dvh;
4217
}
4318
44-
.graphiql-explorer-actions select {
45-
margin-left: var(--px-12);
19+
#graphiql-loading {
20+
height: 100%;
21+
display: flex;
22+
align-items: center;
23+
justify-content: center;
24+
font-size: 4rem;
4625
}
4726
</style>
48-
<script src="{{ DownloadAssetsCommand::reactPath() }}"></script>
49-
<script src="{{ DownloadAssetsCommand::reactDOMPath() }}"></script>
50-
<link rel="stylesheet" href="{{ DownloadAssetsCommand::cssPath() }}"/>
51-
<link rel="shortcut icon" href="{{ DownloadAssetsCommand::faviconPath() }}"/>
27+
<script src="{{ GraphiQLAsset::reactJS() }}"></script>
28+
<script src="{{ GraphiQLAsset::reactDOMJS() }}"></script>
29+
<link rel="stylesheet" href="{{ GraphiQLAsset::graphiQLCSS() }}"/>
30+
<link rel="stylesheet" href="{{ GraphiQLAsset::pluginExplorerCSS() }}"/>
31+
<link rel="shortcut icon" href="{{ GraphiQLAsset::favicon() }}"/>
5232
</head>
5333

5434
<body>
5535

56-
<div id="graphiql">Loading...</div>
57-
<script src="{{ DownloadAssetsCommand::jsPath() }}"></script>
58-
<script src="{{ DownloadAssetsCommand::pluginExplorerPath() }}"></script>
36+
<div id="graphiql">
37+
<div id="graphiql-loading">Loading…</div>
38+
</div>
39+
40+
<script src="{{ GraphiQLAsset::graphiQLJS() }}"></script>
41+
<script src="{{ GraphiQLAsset::pluginExplorerJS() }}"></script>
5942
<script>
6043
const fetcher = GraphiQL.createFetcher({
6144
url: '{{ $url }}',
6245
subscriptionUrl: '{{ $subscriptionUrl }}',
6346
});
47+
const explorer = GraphiQLPluginExplorer.explorerPlugin();
6448
6549
function GraphiQLWithExplorer() {
66-
const [query, setQuery] = React.useState('');
67-
6850
return React.createElement(GraphiQL, {
6951
fetcher,
70-
query,
71-
onEditQuery: setQuery,
72-
defaultEditorToolsVisibility: true,
7352
plugins: [
74-
GraphiQLPluginExplorer.useExplorerPlugin({
75-
query,
76-
onEdit: setQuery,
77-
}),
53+
explorer,
7854
],
55+
// See https://github.com/graphql/graphiql/tree/main/packages/graphiql#props for available settings
7956
});
8057
}
8158

0 commit comments

Comments
 (0)