QueryRoot now returns proposals, comment(:id) and comments

This commit is contained in:
Alberto Miedes Garcés
2016-09-29 13:11:34 +02:00
parent de913c5536
commit 6a3f7d725c

View File

@@ -10,4 +10,29 @@ QueryRoot = GraphQL::ObjectType.define do
Proposal.find(arguments["id"])
}
end
field :proposals do
type types[ProposalType]
description "Find all Proposals"
resolve -> (object, arguments, context) {
Proposal.all
}
end
field :comment do
type CommentType
description "Find a Comment by id"
argument :id, !types.ID
resolve -> (object, arguments, context) {
Comment.find(arguments["id"])
}
end
field :comments do
type types[CommentType]
description "Find all Comments"
resolve -> (object, arguments, context) {
Comment.all
}
end
end