Sha256: 55b5d9496430e99919b09899fe2d0506bc6cfd1987252350784a2967a308879d
Contents?: true
Size: 736 Bytes
Versions: 2
Compression:
Stored size: 736 Bytes
Contents
# frozen_string_literal: true module GraphQL module Client module Query Argument = Struct.new(:value) do def to_query case value when FalseClass, Float, Integer, NilClass, String, TrueClass generate_query_value(value) when Array "[#{value.map { |v| generate_query_value(v) }.join(', ')}]" when Hash "{ #{value.map { |k, v| "#{k}: #{generate_query_value(v)}" }.join(', ')} }" end end private def generate_query_value(value) if value.to_s.start_with?('$') value else JSON.generate(value, quirks_mode: true) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql_client-0.4.1 | lib/graphql_client/query/argument.rb |
graphql_client-0.3.3 | lib/graphql_client/query/argument.rb |