Created CommentableInterface
This commit is contained in:
@@ -17,4 +17,5 @@ CommentType = GraphQL::ObjectType.define do
|
|||||||
|
|
||||||
# Linked resources
|
# Linked resources
|
||||||
field :user, !UserType, "User who made this comment"
|
field :user, !UserType, "User who made this comment"
|
||||||
|
field :commentable, CommentableInterface, "Element which was commented"
|
||||||
end
|
end
|
||||||
|
|||||||
21
app/graph/types/commentable_interface.rb
Normal file
21
app/graph/types/commentable_interface.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
CommentableInterface = GraphQL::InterfaceType.define do
|
||||||
|
name "Commentable"
|
||||||
|
|
||||||
|
field :id, !types.ID, "ID of the commentable"
|
||||||
|
field :title, types.String, "The title of this commentable"
|
||||||
|
field :description, types.String, "The description of this commentable"
|
||||||
|
field :author_id, types.Int, "ID of the author of this commentable"
|
||||||
|
field :comments_count, types.Int, "Number of comments on this commentable"
|
||||||
|
|
||||||
|
# Linked resources
|
||||||
|
field :author, UserType, "Author of this commentable"
|
||||||
|
field :comments, !types[!CommentType], "Comments in this commentable"
|
||||||
|
field :geozone, GeozoneType, "Geozone affected by this commentable"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Then, object types may include it:
|
||||||
|
CoffeeType = GraphQL::ObjectType.define do
|
||||||
|
# ...
|
||||||
|
interfaces([BeverageInterface])
|
||||||
|
end
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
DebateType = GraphQL::ObjectType.define do
|
DebateType = GraphQL::ObjectType.define do
|
||||||
name "Debate"
|
name "Debate"
|
||||||
description "A single debate entry with associated info"
|
description "A single debate entry with associated info"
|
||||||
|
|
||||||
|
interfaces([CommentableInterface])
|
||||||
|
|
||||||
# Expose fields associated with Debate model
|
# Expose fields associated with Debate model
|
||||||
field :id, !types.ID, "The id of this debate"
|
field :id, !types.ID, "The id of this debate"
|
||||||
field :title, types.String, "The title of this debate"
|
field :title, types.String, "The title of this debate"
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
ProposalType = GraphQL::ObjectType.define do
|
ProposalType = GraphQL::ObjectType.define do
|
||||||
name "Proposal"
|
name "Proposal"
|
||||||
description "A single proposal entry returns a proposal with author, total votes and comments"
|
description "A single proposal entry returns a proposal with author, total votes and comments"
|
||||||
|
|
||||||
|
interfaces([CommentableInterface])
|
||||||
|
|
||||||
# Expose fields associated with Proposal model
|
# Expose fields associated with Proposal model
|
||||||
field :id, !types.ID, "The id of this proposal"
|
field :id, !types.ID, "The id of this proposal"
|
||||||
field :title, types.String, "The title of this proposal"
|
field :title, types.String, "The title of this proposal"
|
||||||
|
|||||||
Reference in New Issue
Block a user