class RSpec::GraphqlAssistant::QueryBuilder

Attributes

input_args[R]
name[R]
resp_args[R]
type[R]

Public Class Methods

new(type, name, input_args, resp_args) click to toggle source
# File lib/rspec/graphql_assistant/query_builder.rb, line 5
def initialize(type, name, input_args, resp_args)
  @type = type
  @name = name
  @input_args = input_args
  @resp_args = resp_args
end

Public Instance Methods

call() click to toggle source
# File lib/rspec/graphql_assistant/query_builder.rb, line 13
def call
  template % {type: type, name: name, input_args: transform_input_args(input_args), resp_args: transform_resp_args(resp_args)}
end

Private Instance Methods

template() click to toggle source
# File lib/rspec/graphql_assistant/query_builder.rb, line 28
      def template
        <<-GQL
%{type} {
 %{name}%{input_args} {
  %{resp_args}
 }
}
        GQL
      end
transform_input_args(args) click to toggle source
# File lib/rspec/graphql_assistant/query_builder.rb, line 19
def transform_input_args(args)
  return if args.blank?
  "(#{ArgumentBuilder.new(args).call})"
end
transform_resp_args(args) click to toggle source
# File lib/rspec/graphql_assistant/query_builder.rb, line 24
def transform_resp_args(args)
  ResponseBuilder.new(args).call
end