You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

600 lines
22 KiB

1 month ago
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Route Configuration
  6. |--------------------------------------------------------------------------
  7. |
  8. | Controls the HTTP route that your GraphQL server responds to.
  9. | You may set `route` => false, to disable the default route
  10. | registration and take full control.
  11. |
  12. */
  13. 'route' => [
  14. /*
  15. * The URI the endpoint responds to, e.g. mydomain.com/graphql.
  16. */
  17. 'uri' => '/graphql',
  18. /*
  19. * Lighthouse creates a named route for convenient URL generation and redirects.
  20. */
  21. 'name' => 'graphql',
  22. /*
  23. * Beware that middleware defined here runs before the GraphQL execution phase,
  24. * make sure to return spec-compliant responses in case an error is thrown.
  25. */
  26. 'middleware' => [
  27. \Nuwave\Lighthouse\Support\Http\Middleware\AcceptJson::class,
  28. // Logs in a user if they are authenticated. In contrast to Laravel's 'auth'
  29. // middleware, this delegates auth and permission checks to the field level.
  30. \Nuwave\Lighthouse\Support\Http\Middleware\AttemptAuthentication::class,
  31. // Logs every incoming GraphQL query.
  32. // \Nuwave\Lighthouse\Support\Http\Middleware\LogGraphQLQueries::class,
  33. ],
  34. /*
  35. * The `prefix` and `domain` configuration options are optional.
  36. */
  37. //'prefix' => '',
  38. //'domain' => '',
  39. ],
  40. /*
  41. |--------------------------------------------------------------------------
  42. | Authentication Guard
  43. |--------------------------------------------------------------------------
  44. |
  45. | The guard to use for authenticating GraphQL requests, if needed.
  46. | This setting is used whenever Lighthouse looks for an authenticated user, for example in directives
  47. | such as `@guard` and when applying the `AttemptAuthentication` middleware.
  48. |
  49. */
  50. 'guard' => 'api',
  51. /*
  52. |--------------------------------------------------------------------------
  53. | Schema Location
  54. |--------------------------------------------------------------------------
  55. |
  56. | Path to your .graphql schema file.
  57. | Additional schema files may be imported from within that file.
  58. |
  59. */
  60. 'schema' => [
  61. 'register' => __DIR__ . '/../src/GraphQL/Schema/schema.graphql',
  62. ],
  63. /*
  64. |--------------------------------------------------------------------------
  65. | Schema Cache
  66. |--------------------------------------------------------------------------
  67. |
  68. | A large part of schema generation consists of parsing and AST manipulation.
  69. | This operation is very expensive, so it is highly recommended to enable
  70. | caching of the final schema to optimize performance of large schemas.
  71. |
  72. */
  73. 'cache' => [
  74. /*
  75. * Setting to true enables schema caching.
  76. */
  77. 'enable' => env('LIGHTHOUSE_CACHE_ENABLE', 'local' !== env('APP_ENV')),
  78. /*
  79. * Allowed values:
  80. * - 1: uses the store, key and ttl config values to store the schema as a string in the given cache store.
  81. * - 2: uses the path config value to store the schema in a PHP file allowing OPcache to pick it up.
  82. */
  83. 'version' => env('LIGHTHOUSE_CACHE_VERSION', 1),
  84. /*
  85. * The name of the cache item for the schema cache.
  86. */
  87. 'version' => env('LIGHTHOUSE_CACHE_VERSION', 1),
  88. /*
  89. * Allows using a specific cache store, uses the app's default if set to null.
  90. * Only relevant if version is set to 1.
  91. */
  92. 'store' => env('LIGHTHOUSE_CACHE_STORE', null),
  93. /*
  94. * The name of the cache item for the schema cache.
  95. * Only relevant if version is set to 1.
  96. */
  97. 'key' => env('LIGHTHOUSE_CACHE_KEY', 'lighthouse-schema'),
  98. /*
  99. * Duration in seconds the schema should remain cached, null means forever.
  100. * Only relevant if version is set to 1.
  101. */
  102. 'ttl' => env('LIGHTHOUSE_CACHE_TTL', null),
  103. /*
  104. * File path to store the lighthouse schema.
  105. * Only relevant if version is set to 2.
  106. */
  107. 'path' => env('LIGHTHOUSE_CACHE_PATH', base_path('bootstrap/cache/lighthouse-schema.php')),
  108. /*
  109. * Should the `@cache` directive use a tagged cache?
  110. */
  111. 'tags' => false,
  112. ],
  113. /*
  114. |--------------------------------------------------------------------------
  115. | Query Cache
  116. |--------------------------------------------------------------------------
  117. |
  118. | Caches the result of parsing incoming query strings to boost performance on subsequent requests.
  119. |
  120. */
  121. 'query_cache' => [
  122. /*
  123. * Setting to true enables query caching.
  124. */
  125. 'enable' => env('LIGHTHOUSE_QUERY_CACHE_ENABLE', true),
  126. /*
  127. * Allows using a specific cache store, uses the app's default if set to null.
  128. */
  129. 'store' => env('LIGHTHOUSE_QUERY_CACHE_STORE', null),
  130. /*
  131. * Duration in seconds the query should remain cached, null means forever.
  132. */
  133. 'ttl' => env(
  134. 'LIGHTHOUSE_QUERY_CACHE_TTL',
  135. \Nuwave\Lighthouse\Support\AppVersion::atLeast(5.8)
  136. ? null
  137. : 365 * 24 * 60 // For Laravel < 5.8 the exact value must be specified and it is counted in minutes
  138. ),
  139. ],
  140. /*
  141. |--------------------------------------------------------------------------
  142. | Namespaces
  143. |--------------------------------------------------------------------------
  144. |
  145. | These are the default namespaces where Lighthouse looks for classes to
  146. | extend functionality of the schema. You may pass in either a string
  147. | or an array, they are tried in order and the first match is used.
  148. |
  149. */
  150. 'namespaces' => [
  151. 'models' => ['App', 'Marvel\\Database\\Models'],
  152. 'queries' => ['App\\GraphQL\\Queries', 'Marvel\\GraphQL\\Queries'],
  153. 'mutations' => ['App\\GraphQL\\Mutations', 'Marvel\\GraphQL\\Mutation'],
  154. 'subscriptions' => 'App\\GraphQL\\Subscriptions',
  155. 'interfaces' => 'App\\GraphQL\\Interfaces',
  156. 'unions' => 'App\\GraphQL\\Unions',
  157. 'scalars' => 'App\\GraphQL\\Scalars',
  158. 'directives' => ['App\\GraphQL\\Directives', 'Marvel\\GraphQL\\Directives'],
  159. 'validators' => ['App\\GraphQL\\Validators'],
  160. ],
  161. /*
  162. |--------------------------------------------------------------------------
  163. | Security
  164. |--------------------------------------------------------------------------
  165. |
  166. | Control how Lighthouse handles security related query validation.
  167. | Read more at https://webonyx.github.io/graphql-php/security/
  168. |
  169. */
  170. 'security' => [
  171. 'max_query_complexity' => \GraphQL\Validator\Rules\QueryComplexity::DISABLED,
  172. 'max_query_depth' => \GraphQL\Validator\Rules\QueryDepth::DISABLED,
  173. 'disable_introspection' => \GraphQL\Validator\Rules\DisableIntrospection::DISABLED,
  174. ],
  175. /*
  176. |--------------------------------------------------------------------------
  177. | Pagination
  178. |--------------------------------------------------------------------------
  179. |
  180. | Set defaults for the pagination features within Lighthouse, such as
  181. | the @paginate directive, or paginated relation directives.
  182. |
  183. */
  184. 'pagination' => [
  185. /*
  186. * Allow clients to query paginated lists without specifying the amount of items.
  187. * Setting this to `null` means clients have to explicitly ask for the count.
  188. */
  189. 'default_count' => null,
  190. /*
  191. * Limit the maximum amount of items that clients can request from paginated lists.
  192. * Setting this to `null` means the count is unrestricted.
  193. */
  194. 'max_count' => null,
  195. ],
  196. /*
  197. |--------------------------------------------------------------------------
  198. | Debug
  199. |--------------------------------------------------------------------------
  200. |
  201. | Control the debug level as described in https://webonyx.github.io/graphql-php/error-handling/
  202. | Debugging is only applied if the global Laravel debug config is set to true.
  203. |
  204. | When you set this value through an environment variable, use the following reference table:
  205. | 0 => INCLUDE_NONE
  206. | 1 => INCLUDE_DEBUG_MESSAGE
  207. | 2 => INCLUDE_TRACE
  208. | 3 => INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
  209. | 4 => RETHROW_INTERNAL_EXCEPTIONS
  210. | 5 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
  211. | 6 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE
  212. | 7 => RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
  213. | 8 => RETHROW_UNSAFE_EXCEPTIONS
  214. | 9 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
  215. | 10 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_TRACE
  216. | 11 => RETHROW_UNSAFE_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
  217. | 12 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS
  218. | 13 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_DEBUG_MESSAGE
  219. | 14 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE
  220. | 15 => RETHROW_UNSAFE_EXCEPTIONS | RETHROW_INTERNAL_EXCEPTIONS | INCLUDE_TRACE | INCLUDE_DEBUG_MESSAGE
  221. |
  222. */
  223. 'debug' => env('LIGHTHOUSE_DEBUG', \GraphQL\Error\DebugFlag::INCLUDE_DEBUG_MESSAGE | \GraphQL\Error\DebugFlag::INCLUDE_TRACE),
  224. /*
  225. |--------------------------------------------------------------------------
  226. | Error Handlers
  227. |--------------------------------------------------------------------------
  228. |
  229. | Register error handlers that receive the Errors that occur during execution
  230. | and handle them. You may use this to log, filter or format the errors.
  231. | The classes must implement \Nuwave\Lighthouse\Execution\ErrorHandler
  232. |
  233. */
  234. 'error_handlers' => [
  235. \Nuwave\Lighthouse\Execution\AuthenticationErrorHandler::class,
  236. \Nuwave\Lighthouse\Execution\AuthorizationErrorHandler::class,
  237. \Nuwave\Lighthouse\Execution\ValidationErrorHandler::class,
  238. \Nuwave\Lighthouse\Execution\ExtensionErrorHandler::class,
  239. \Nuwave\Lighthouse\Execution\ReportingErrorHandler::class,
  240. ],
  241. /*
  242. |--------------------------------------------------------------------------
  243. | Field Middleware
  244. |--------------------------------------------------------------------------
  245. |
  246. | Register global field middleware directives that wrap around every field.
  247. | Execution happens in the defined order, before other field middleware.
  248. | The classes must implement \Nuwave\Lighthouse\Support\Contracts\FieldMiddleware
  249. |
  250. */
  251. 'field_middleware' => [
  252. \Nuwave\Lighthouse\Schema\Directives\TrimDirective::class,
  253. \Nuwave\Lighthouse\Schema\Directives\SanitizeDirective::class,
  254. \Nuwave\Lighthouse\Validation\ValidateDirective::class,
  255. \Nuwave\Lighthouse\Schema\Directives\TransformArgsDirective::class,
  256. \Nuwave\Lighthouse\Schema\Directives\SpreadDirective::class,
  257. \Nuwave\Lighthouse\Schema\Directives\RenameArgsDirective::class,
  258. ],
  259. /*
  260. |--------------------------------------------------------------------------
  261. | Global ID
  262. |--------------------------------------------------------------------------
  263. |
  264. | The name that is used for the global id field on the Node interface.
  265. | When creating a Relay compliant server, this must be named "id".
  266. |
  267. */
  268. 'global_id_field' => 'id',
  269. /*
  270. |--------------------------------------------------------------------------
  271. | Batched Queries
  272. |--------------------------------------------------------------------------
  273. |
  274. | GraphQL query batching means sending multiple queries to the server in one request,
  275. | You may set this flag to either process or deny batched queries.
  276. |
  277. */
  278. // 'batched_queries' => true,
  279. /*
  280. |--------------------------------------------------------------------------
  281. | Persisted Queries
  282. |--------------------------------------------------------------------------
  283. |
  284. | Lighthouse supports Automatic Persisted Queries (APQ), compatible with the
  285. | [Apollo implementation](https://www.apollographql.com/docs/apollo-server/performance/apq).
  286. | You may set this flag to either process or deny these queries.
  287. |
  288. */
  289. 'persisted_queries' => true,
  290. /*
  291. |--------------------------------------------------------------------------
  292. | Persisted Queries
  293. |--------------------------------------------------------------------------
  294. |
  295. | Lighthouse supports Automatic Persisted Queries (APQ), compatible with the
  296. | [Apollo implementation](https://www.apollographql.com/docs/apollo-server/performance/apq).
  297. | You may set this flag to either process or deny these queries.
  298. |
  299. */
  300. 'persisted_queries' => true,
  301. /*
  302. |--------------------------------------------------------------------------
  303. | Transactional Mutations
  304. |--------------------------------------------------------------------------
  305. |
  306. | If set to true, mutations such as @create or @update will be
  307. | wrapped in a transaction to ensure atomicity.
  308. |
  309. */
  310. 'transactional_mutations' => true,
  311. /*
  312. |--------------------------------------------------------------------------
  313. | Mass Assignment Protection
  314. |--------------------------------------------------------------------------
  315. |
  316. | If set to true, mutations will use forceFill() over fill() when populating
  317. | a model with arguments in mutation directives. Since GraphQL constrains
  318. | allowed inputs by design, mass assignment protection is not needed.
  319. |
  320. */
  321. 'force_fill' => true,
  322. /*
  323. |--------------------------------------------------------------------------
  324. | Batchload Relations
  325. |--------------------------------------------------------------------------
  326. |
  327. | If set to true, relations marked with directives like @hasMany or @belongsTo
  328. | will be optimized by combining the queries through the BatchLoader.
  329. |
  330. */
  331. 'batchload_relations' => true,
  332. /*
  333. |--------------------------------------------------------------------------
  334. | Shortcut Foreign Key Selection
  335. |--------------------------------------------------------------------------
  336. |
  337. | If set to true, Lighthouse will shortcut queries where the client selects only the
  338. | foreign key pointing to a related model. Only works if the related model's primary
  339. | key field is called exactly `id` for every type in your schema.
  340. |
  341. */
  342. 'shortcut_foreign_key_selection' => false,
  343. /*
  344. |--------------------------------------------------------------------------
  345. | Non-Null Pagination Results
  346. |--------------------------------------------------------------------------
  347. |
  348. | If set to true, the generated result type of paginated lists will be marked
  349. | as non-nullable. This is generally more convenient for clients, but will
  350. | cause validation errors to bubble further up in the result.
  351. |
  352. | This setting will be removed and always behave as if it were true in v6.
  353. |
  354. */
  355. 'non_null_pagination_results' => false,
  356. /*
  357. |--------------------------------------------------------------------------
  358. | Unbox BenSampo\Enum\Enum instances
  359. |--------------------------------------------------------------------------
  360. |
  361. | If set to true, Lighthouse will extract the internal $value from instances of
  362. | BenSampo\Enum\Enum before passing it to ArgBuilderDirective::handleBuilder().
  363. |
  364. | This setting will be removed and always behave as if it were false in v6.
  365. |
  366. | It is only here to preserve compatibility, e.g. when expecting the internal
  367. | value to be passed to a scope when using @scope, but not needed due to Laravel
  368. | calling the Enum's __toString() method automagically when used in a query.
  369. |
  370. */
  371. 'unbox_bensampo_enum_enum_instances' => true,
  372. /*
  373. |--------------------------------------------------------------------------
  374. | Shortcut Foreign Key Selection
  375. |--------------------------------------------------------------------------
  376. |
  377. | If set to true, Lighthouse will shortcut queries where the client selects only the
  378. | foreign key pointing to a related model. Only works if the related model's primary
  379. | key field is called exactly `id` for every type in your schema.
  380. |
  381. */
  382. 'shortcut_foreign_key_selection' => false,
  383. /*
  384. |--------------------------------------------------------------------------
  385. | Non-Null Pagination Results
  386. |--------------------------------------------------------------------------
  387. |
  388. | If set to true, the generated result type of paginated lists will be marked
  389. | as non-nullable. This is generally more convenient for clients, but will
  390. | cause validation errors to bubble further up in the result.
  391. |
  392. | This setting will be removed and always behave as if it were true in v6.
  393. |
  394. */
  395. 'non_null_pagination_results' => false,
  396. /*
  397. |--------------------------------------------------------------------------
  398. | Unbox BenSampo\Enum\Enum instances
  399. |--------------------------------------------------------------------------
  400. |
  401. | If set to true, Lighthouse will extract the internal $value from instances of
  402. | BenSampo\Enum\Enum before passing it to ArgBuilderDirective::handleBuilder().
  403. |
  404. | This setting will be removed and always behave as if it were false in v6.
  405. |
  406. | It is only here to preserve compatibility, e.g. when expecting the internal
  407. | value to be passed to a scope when using @scope, but not needed due to Laravel
  408. | calling the Enum's __toString() method automagically when used in a query.
  409. |
  410. */
  411. 'unbox_bensampo_enum_enum_instances' => true,
  412. /*
  413. |--------------------------------------------------------------------------
  414. | GraphQL Subscriptions
  415. |--------------------------------------------------------------------------
  416. |
  417. | Here you can define GraphQL subscription broadcaster and storage drivers
  418. | as well their required configuration options.
  419. |
  420. */
  421. 'subscriptions' => [
  422. /*
  423. * Determines if broadcasts should be queued by default.
  424. */
  425. 'queue_broadcasts' => env('LIGHTHOUSE_QUEUE_BROADCASTS', true),
  426. /*
  427. * Determines the queue to use for broadcasting queue jobs.
  428. */
  429. 'broadcasts_queue_name' => env('LIGHTHOUSE_BROADCASTS_QUEUE_NAME', null),
  430. /*
  431. * Default subscription storage.
  432. *
  433. * Any Laravel supported cache driver options are available here.
  434. */
  435. 'storage' => env('LIGHTHOUSE_SUBSCRIPTION_STORAGE', 'redis'),
  436. /*
  437. * Default subscription storage time to live in seconds.
  438. *
  439. * Indicates how long a subscription can be active before it's automatically removed from storage.
  440. * Setting this to `null` means the subscriptions are stored forever. This may cause
  441. * stale subscriptions to linger indefinitely in case cleanup fails for any reason.
  442. */
  443. 'storage_ttl' => env('LIGHTHOUSE_SUBSCRIPTION_STORAGE_TTL', null),
  444. /*
  445. * Default subscription broadcaster.
  446. */
  447. 'broadcaster' => env('LIGHTHOUSE_BROADCASTER', 'pusher'),
  448. /*
  449. * Subscription broadcasting drivers with config options.
  450. */
  451. 'broadcasters' => [
  452. 'log' => [
  453. 'driver' => 'log',
  454. ],
  455. 'pusher' => [
  456. 'driver' => 'pusher',
  457. 'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class . '@pusher',
  458. 'connection' => 'pusher',
  459. ],
  460. 'echo' => [
  461. 'driver' => 'echo',
  462. 'connection' => env('LIGHTHOUSE_SUBSCRIPTION_REDIS_CONNECTION', 'default'),
  463. 'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class . '@echoRoutes',
  464. ],
  465. ],
  466. /*
  467. * Controls the format of the extensions response.
  468. * Allowed values: 1, 2
  469. */
  470. 'version' => env('LIGHTHOUSE_SUBSCRIPTION_VERSION', 1),
  471. /*
  472. * Should the subscriptions extension be excluded when the response has no subscription channel?
  473. * This optimizes performance by sending less data, but clients must anticipate this appropriately.
  474. * Will default to true in v6 and be removed in v7.
  475. */
  476. 'exclude_empty' => env('LIGHTHOUSE_SUBSCRIPTION_EXCLUDE_EMPTY', false),
  477. ],
  478. /*
  479. |--------------------------------------------------------------------------
  480. | Defer
  481. |--------------------------------------------------------------------------
  482. |
  483. | Configuration for the experimental @defer directive support.
  484. |
  485. */
  486. 'defer' => [
  487. /*
  488. * Maximum number of nested fields that can be deferred in one query.
  489. * Once reached, remaining fields will be resolved synchronously.
  490. * 0 means unlimited.
  491. */
  492. 'max_nested_fields' => 0,
  493. /*
  494. * Maximum execution time for deferred queries in milliseconds.
  495. * Once reached, remaining fields will be resolved synchronously.
  496. * 0 means unlimited.
  497. */
  498. 'max_execution_ms' => 0,
  499. ],
  500. /*
  501. |--------------------------------------------------------------------------
  502. | Apollo Federation
  503. |--------------------------------------------------------------------------
  504. |
  505. | Lighthouse can act as a federated service: https://www.apollographql.com/docs/federation/federation-spec.
  506. |
  507. */
  508. 'federation' => [
  509. /*
  510. * Location of resolver classes when resolving the `_entities` field.
  511. */
  512. 'entities_resolver_namespace' => 'App\\GraphQL\\Entities',
  513. ],
  514. ];