wmaciejak/rails_rom_graphql_clean_architecture_boilerplate

View on GitHub
app/graphql/query_types/comment.rb

Summary

Maintainability
A
1 hr
Test Coverage
# frozen_string_literal: true

module QueryTypes
  Comment = GraphQL::ObjectType.define do
    field :comment do
      type CommentType
      argument :id, !types.ID
      description "Find a Comment by ID"
      resolve ->(_obj, args, _ctx) { Container.instance["repositories.comment"].one(args["id"]) }
    end

    field :comments do
      type !types[CommentType]
      resolve ->(_obj, _args, _ctx) { Container.instance["repositories.comment"].to_a }
    end
  end
end