Module: Decidim::Comments::MutationExtensions
- Defined in:
- lib/decidim/comments/mutation_extensions.rb
Overview
This module’s job is to extend the API with custom fields related to decidim-comments.
Class Method Summary collapse
-
.extend!(type) ⇒ Object
Public: Extends a type with ‘decidim-comments`’s fields.
Class Method Details
.extend!(type) ⇒ Object
Public: Extends a type with ‘decidim-comments`’s fields.
type - A GraphQL::BaseType to extend.
Returns nothing.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/decidim/comments/mutation_extensions.rb', line 13 def self.extend!(type) type.define do field :commentable, Decidim::Comments::CommentableMutationType do description "A commentable" argument :id, !types.String, "The commentable's ID" argument :type, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`" resolve lambda { |_obj, args, _ctx| args[:type].constantize.find(args[:id]) } end field :comment, Decidim::Comments::CommentMutationType do description "A comment" argument :id, !types.ID, "The comment's id" resolve lambda { |_obj, args, _ctx| Comment.find(args["id"]) } end end end |