Skip to content

Commit

Permalink
Add a Link type & the allLinks resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaspar committed Jul 30, 2017
1 parent 8a948ba commit 378aa82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/graphql/graphql_tutorial_schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GraphqlTutorialSchema = GraphQL::Schema.define do
mutation(Types::MutationType)
# mutation(Types::MutationType)
query(Types::QueryType)
end
7 changes: 7 additions & 0 deletions app/graphql/types/link_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Types::LinkType = GraphQL::ObjectType.define do
name 'Link'

field :id, !types.ID
field :url, !types.String
field :description, !types.String
end
8 changes: 2 additions & 6 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
# Add root-level fields here.
# They will be entry points for queries on your schema.

# TODO: remove me
field :testField, types.String do
description "An example field added by the generator"
resolve ->(obj, args, ctx) {
"Hello World!"
}
field :allLinks, !types[Types::LinkType] do
resolve -> (obj, args, ctx) { Link.all }
end
end

0 comments on commit 378aa82

Please sign in to comment.