Graphql-ruby objects: Difference between revisions
From wikinotes
(Created page with "= Fields = <blockquote> <syntaxhighlight lang="ruby"> class User < GraphQL::Schema::Object field :id, Integer # name, returntype field :age, Integer # name, returntyp...") |
No edit summary |
||
Line 1: | Line 1: | ||
= Fields = | = Fields = | ||
<blockquote> | |||
All objects in graphql are exposed using fields.<br> | |||
Mutations are added as fields to the root <code>Mutation</code> object,<br> | |||
and Queries are added to the root <code>Query</code> object. | |||
== Fields == | |||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="ruby"> | <syntaxhighlight lang="ruby"> | ||
Line 19: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Parametrized Fields --> | </blockquote><!-- Parametrized Fields --> | ||
</blockquote><!-- Fields --> |
Revision as of 21:42, 5 September 2021
Fields
All objects in graphql are exposed using fields.
Mutations are added as fields to the rootMutation
object,
and Queries are added to the rootQuery
object.Fields
class User < GraphQL::Schema::Object field :id, Integer # name, returntype field :age, Integer # name, returntype endParametrized Fields
class MyGraph < GraphQL::Schema::Object field :user, User, do |field| field.argument(:id, Integer, required: true) end end