echo_resolver.rb 425 Bytes
Newer Older
1 2 3 4
# frozen_string_literal: true

module Resolvers
  class EchoResolver < BaseResolver
charlie ablett's avatar
charlie ablett committed
5
    type ::GraphQL::STRING_TYPE, null: false
6 7
    description 'Testing endpoint to validate the API with'

8 9 10
    argument    :text, GraphQL::STRING_TYPE, required: true,
                description: 'Text to echo back'

charlie ablett's avatar
charlie ablett committed
11 12
    def resolve(text:)
      username = current_user&.username
13

charlie ablett's avatar
charlie ablett committed
14
      "#{username.inspect} says: #{text}"
15 16 17
    end
  end
end