for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Digia\Lumen\GraphQL\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class GraphiQLTokenMiddleware
* @package Digia\Lumen\GraphQL\Http\Middleware
*/
class GraphiQLTokenMiddleware
{
* @var boolean
private $enableGraphiql;
* @var string|null
private $graphiqlToken;
* GraphiQLTokenMiddleware constructor.
*
* @param bool $enableGraphiql
* @param string|null $graphiqlToken
public function __construct($enableGraphiql, $graphiqlToken)
$this->enableGraphiql = $enableGraphiql;
$this->graphiqlToken = $graphiqlToken;
}
* @inheritDoc
* @throws NotFoundHttpException if the interface is not enabled
public function handle(Request $request, Closure $next)
if ($this->enableGraphiql || ($this->graphiqlToken !== null && $request->get('token') === $this->graphiqlToken)) {
return $next($request);
// Pretend the interface is not there if not enabled
throw new NotFoundHttpException();