Skip to content

Commit 8570a8e

Browse files
Update input_objects.md
1 parent a2cebbd commit 8570a8e

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

guides/type_definitions/input_objects.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,23 @@ Input objects are passed to field methods as an instance of their definition cla
6262
- calling `#[]` with the _camel-cased_ name of the argument (this is for compatibility with previous GraphQL-Ruby versions)
6363

6464
```ruby
65-
# This field takes an argument called `attributes`
66-
# which will be an instance of `PostAttributes`
67-
field :create_post, Types::Post, null: false do
68-
argument :attributes, Types::PostAttributes
69-
end
65+
class Types::MutationType < GraphQL::Schema::Object
66+
# This field takes an argument called `attributes`
67+
# which will be an instance of `PostAttributes`
68+
field :create_post, Types::Post, null: false do
69+
argument :attributes, Types::PostAttributes
70+
end
7071

71-
def create_post(attributes:)
72-
puts attributes.class.name
73-
# => "Types::PostAttributes"
74-
# Access a value by method (underscore-cased):
75-
puts attributes.full_text
76-
# => "This is my first post"
77-
# Or by hash-style lookup (camel-cased, for compatibility):
78-
puts attributes[:fullText]
79-
# => "This is my first post"
72+
def create_post(attributes:)
73+
puts attributes.class.name
74+
# => "Types::PostAttributes"
75+
# Access a value by method (underscore-cased):
76+
puts attributes.full_text
77+
# => "This is my first post"
78+
# Or by hash-style lookup (camel-cased, for compatibility):
79+
puts attributes[:fullText]
80+
# => "This is my first post"
81+
end
8082
end
8183
```
8284

0 commit comments

Comments
 (0)