Skip to content

Commit

Permalink
Pin working version 0.1.20 of @graphiql/plugin-explorer
Browse files Browse the repository at this point in the history
Resolves #25
  • Loading branch information
spawnia committed Jun 26, 2023
1 parent 16f19ce commit 8e4a6d6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-graphiql/releases).

## Unreleased

## v3.0.2

### Fixed

- Pin working version `0.1.20` of `@graphiql/plugin-explorer`

## v3.0.1

### Fixed
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ parameters:
paths:
- src
- views
- .php-cs-fixer.php
checkOctaneCompatibility: true
11 changes: 6 additions & 5 deletions src/DownloadAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class DownloadAssetsCommand extends Command
public const JS_PATH_LOCAL = 'vendor/graphiql/graphiql.min.js';
public const JS_PATH_CDN = '//unpkg.com/graphiql/graphiql.min.js';

public const EXPLORER_PLUGIN_PATH_LOCAL = 'vendor/graphiql/graphiql-plugin-explorer.umd.js';
public const EXPLORER_PLUGIN_PATH_CDN = '//unpkg.com/@graphiql/plugin-explorer/dist/graphiql-plugin-explorer.umd.js';
public const PLUGIN_EXPLORER_PATH_LOCAL = 'vendor/graphiql/graphiql-plugin-explorer.umd.js';
/** Pinned because the latest version broke, see https://github.com/mll-lab/laravel-graphiql/issues/25. */
public const PLUGIN_EXPLORER_PATH_CDN = '//unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js';

public const CSS_PATH_LOCAL = 'vendor/graphiql/graphiql.min.css';
public const CSS_PATH_CDN = '//unpkg.com/graphiql/graphiql.min.css';
Expand All @@ -38,7 +39,7 @@ public function handle(): void
$this->downloadFileFromCDN(self::REACT_DOM_PATH_LOCAL, self::REACT_DOM_PATH_CDN);
$this->downloadFileFromCDN(self::CSS_PATH_LOCAL, self::CSS_PATH_CDN);
$this->downloadFileFromCDN(self::JS_PATH_LOCAL, self::JS_PATH_CDN);
$this->downloadFileFromCDN(self::EXPLORER_PLUGIN_PATH_LOCAL, self::EXPLORER_PLUGIN_PATH_CDN);
$this->downloadFileFromCDN(self::PLUGIN_EXPLORER_PATH_LOCAL, self::PLUGIN_EXPLORER_PATH_CDN);
$this->downloadFileFromCDN(self::FAVICON_PATH_LOCAL, self::FAVICON_PATH_CDN);
}

Expand Down Expand Up @@ -76,9 +77,9 @@ public static function jsPath(): string
return self::assetPath(self::JS_PATH_LOCAL, self::JS_PATH_CDN);
}

public static function explorerPluginPath(): string
public static function pluginExplorerPath(): string
{
return self::assetPath(self::EXPLORER_PLUGIN_PATH_LOCAL, self::EXPLORER_PLUGIN_PATH_CDN);
return self::assetPath(self::PLUGIN_EXPLORER_PATH_LOCAL, self::PLUGIN_EXPLORER_PATH_CDN);
}

public static function cssPath(): string
Expand Down
26 changes: 15 additions & 11 deletions views/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">

@php use MLL\GraphiQL\DownloadAssetsCommand; @endphp
<head>
<meta charset=utf-8/>
<meta name="viewport"
Expand All @@ -24,34 +24,38 @@
width: 100% !important;
height: auto !important;
}
.doc-explorer-title-bar {
font-weight: var(--font-weight-medium);
font-size: var(--font-size-h2);
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.doc-explorer-rhs {
display: none;
}
.doc-explorer-contents {
margin: var(--px-16) 0 0;
}
.graphiql-explorer-actions select {
margin-left: var(--px-12);
}
</style>
<script src="{{ \MLL\GraphiQL\DownloadAssetsCommand::reactPath() }}"></script>
<script src="{{ \MLL\GraphiQL\DownloadAssetsCommand::reactDOMPath() }}"></script>
<link rel="stylesheet" href="{{ \MLL\GraphiQL\DownloadAssetsCommand::cssPath() }}"/>
<link rel="shortcut icon" href="{{ \MLL\GraphiQL\DownloadAssetsCommand::faviconPath() }}"/>
<script src="{{ DownloadAssetsCommand::reactPath() }}"></script>
<script src="{{ DownloadAssetsCommand::reactDOMPath() }}"></script>
<link rel="stylesheet" href="{{ DownloadAssetsCommand::cssPath() }}"/>
<link rel="shortcut icon" href="{{ DownloadAssetsCommand::faviconPath() }}"/>
</head>

<body>

<div id="graphiql">Loading...</div>
<script src="{{ \MLL\GraphiQL\DownloadAssetsCommand::jsPath() }}"></script>
<script src="{{ \MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath() }}"></script>
<script src="{{ DownloadAssetsCommand::jsPath() }}"></script>
<script src="{{ DownloadAssetsCommand::pluginExplorerPath() }}"></script>
<script>
const fetcher = GraphiQL.createFetcher({
url: '{{ $url }}',
Expand All @@ -62,15 +66,15 @@ function GraphiQLWithExplorer() {
const [query, setQuery] = React.useState('');
return React.createElement(GraphiQL, {
fetcher: fetcher,
query: query,
fetcher,
query,
onEditQuery: setQuery,
defaultEditorToolsVisibility: true,
plugins: [
GraphiQLPluginExplorer.useExplorerPlugin({
query: query,
query,
onEdit: setQuery,
})
}),
],
});
}
Expand Down

0 comments on commit 8e4a6d6

Please sign in to comment.