@@ -63,6 +63,7 @@ config/graphql.php
6363 - [ GraphQL resolver middleware] ( #graphql-resolver-middleware )
6464 - [ Schemas] ( #schemas )
6565 - [ Schema classes] ( #schema-classes )
66+ - [ Route attributes] ( #route-attributes )
6667 - [ Creating a query] ( #creating-a-query )
6768 - [ Creating a mutation] ( #creating-a-mutation )
6869 - [ File uploads] ( #file-uploads )
@@ -245,7 +246,7 @@ schemas and assign different **HTTP middleware** and **execution middleware** to
245246them, in addition to the global middleware. For example:
246247
247248``` php
248- 'schema ' => 'default',
249+ 'default_schema ' => 'default',
249250
250251'schemas' => [
251252 'default' => [
@@ -275,6 +276,11 @@ them, in addition to the global middleware. For example:
275276 'execution_middleware' => [
276277 \Rebing\GraphQL\Support\ExecutionMiddleware\UnusedVariablesMiddleware::class,
277278 ],
279+ // Route attributes applied to the generated HTTP route for this schema
280+ // Example: expose this schema on a dedicated subdomain
281+ 'route_attributes' => [
282+ 'domain' => 'api.example.com',
283+ ],
278284 ],
279285],
280286```
@@ -284,6 +290,24 @@ which it is accessible. Per the default configuration of `prefix = graphql`, the
284290_ default_ schema is accessible via ` /graphql ` .
285291
286292
293+ #### Route attributes
294+
295+ You can customize the HTTP route generated for a specific schema using the ` route_attributes ` key.
296+ This is useful for setting parameters supported by Laravel routes, e.g. a custom ` domain ` .
297+
298+ ``` php
299+ 'schemas' => [
300+ 'with_custom_domain' => [
301+ 'query' => [
302+ App\GraphQL\Queries\UsersQuery::class,
303+ ],
304+ 'middleware' => ['auth:api'],
305+ 'route_attributes' => [
306+ 'domain' => 'api.example.com',
307+ ],
308+ ],
309+ ]
310+ ```
287311
288312
289313#### Schema classes
@@ -1895,6 +1919,37 @@ class PostsQuery extends Query
18951919}
18961920```
18971921
1922+ [ Cursor Pagination] ( https://laravel.com/docs/pagination#cursor-pagination ) will be used, if a query or mutation returns a ` CursorPaginationType ` .
1923+
1924+ ``` php
1925+ namespace App\GraphQL\Queries;
1926+
1927+ use Closure;
1928+ use GraphQL\Type\Definition\ResolveInfo;
1929+ use GraphQL\Type\Definition\Type;
1930+ use Rebing\GraphQL\Support\Facades\GraphQL;
1931+ use Rebing\GraphQL\Support\Query;
1932+
1933+ class PostsQuery extends Query
1934+ {
1935+ public function type(): Type
1936+ {
1937+ return GraphQL::cursorPaginate('posts');
1938+ }
1939+
1940+ // ...
1941+
1942+ public function resolve($root, array $args, $context, ResolveInfo $info, Closure $getSelectFields)
1943+ {
1944+ $fields = $getSelectFields();
1945+
1946+ return Post::with($fields->getRelations())
1947+ ->select($fields->getSelect())
1948+ ->cursorPaginate($args['limit'], ['*'], 'cursorName', $args['cursor']);
1949+ }
1950+ }
1951+ ```
1952+
18981953### Batching
18991954
19001955Batched requests are required to be sent via a POST request.
@@ -2005,7 +2060,7 @@ class EpisodeEnum extends EnumType
20052060> will be able to choose from, while the value is what will your server receive (what will enum
20062061> be resolved to).
20072062
2008- The Enum will be registered like any other type in your schema in ` config/graphq .php ` :
2063+ The Enum will be registered like any other type in your schema in ` config/graphql .php ` :
20092064
20102065``` php
20112066'schemas' => [
@@ -2266,7 +2321,7 @@ class ReviewInput extends InputType
22662321}
22672322```
22682323
2269- The Input Object will be registered like any other type in your schema in ` config/graphq .php ` :
2324+ The Input Object will be registered like any other type in your schema in ` config/graphql .php ` :
22702325
22712326``` php
22722327'schemas' => [
0 commit comments