Class: ApolloUploadServer::GraphQLDataBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/apollo_upload_server/graphql_data_builder.rb

Constant Summary collapse

OutOfBounds =
Class.new(ArgumentError)

Instance Method Summary collapse

Constructor Details

#initialize(strict_mode: false) ⇒ GraphQLDataBuilder

Returns a new instance of GraphQLDataBuilder.



10
11
12
# File 'lib/apollo_upload_server/graphql_data_builder.rb', line 10

def initialize(strict_mode: false)
  @strict_mode = strict_mode
end

Instance Method Details

#call(params) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/apollo_upload_server/graphql_data_builder.rb', line 14

def call(params)
  operations = safe_json_parse(params['operations'])
  file_mapper = safe_json_parse(params['map'])

  return nil if operations.nil? || file_mapper.nil?
  if operations.is_a?(Hash)
    single_transformation(file_mapper, operations, params)
  else
    { '_json' => multiple_transformation(file_mapper, operations, params) }
  end
end