mll-lab / laravel-graphiql Goto Github PK
View Code? Open in Web Editor NEWA thin wrapper for serving the GraphiQL UI from Laravel
License: MIT License
A thin wrapper for serving the GraphiQL UI from Laravel
License: MIT License
It seems that using this package we are not able to load different schemas in different endpoints, is that correct?
https://github.com/rebing/graphql-laravel/pull/986/files
Received 404 status on: https://unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js
Doing a fresh install this library with Lumen 10.0.0
Target [Illuminate\Contracts\Routing\UrlGenerator] is not instantiable while building [MLL\GraphiQL\GraphiQLController].
I am currently encountering an issue with the MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath
method. I'm receiving a BadMethodCallException
with the message stating "Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist."
Steps to reproduce the issue:
Environment:
Attempts to fix:
I attempted to clear the compiled class file and re-optimize the class loader by running artisan optimize
, but the issue persisted.
I got an error when trying to run GraphiQL.
Uncaught ReferenceError: GraphiQL is not defined
Investigando o código do repo me deparei com um erro no código do comando graphiql:download-assets
:
file_put_contents($publicPath, $cdnPath);
The correct code is:
file_put_contents($publicPath, $contents);
Can you please add the explorer plugin to this playground?
Hi there, I tried to install this but received an error about the UrlGenerator type in https://github.com/mll-lab/laravel-graphiql/blob/master/src/GraphiQLController.php
I'm on PHP 7.2.14, and typed properties aren't available until 7.4; however, the PHP version in composer.json for this project states that ^7.1 || ^8
, so I'm able to install it. Installing 1.2.2 works fine.
When loading GraphiQL I get the following error in console:
"GraphiQLPluginExplorer is not defined"
Checking the vendor files, in src/DownloadAssetsCommand.php exactly on line 23:
public const EXPLORER_PLUGIN_PATH_CDN = '//unpkg.com/@graphiql/plugin-explorer/dist/graphiql-plugin-explorer.umd.js';
leads to version 1.21 of plugin-explorer, which is down, To solve it, I replaced that line with:
public const EXPLORER_PLUGIN_PATH_CDN = '//unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js';
I used version 1.20 and it worked but it is not the definitive solution.
Can't access /graphiql
because:
Failed to load resource: the server responded with a status of 404 ()
https://unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js
is return 404.
ReferenceError: GraphiQLPluginExplorer is not defined
at GraphiQLWithExplorer (graphiql:70:17)
Probably has something to do with a new version v3.1
?
I am using Laravel Lighthouse. I just installed it today, and this package. Ever since installing I'm getting the error below:
{
"errors": [
{
"message": "Failed to fetch",
"stack": "TypeError: Failed to fetch\n at http://unpkg.com/graphiql/graphiql.min.js:65084:22\n at Generator.next (<anonymous>)\n at http://unpkg.com/graphiql/graphiql.min.js:65003:67\n at new Promise (<anonymous>)\n at __webpack_modules__.../../graphiql-toolkit/esm/create-fetcher/lib.js.__awaiter (http://unpkg.com/graphiql/graphiql.min.js:64985:10)\n at http://unpkg.com/graphiql/graphiql.min.js:65083:85\n at http://unpkg.com/graphiql/graphiql.min.js:64912:54\n at fetchIntrospectionData (http://unpkg.com/graphiql/graphiql.min.js:58264:40)\n at http://unpkg.com/graphiql/graphiql.min.js:58286:39\n at http://unpkg.com/graphiql/graphiql.min.js:58298:5"
}
]
}
Is this an issue or have I set something up improperly? I'm using Laravel 9 with PHP 8.
IGNORE
https://flareapp.io/share/KPgQLBq5
Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist.
Cannot access tool, attempted fresh install. Any idea how to proceed?
I've followed the instructions for CSRF, and the token is being sent correctly on each request.
The web
middleware is included in the graphiql config.
'middleware' => ['web'],
Decoding the XSRF-TOKEN cookie matches the token that is being sent.
The web middleware group consists of the following middleware:
[
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
]
Though I'm still getting a 419 error. CSRF is working correctly from the frontend.
Any ideas?
I received this msg: "Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist."
At DownloadAssetsCommand.php only exist "pluginExplorerPath"
I think it should be explorerPluginPath instead.
X-CSRF-TOKEN is set when GraphiQL is opened, but not when a new tab is opened.
If you reload the browser, a new tab will be created and X-CSRF-TOKEN will be set.
X-CSRF-TOKEN is set in Headers.
Add tab
is pressed.X-CSRF-TOKEN is not set.
A new tab is created, X-CSRF-TOKEN is set in Headers.
I don't want a new tab to be created when reloading the browser.
Please let me know if there is anything missing.
$ php artisan vendor:publish --tag=graphiql-view
Add to resources/views/vendor/graphiql/index.blade.php
head
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
Add to resources/views/vendor/graphiql/index.blade.php
script
<script>
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
url: '{{ url(config('graphiql.endpoint')) }}',
subscriptionUrl: '{{ config('graphiql.subscription-endpoint') }}',
}),
shouldPersistHeaders: true,
headers: JSON.stringify({
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
}),
}),
document.getElementById('graphiql'),
);
</script>
Add to config/graphiql.php
route.middleware
'route' => [
'uri' => '/graphiql',
'name' => 'graphiql',
'middleware' => ['web'],
// 'prefix' => '',
// 'domain' => 'graphql.' . env('APP_DOMAIN', 'localhost'),
],
$ php artisan optimize:clear
Is there any possibility to add some structure here? Or maybe it can be done somewhere else?
A screenshot shows a query and mutation, but it is harder to find enums in All Schema Types if a frontend dev is not sure what they need to find.
Of course if frontend and backend devs are working together and they always can make a deal that all of the enum types must have '_enum' or something in the name of enum, thus frontend dev could search it by this word ending, but what if frontend works alone and there is no backend dev to have a deal with?
Hi,
I'm trying to integrate and test subscriptions with GraphiQL but I'm really struggling. When attempting to execute a subscription I get -
{
"errors": [
{
"message": "Invalid message",
"stack": "Error: Invalid message\n at parseMessage (https://unpkg.com/graphiql/graphiql.min.js:20983:11)\n at socket.onmessage (https://unpkg.com/graphiql/graphiql.min.js:20657:52)"
}
]
}
When subscribing to a Pusher channel I get the following message back -
{"event":"pusher:connection_established","data":"{\"socket_id\":\"2814561052.459239379\",\"activity_timeout\":30}"}
This connection established response causes the error because it fails the isMessage
check in graphiql.min.js as once converted to n object, it checks if there a property called type
. Pusher doesn't have a type
property and as such fails.
Can it be possible to just ignore Pusher system messages?
Thanks,
Chris.
If there's something written in the query field and we reload the page, a new tab is openned.
That's completely unecessary and flood the GraphiQL page with untitled
tabs, is there any way to disable it? I just want one tab openned, if I need more I would like to do it myself.
Hi all 👋
I have a problem with the comand
php artisan vendor:publish --tag=graphiql-view
Once the command was run, the index.blade.php
file was successfully generated:
However any changes to the file are not applied. I also tried clearing the Laravel caches.
I need to change the Fetch call by adding an authentication parameter.
Do you have any ideas? 😢
is it possible to config "Persist headers" default to True through config file => graphiql.php
Hi, i followed sanctum instructions but it's not working for queries .
I added defaultHeaders to GraphiQLWithExplorer function. It gets the schema but it will throw CSRF error on queries.
To fix this problem i also added headers object to fetcher.
const fetcher = GraphiQL.createFetcher({
url: '{{ $url }}',
subscriptionUrl: '{{ $subscriptionUrl }}',
+ headers: {
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
+ },
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.