|
4 | 4 |
|
5 | 5 | use Illuminate\Contracts\Auth\Access\Gate; |
6 | 6 | use Illuminate\Contracts\Auth\Factory as AuthFactory; |
| 7 | +use Illuminate\Contracts\Events\Dispatcher; |
7 | 8 | use Symfony\Component\Cache\Adapter\ApcuAdapter; |
8 | 9 | use Symfony\Component\Cache\Adapter\PhpFilesAdapter; |
9 | 10 | use Symfony\Component\Cache\Psr16Cache; |
10 | 11 | use TheCodingMachine\GraphQLite\Context\Context; |
11 | 12 | use TheCodingMachine\GraphQLite\Exceptions\WebonyxErrorHandler; |
| 13 | +use TheCodingMachine\GraphQLite\Laravel\Listeners\CachePurger; |
12 | 14 | use TheCodingMachine\GraphQLite\Laravel\Mappers\Parameters\ValidateFieldMiddleware; |
13 | 15 | use TheCodingMachine\GraphQLite\Laravel\Mappers\PaginatorTypeMapper; |
14 | 16 | use TheCodingMachine\GraphQLite\Laravel\Mappers\PaginatorTypeMapperFactory; |
@@ -41,13 +43,14 @@ class GraphQLiteServiceProvider extends ServiceProvider |
41 | 43 | * |
42 | 44 | * @return void |
43 | 45 | */ |
44 | | - public function boot() |
| 46 | + public function boot(Dispatcher $events) |
45 | 47 | { |
46 | 48 | $this->publishes([ |
47 | 49 | __DIR__.'/../../config/graphqlite.php' => config_path('graphqlite.php'), |
48 | 50 | ], 'config'); |
49 | 51 |
|
50 | 52 | $this->loadRoutesFrom(__DIR__.'/../routes/routes.php'); |
| 53 | + $events->listen('cache:clearing', CachePurger::class); |
51 | 54 | } |
52 | 55 |
|
53 | 56 | /** |
@@ -88,6 +91,10 @@ public function register() |
88 | 91 | } |
89 | 92 | }); |
90 | 93 |
|
| 94 | + $this->app->singleton(CachePurger::class, static function (Application $app) { |
| 95 | + return new CachePurger($app['graphqliteCache']); |
| 96 | + }); |
| 97 | + |
91 | 98 | $this->app->singleton(AuthenticationService::class, function(Application $app) { |
92 | 99 | $guard = config('graphqlite.guard', $this->app['config']['auth.defaults.guard']); |
93 | 100 | if (!is_array($guard)) { |
|
0 commit comments