Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Enable route caching

Choose a tag to compare

@spawnia spawnia released this 18 Sep 20:34
· 75 commits to master since this release
46ff4e8
Enable route caching by adding a dedicated controller (#11)

Without this PR this package adds a route with an anonymous controller function. This is incompatible with native Laravel route caching, causing the following exception:

```bash
$ php artisan route:cache
Route cache cleared!

   LogicException  : Unable to prepare route [graphql-playground] for serialization. Uses Closure.

  at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php:880
    876|      */
    877|     public function prepareForSerialization()
    878|     {
    879|         if ($this->action['uses'] instanceof Closure) {
  > 880|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    881|         }
    882| 
    883|         $this->compileRoute();
    884| 

  Exception trace:

  1   Illuminate\Routing\Route::prepareForSerialization()
      /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29

  Please use the argument -v to see more details.
```

With this PR route caching is possible again by introducing a controller class for the playground.