lib/graphql/language/nodes.rb in graphql-1.9.8 vs lib/graphql/language/nodes.rb in graphql-1.9.9
- old
+ new
@@ -71,19 +71,26 @@
def position
[line, col]
end
def to_query_string(printer: GraphQL::Language::Printer.new)
- printer.print(self)
+ if printer.is_a?(GraphQL::Language::Printer)
+ @query_string ||= printer.print(self)
+ else
+ printer.print(self)
+ end
end
# This creates a copy of `self`, with `new_options` applied.
# @param new_options [Hash]
# @return [AbstractNode] a shallow copy of `self`
def merge(new_options)
copied_self = dup
new_options.each do |key, value|
copied_self.instance_variable_set(:"@#{key}", value)
+ if copied_self.instance_variable_defined?(:@query_string)
+ copied_self.instance_variable_set(:@query_string, nil)
+ end
end
copied_self
end
# Copy `self`, but modify the copy so that `previous_child` is replaced by `new_child`