docs/components/controller.md in graphql_rails-1.0.0 vs docs/components/controller.md in graphql_rails-1.1.0
- old
+ new
@@ -167,11 +167,11 @@
User.all
end
end
```
-Also check ['decorating controller responses']('components/decorator') for more details about working with active record and decorators.
+Also check ['decorating controller responses'](components/decorator) for more details about working with active record and decorators.
#### *max_page_size*
Allows to specify max items count per request
@@ -217,10 +217,26 @@
user = User.find(params[:id]).orders.last
end
end
```
+You can also return raw graphql-ruby types:
+
+```ruby
+# raw graphql-ruby type:
+class OrderType < GraphQL::Schema::Object
+ graphql_name 'Order'
+ field :id, ID
+end
+
+class UsersController < GraphqlRails::Controller
+ action(:last_order).permit(:id).returns(OrderType)
+end
+```
+
+Check [graphql-ruby documentation](https://graphql-ruby.org) for more details about graphql-ruby types.
+
### *returns_list*
When you have defined `model` dynamically, you can use `returns_list` to indicate that action must return list without specifying model type for each action. By default list and inner types are required but you can change that with `required_list: false` and `required_inner: false`
```ruby
@@ -436,17 +452,17 @@
end
```
## decorating objects
-See ['Decorating controller responses']('components/decorator') for various options how you can decorate paginated responses
+See ['Decorating controller responses'](components/decorator) for various options how you can decorate paginated responses
## Rendering errors
### Rendering strings as errors
-The simples way to render error is to provide list of error messages, like this:
+The simplest way to render an error is to provide a list of error messages, like this:
```ruby
class UsersController < GraphqlRails::Controller
action(:update).permit(:id, input: 'UserInput!').returns('User!')
@@ -507,15 +523,15 @@
end
```
### Raising custom error classes
-If you want to have customized error classes you need to create errors which inherits from `GraphqlRails::ExecutionError`
+If you want to have customized error classes you need to create errors which inherit from `GraphqlRails::ExecutionError`
```ruby
class MyCustomError < GraphqlRails::ExecutionError
def to_h
- # this part will be rendered in graphl
+ # this part will be rendered in graphql
{ something_custom: 'yes' }
end
end
class UsersController < GraphqlRails::Controller