Sha256: 43b3f90f8f83a6524063afe562409bf17d698f42eb8156a206a25f178bd36800

Contents?: true

Size: 761 Bytes

Versions: 32

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    # This module's job is to extend the API with custom fields related to
    # decidim-comments.
    module QueryExtensions
      # Public: Extends a type with `decidim-comments`'s fields.
      #
      # type - A GraphQL::BaseType to extend.
      #
      # Returns nothing.
      def self.define(type)
        type.field :commentable do
          type !CommentableType

          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
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
decidim-comments-0.13.1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.12.2 lib/decidim/comments/query_extensions.rb
decidim-comments-0.13.0 lib/decidim/comments/query_extensions.rb
decidim-comments-0.12.1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.13.0.pre1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.12.0 lib/decidim/comments/query_extensions.rb
decidim-comments-0.11.2 lib/decidim/comments/query_extensions.rb
decidim-comments-0.12.0.pre lib/decidim/comments/query_extensions.rb
decidim-comments-0.11.1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.11.0.pre1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.10.1 lib/decidim/comments/query_extensions.rb
decidim-comments-0.10.0 lib/decidim/comments/query_extensions.rb