dr-schopalopp / graphiql-middleware
GraphiQL PSR-15 Middleware based on https://github.com/graphql/graphiql
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Language:HTML
Requires
- php: ^7.4
- phpunit/php-text-template: ^1.2
- psr/http-server-middleware: ^1.0.0
Requires (Dev)
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.5
README
Add a GraphiQL interface to your application with this PSR-15 middleware.
This is basically a copy of graphiql-middleware adjusted for PSR-15.
Install
composer require dr-schopalopp/graphiql-middleware
Usage
This middleware was developed in a slim project, but it should work with any other PSR-15 compatible framework.
Slim 4
// app/dependencies.php use DrSchopalopp\GraphiQLMiddleware\GraphiQLMiddleware; return function (ContainerBuilder $containerBuilder) { $containerBuilder->addDefinitions([ // ... GraphiQLMiddleware::class => function () { return new GraphiQLMiddleware(); } // ... ]); };
// app/middleware.php use DrSchopalopp\GraphiQLMiddleware\GraphiQLMiddleware; return function (App $app) { // ... $app->add(GraphiQLMiddleware::class); // ... };
// app/routes.php return static function (App $app) { // ... // dummy route necessary otherwise you will get an HTTP 405 Method Not Allowed error $app->get('/graphiql', function (Request $request, Response $response) { return $response; }); // ... };
see HTTP 405 Method Not Allowed for details
License
The MIT License (MIT). Please see License File for more information.