forked from nuwave/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlighthouse.php
More file actions
399 lines (346 loc) · 14.2 KB
/
lighthouse.php
File metadata and controls
399 lines (346 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?php
return [
/*
|--------------------------------------------------------------------------
| Route Configuration
|--------------------------------------------------------------------------
|
| Controls the HTTP route that your GraphQL server responds to.
| You may set `route` => false, to disable the default route
| registration and take full control.
|
*/
'route' => [
/*
* The URI the endpoint responds to, e.g. mydomain.com/graphql.
*/
'uri' => '/graphql',
/*
* Lighthouse creates a named route for convenient URL generation and redirects.
*/
'name' => 'graphql',
/*
* Beware that middleware defined here runs before the GraphQL execution phase,
* make sure to return spec-compliant responses in case an error is thrown.
*/
'middleware' => [
\Nuwave\Lighthouse\Support\Http\Middleware\AcceptJson::class,
// Logs in a user if they are authenticated. In contrast to Laravel's 'auth'
// middleware, this delegates auth and permission checks to the field level.
\Nuwave\Lighthouse\Support\Http\Middleware\AttemptAuthentication::class,
// Logs every incoming GraphQL query.
// \Nuwave\Lighthouse\Support\Http\Middleware\LogGraphQLQueries::class,
],
/*
* The `prefix` and `domain` configuration options are optional.
*/
//'prefix' => '',
//'domain' => '',
],
/*
|--------------------------------------------------------------------------
| Authentication Guard
|--------------------------------------------------------------------------
|
| The guard to use for authenticating GraphQL requests, if needed.
| This setting is used whenever Lighthouse looks for an authenticated user, for example in directives
| such as `@guard` and when applying the `AttemptAuthentication` middleware.
|
*/
'guard' => 'api',
/*
|--------------------------------------------------------------------------
| Schema Location
|--------------------------------------------------------------------------
|
| Path to your .graphql schema file.
| Additional schema files may be imported from within that file.
|
*/
'schema' => [
'register' => base_path('graphql/schema.graphql'),
],
/*
|--------------------------------------------------------------------------
| Schema Cache
|--------------------------------------------------------------------------
|
| A large part of schema generation consists of parsing and AST manipulation.
| This operation is very expensive, so it is highly recommended to enable
| caching of the final schema to optimize performance of large schemas.
|
*/
'cache' => [
/*
* Setting to true enables schema caching.
*/
'enable' => env('LIGHTHOUSE_CACHE_ENABLE', env('APP_ENV') !== 'local'),
/*
* The name of the cache item for the schema cache.
*/
'key' => env('LIGHTHOUSE_CACHE_KEY', 'lighthouse-schema'),
/*
* Allows using a specific cache store, uses the app's default if set to null.
*/
'store' => env('LIGHTHOUSE_CACHE_STORE', null),
/*
* Duration in seconds the schema should remain cached, null means forever.
*/
'ttl' => env('LIGHTHOUSE_CACHE_TTL', null),
],
/*
|--------------------------------------------------------------------------
| Namespaces
|--------------------------------------------------------------------------
|
| These are the default namespaces where Lighthouse looks for classes to
| extend functionality of the schema. You may pass in either a string
| or an array, they are tried in order and the first match is used.
|
*/
'namespaces' => [
'models' => ['App', 'App\\Models'],
'queries' => 'App\\GraphQL\\Queries',
'mutations' => 'App\\GraphQL\\Mutations',
'subscriptions' => 'App\\GraphQL\\Subscriptions',
'interfaces' => 'App\\GraphQL\\Interfaces',
'unions' => 'App\\GraphQL\\Unions',
'scalars' => 'App\\GraphQL\\Scalars',
'directives' => ['App\\GraphQL\\Directives'],
'validators' => ['App\\GraphQL\\Validators'],
],
/*
|--------------------------------------------------------------------------
| Security
|--------------------------------------------------------------------------
|
| Control how Lighthouse handles security related query validation.
| Read more at https://webonyx.github.io/graphql-php/security/
|
*/
'security' => [
'max_query_complexity' => \GraphQL\Validator\Rules\QueryComplexity::DISABLED,
'max_query_depth' => \GraphQL\Validator\Rules\QueryDepth::DISABLED,
'disable_introspection' => \GraphQL\Validator\Rules\DisableIntrospection::DISABLED,
],
/*
|--------------------------------------------------------------------------
| Pagination
|--------------------------------------------------------------------------
|
| Set defaults for the pagination features within Lighthouse, such as
| the @paginate directive, or paginated relation directives.
|
*/
'pagination' => [
/*
* Allow clients to query paginated lists without specifying the amount of items.
* Setting this to `null` means clients have to explicitly ask for the count.
*/
'default_count' => null,
/*
* Limit the maximum amount of items that clients can request from paginated lists.
* Setting this to `null` means the count is unrestricted.
*/
'max_count' => null,
],
/*
|--------------------------------------------------------------------------
| Debug
|--------------------------------------------------------------------------
|
| Control the debug level as described in https://webonyx.github.io/graphql-php/error-handling/
| Debugging is only applied if the global Laravel debug config is set to true.
|
| When you set this value through an environment variable, use the following reference table:
| 0 => INCLUDE_NONE
| 1 => INCLUDE_DEBUG_MESSAGE
| 2 => INCLUDE_TRACE
| 3 => INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
| 4 => RETHROW_INTERNAL_EXCEPTIONS
| 5 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
| 6 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE
| 7 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
| 8 => RETHROW_UNSAFE_EXCEPTIONS
| 9 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
| 10 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_TRACE
| 11 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
| 12 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS
| 13 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
| 14 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE
| 15 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
|
*/
'debug' => env('LIGHTHOUSE_DEBUG', \GraphQL\Error\DebugFlag::INCLUDE_DEBUG_MESSAGE | \GraphQL\Error\DebugFlag::INCLUDE_TRACE),
/*
|--------------------------------------------------------------------------
| Error Handlers
|--------------------------------------------------------------------------
|
| Register error handlers that receive the Errors that occur during execution
| and handle them. You may use this to log, filter or format the errors.
| The classes must implement \Nuwave\Lighthouse\Execution\ErrorHandler
|
*/
'error_handlers' => [
\Nuwave\Lighthouse\Execution\ExtensionErrorHandler::class,
\Nuwave\Lighthouse\Execution\ReportingErrorHandler::class,
],
/*
|--------------------------------------------------------------------------
| Field Middleware
|--------------------------------------------------------------------------
|
| Register global field middleware directives that wrap around every field.
| Execution happens in the defined order, before other field middleware.
| The classes must implement \Nuwave\Lighthouse\Support\Contracts\FieldMiddleware
|
*/
'field_middleware' => [
\Nuwave\Lighthouse\Schema\Directives\TrimDirective::class,
\Nuwave\Lighthouse\Schema\Directives\SanitizeDirective::class,
\Nuwave\Lighthouse\Validation\ValidateDirective::class,
\Nuwave\Lighthouse\Schema\Directives\TransformArgsDirective::class,
\Nuwave\Lighthouse\Schema\Directives\SpreadDirective::class,
\Nuwave\Lighthouse\Schema\Directives\RenameArgsDirective::class,
],
/*
|--------------------------------------------------------------------------
| Global ID
|--------------------------------------------------------------------------
|
| The name that is used for the global id field on the Node interface.
| When creating a Relay compliant server, this must be named "id".
|
*/
'global_id_field' => 'id',
/*
|--------------------------------------------------------------------------
| Batched Queries
|--------------------------------------------------------------------------
|
| GraphQL query batching means sending multiple queries to the server in one request,
| You may set this flag to either process or deny batched queries.
|
*/
'batched_queries' => true,
/*
|--------------------------------------------------------------------------
| Transactional Mutations
|--------------------------------------------------------------------------
|
| If set to true, mutations such as @create or @update will be
| wrapped in a transaction to ensure atomicity.
|
*/
'transactional_mutations' => true,
/*
|--------------------------------------------------------------------------
| Mass Assignment Protection
|--------------------------------------------------------------------------
|
| If set to true, mutations will use forceFill() over fill() when populating
| a model with arguments in mutation directives. Since GraphQL constrains
| allowed inputs by design, mass assignment protection is not needed.
|
*/
'force_fill' => true,
/*
|--------------------------------------------------------------------------
| Batchload Relations
|--------------------------------------------------------------------------
|
| If set to true, relations marked with directives like @hasMany or @belongsTo
| will be optimized by combining the queries through the BatchLoader.
|
*/
'batchload_relations' => true,
/*
|--------------------------------------------------------------------------
| GraphQL Subscriptions
|--------------------------------------------------------------------------
|
| Here you can define GraphQL subscription broadcaster and storage drivers
| as well their required configuration options.
|
*/
'subscriptions' => [
/*
* Determines if broadcasts should be queued by default.
*/
'queue_broadcasts' => env('LIGHTHOUSE_QUEUE_BROADCASTS', true),
/*
* Determines the queue to use for broadcasting queue jobs.
*/
'broadcasts_queue_name' => env('LIGHTHOUSE_BROADCASTS_QUEUE_NAME', null),
/*
* Default subscription storage.
*
* Any Laravel supported cache driver options are available here.
*/
'storage' => env('LIGHTHOUSE_SUBSCRIPTION_STORAGE', 'redis'),
/*
* Default subscription storage time to live in seconds.
*
* Indicates how long a subscription can be active before it's automatically removed from storage.
* Setting this to `null` means the subscriptions are stored forever. This may cause
* stale subscriptions to linger indefinitely in case cleanup fails for any reason.
*/
'storage_ttl' => env('LIGHTHOUSE_SUBSCRIPTION_STORAGE_TTL', null),
/*
* Default subscription broadcaster.
*/
'broadcaster' => env('LIGHTHOUSE_BROADCASTER', 'pusher'),
/*
* Subscription broadcasting drivers with config options.
*/
'broadcasters' => [
'log' => [
'driver' => 'log',
],
'pusher' => [
'driver' => 'pusher',
'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class.'@pusher',
'connection' => 'pusher',
],
'echo' => [
'driver' => 'echo',
'connection' => env('LIGHTHOUSE_SUBSCRIPTION_REDIS_CONNECTION', 'default'),
'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class.'@echoRoutes',
],
],
/*
* Controls the format of the extensions response.
* Allowed values: 1, 2
*/
'version' => env('LIGHTHOUSE_SUBSCRIPTION_VERSION', 1),
/*
* Should the subscriptions extension be excluded when the response has no subscription channel?
* This optimizes performance by sending less data, but clients must anticipate this appropriately.
* Will default to true in v6 and be removed in v7.
*/
'exclude_empty' => env('LIGHTHOUSE_SUBSCRIPTION_EXCLUDE_EMPTY', false),
],
/*
|--------------------------------------------------------------------------
| Defer
|--------------------------------------------------------------------------
|
| Configuration for the experimental @defer directive support.
|
*/
'defer' => [
/*
* Maximum number of nested fields that can be deferred in one query.
* Once reached, remaining fields will be resolved synchronously.
* 0 means unlimited.
*/
'max_nested_fields' => 0,
/*
* Maximum execution time for deferred queries in milliseconds.
* Once reached, remaining fields will be resolved synchronously.
* 0 means unlimited.
*/
'max_execution_ms' => 0,
],
];