Class: GraphWeaver::Testing::Anonymizer

Inherits:
Object
  • Object
show all
Includes:
Selection
Defined in:
lib/graph_weaver/testing/cassette.rb

Overview

Rewrites a recorded response through the Values engine: same shape, fake values. Enums, booleans, __typename, and null positions are preserved; ids map consistently so relationships survive.

Instance Method Summary collapse

Methods included from Selection

#each_field, #gather, #load_operation, #operation_root_type

Constructor Details

#initialize(schema:, seed: nil, mode: nil) ⇒ Anonymizer

Returns a new instance of Anonymizer.



164
165
166
167
# File 'lib/graph_weaver/testing/cassette.rb', line 164

def initialize(schema:, seed: nil, mode: nil)
  @schema = schema
  @values = Values.new(seed:, mode:)
end

Instance Method Details

#anonymize(query, data) ⇒ Object



169
170
171
172
173
# File 'lib/graph_weaver/testing/cassette.rb', line 169

def anonymize(query, data)
  operation = load_operation(query)

  object_value(operation_root_type(operation), operation.selections, data)
end