Module: GraphQL::Language

Included in:
InternalRepresentation::Rewrite, StaticValidation::DirectivesAreInValidLocations
Defined in:
lib/graphql/language.rb,
lib/graphql/language/lexer.rb,
lib/graphql/language/nodes.rb,
lib/graphql/language/token.rb,
lib/graphql/language/parser.rb,
lib/graphql/language/visitor.rb,
lib/graphql/language/comments.rb,
lib/graphql/language/generation.rb,
lib/graphql/language/definition_slice.rb

Defined Under Namespace

Modules: Comments, DefinitionSlice, Generation, Lexer, Nodes Classes: Parser, Token, Visitor

Class Method Summary collapse

Class Method Details

.serialize(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/graphql/language.rb', line 14

def self.serialize(value)
  if value.is_a?(Hash)
    serialized_hash = value.map do |k, v|
      "#{k}:#{serialize v}"
    end.join(",")

    "{#{serialized_hash}}"
  elsif value.is_a?(Array)
    serialized_array = value.map do |v|
      serialize v
    end.join(",")

    "[#{serialized_array}]"
  else
    JSON.generate(value, quirks_mode: true)
  end
end