mll-lab / laravel-graphql-playground Goto Github PK
View Code? Open in Web Editor NEWThis project is deprecated in favor of https://github.com/mll-lab/laravel-graphiql.
License: MIT License
This project is deprecated in favor of https://github.com/mll-lab/laravel-graphiql.
License: MIT License
I wanted to publish the configuration for nuwave/lighthouse
. I had no intention to publish your configuration. But as I had to select the option, it published your configuration too. So, I'd think that it'd be great to publish your content under a different tag. Maybe gql.playground
or simply playground
.
I wanted to publish lighthouse
's configuration and came up with publishing your configuration too.
Thanks BTW.
The introspect requests of the playground are done through http, even though it is running on a https domain, which return a "mixed content" error on the browser. Is there a way to configure it to use https? thanks!
In short I had this issue where my schema was corrupted
The only way I was able to identify the root causes of the issue was by opening my browser console and toggling the docs panel.
I think you should consider a tab that can show the errors that I got by using the above method. It would be very useful during development.
Hi ,
I am having problems with the download assets command. I am using win 10 , php 7.3.2. The error msg is below.
ErrorException : failed loading cafile stream: `C:\xampp\apache\bin\curl-ca-bundle.crt'
at F:\Work\php\laravel-demo\vendor\mll-lab\laravel-graphql-playground\src\DownloadAssetsCommand.php:25
21| public function handle()
22| {
23| $this->fileForceContents(
24| public_path(self::CSS_PATH_LOCAL),
25| file_get_contents('https:'.self::CSS_PATH_CDN)
26| );
27| $this->fileForceContents(
28| public_path(self::JS_PATH_LOCAL),
29| file_get_contents('https:'.self::JS_PATH_CDN)
Exception trace:
1 file_get_contents("https://cdn.jsdelivr.net/npm/graphql-playground-react/build/static/css/index.css")
F:\Work\php\laravel-demo\vendor\mll-lab\laravel-graphql-playground\src\DownloadAssetsCommand.php:25
2 MLL\GraphQLPlayground\DownloadAssetsCommand::handle()
F:\Work\php\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
Please help
Hi,
due to changes in the ServiceProvider signature (laravel/framework#34866) this package fails to load its service provider.
Pull request incoming.
best regards
Hello, on your where directive is there a way I can specify the table where an attribute is coming from. Just like the original model call of where something like:
$model->where('products.name', 'product name');
I have been attempting something like:
@where(products.name: String, operator: LIKE)
But it would end up in a syntax error
Graphql playground supports providing the subscription url.
Please update this package like it's done for the endpoint.
laravel-graphql-playground/views/index.blade.php
Lines 26 to 28 in b14caee
Add setting for websocket to subscription
On try create a subscription this throws error why not have websocket link in settings, but not have settings for this.
For the protected / guarded routes I need to pass the JWT token , how can I do this with Larvel graphql playground ?
Shared attributes are specified in an array format as the first parameter to the Route::group method.
https://laravel.com/docs/5.8/routing#route-groups
If the first argument to Route::group
isn't a function, it must be an array.
This can be resolved by changing
[config('graphql-playground.route')],
Hi,
Thank you for the open source project. I appreciate your hard work.
I am developing on a Windows OS (7). I am facing an issue with "php artisan graphql-playground:download-assets" command. The problem, in my opinion, is the windows folder structure, which is causing this error while recursively creating the directory structure. Any solution to this problem is greatly appreciated. I, as of now, have manually created the necessary folders and pasted the necessary files.
Thanks in advance.
Full Stack trace below --
λ php artisan graphql-playground:download-assets -v
ErrorException : mkdir(): No such file or directory
at E:\Web\PHP\laravel-demo\vendor\mll-lab\laravel-graphql-playground\src\DownloadAssetsCommand.php:49
45| $file = array_pop($parts);
46| $path = '';
47| foreach ($parts as $part) {
48| if (!is_dir($path .= "/$part")) {
> 49| mkdir($path);
50| }
51| }
52| file_put_contents("$path/$file", $contents);
53| }
Exception trace:
1 mkdir("/E:\Web\PHP\laravel-demo\public\vendor")
E:\Web\PHP\laravel-demo\vendor\mll-lab\laravel-graphql-playground\src\DownloadAssetsCommand.php:49
2 MLL\GraphQLPlayground\DownloadAssetsCommand::fileForceContents("/E:\Web\PHP\laravel-demo\public\vendor", "body{margin:0;padding:0;font-family:sans-serif;overflow:hidden}#root{height:100%}body{font-family:Open Sans,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:rgba(0,0,0,.8);line-height:1.5;height:100vh;letter-spacing:.53px;margin-right:-1px!important}a,body,code,h1,h2,h3,h4,html,p,pre,ul{margin:0;padding:0;color:inherit}a:active,a:focus,button:focus,input:focus{outline:none}button,input,submit{border:none}button,input,pre{font-family:Open Sans,sans-serif}code{font-family:Consolas,monospace}
/# sourceMappingURL=index.css.map/")
E:\Web\PHP\laravel-demo\vendor\mll-lab\laravel-graphql-playground\src\DownloadAssetsCommand.php:30
3 MLL\GraphQLPlayground\DownloadAssetsCommand::handle()
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29
4 call_user_func_array([])
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29
5 Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:87
6 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:31
7 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Container\Container.php:564
8 Illuminate\Container\Container::call()
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Console\Command.php:183
9 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
E:\Web\PHP\laravel-demo\vendor\symfony\console\Command\Command.php:251
10 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Console\Command.php:170
11 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\vendor\symfony\console\Application.php:886
12 Symfony\Component\Console\Application::doRunCommand(Object(MLL\GraphQLPlayground\DownloadAssetsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\vendor\symfony\console\Application.php:262
13 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\vendor\symfony\console\Application.php:145
14 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Console\Application.php:89
15 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:122
16 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
E:\Web\PHP\laravel-demo\artisan:37
When I click on copy curl
i receive the following JS error:
Uncaught TypeError: can't access property "getState", t.context.store is undefined in TopBar.tsx:115:20
Everything else is working as expected.
I am using version 2.1.0. Any thoughts on this?
Each time the csrf token is changed the old tabs needs to be updated with the latest X-CSRF-TOKEN
value. Is there a way that can called to update all the opened tabs's header values
After implementing a simple GraphQl
query such as a simple Mutation
and Subscription
I get this error when I try to run this subscription
into graphql-playground
:
subscription {
userCreated{
name
username
password
}
}
I get this error on graphql-playground
:
{
"error": "Could not connect to websocket endpoint ws://127.0.0.1:8000/graphql.
Please check if the endpoint url is correct."
}
GraphQl Schema:
#...
type User {
id: Int!
name: String
email: String
product : [Product!]
}
type Mutation {
createUser(
name: String!
password: String!
email : String!
): User @field(resolver:"UserMutator@create") @broadcast(subscription: "userCreated")
}
type Subscription {
userCreated: User
}
UserMutator
class:
class UserMutator{
public function create($_ , array $args){
$user = User::create($args);
Subscription::broadcast('userCreated',$user);
//return $user;
}
UserCreated
Subscription
class UserCreated extends GraphQLSubscription
{
public function authorize(Subscriber $subscriber, Request $request): bool
{
return true;
}
public function filter(Subscriber $subscriber, $root): bool
{
return true;
}
}
In our system we are using graphql through sessions, but to get it to work with graphql playground we had to change stuff in the view file and research what the GraphQLPlayground parameters was called.
In our application we also have CSRF protection on, so we also had to add a custom header to the request.
We fixed this by adding <meta name="csrf-token" content="{{ csrf_token() }}">
in the header and changing the init
parameters to the following
GraphQLPlayground.init(root, {
endpoint: "{{url(config('graphql-playground.endpoint'))}}",
settings: {
'request.credentials': 'same-origin',
},
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
}
})
What I am proposing is adding two config parameters, one to set the request.credentials
and one to enable CSRF token passthrough.
Is it possible to authenticate the playground with sanctum's SPA authentication? Or would it be better to just generate a token and add the bearer auth value to the headers? I've been trying to figure out how to most simply achieve authentication in the playground if a user wanted to test, but transition easily to an external token as well.
In Laravel 5.8 the route::group() is accepting the first parameter as an array. Not receiving said array fails in the GraphQLPlaygroundServiceProvider, exactly where is the route: group()
I soucione passing the variable as an array, as you can see in the code below
Route::group( [config('graphql-playground.route')], function (): void { Route::get( config('graphql-playground.route_name', 'graphql-playground'), GraphQLPlaygroundController::class.'@get' )->name('graphql-playground'); } );
When setup this packge in lighhouse tutorial i got this error
what i can do now?
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"mll-lab/laravel-graphql-playground": "^1.0",
"nuwave/lighthouse": "^2.6"
},
In Router.php line 363:
Argument 1 passed to Illuminate\Routing\Router::group() must be of the type array, string giv en,
called in D:\Laravel\lighthouse-tutorial\vendor\laravel\framework\src\Illuminate\Support\ Facades\Facade.php on line 223
--
In Router.php line 363:
Argument 1 passed to Illuminate\Routing\Router::group() must be of the type
array, string given, called in D:\Laravel\lighthouse-tutorial\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 223
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with er ror code 1
--
It's hard to believe but I had the case where I just installed it/ set it up and later on travel I didn't have wifi and couldn't even use it in my local environment :-(
Are you open to make a complete static snapshot of all the dependencies, so the web part is essentially self-contained?
I'm missing two things:
'enabled' => env('GRAPHQL_PLAYGROUND_ENABLED', true),
The latter could be achieved with something like the following in \MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider::boot
:
\Route::get(config('graphql-playground.route'), [
'middleware' => config('graphql-playground.middleware', ''),
'as' => 'graphql.playground',
'uses' => function () {
return view('graphql-playground::index');
},
]
);
It would be nice to update it to the latest graphql-playground version.
I am trying to hide a mutation from the playground.
So what I tried so far, is I took the file ./resources/views/vendor/graphql-playground/index.blade.php
and modified the settings object:
So what I tried so far, is I took the file ./resources/views/vendor/graphql-playground/index.blade.php
and modified the settings object:
GraphQLPlayground.init(root, {
endpoint: "{{url(config('graphql-playground.endpoint'))}}",
config: {
schema: {
mutation: {
exclude: ['mutationName', '_mutationNamePayload']
}
},
extensions: {
endpoints: {
production: {
url: "{{url(config('graphql-playground.endpoint'))}}",
exclude: ['mutationName', '_mutationNamePayload'],
mutations: {
exclude: ['mutationName', '_mutationNamePayload']
}
}
}
},
mutation: {
exclude: ['mutationName']
}
},
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
}
})
No luck so far, I can find no information on how to exclude specific parts, and the only similiar issue found is this:
https://community.neo4j.com/t/how-do-i-exclude-auto-generated-mutations/17767
Update composer to allow install for Laravel 5.8
Please add Lumen support :)
I wanted to change subscription endpoint of graphql-playground. Anyone has any idea?
I tried
'extensions' => [ 'endpoints' => [ 'dev' => [ 'subscription' => [ 'url' => 'wss://someendpoint', ] ] ] ]
Hi,
Is it possible to tag a new version that is compatible with laravel 10?
I am trying to give this a go but when I try to run it by going to: http://localhost/graphql-playground
I get a network 404 for http://localhost/graphql
and I think that the endpoint route is not registering properly.
Am i missing something?
Hi, we would like to use the middleware function, but the latest tagged version doesn't contain this feature.
Can u pls tag?
Playground works perfectly fine on localhost, but on production where I try to open dosc or schema tab it shows spinner loading icon infinitely.
I can do successfully queries.
Noticed problems and differences between localhost:
ServerError: Server response was missing for query 'IntrospectionQuery'.
at c (bundle.esm.js:22:17)
at bundle.esm.js:52:13
Server cannot be reached
I wanted to change subscription endpoint of graphql-playground. Anyone has any idea?
Considering this post:
graphql/graphql-playground#1143
Do you have any intention to publish a new package for GraphiQL ?
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.