lib/graphql/tracing/platform_tracing.rb in graphql-1.13.12 vs lib/graphql/tracing/platform_tracing.rb in graphql-1.13.13
- old
+ new
@@ -8,10 +8,14 @@
# - `#platform_field_key(type, field)`
# @api private
class PlatformTracing
class << self
attr_accessor :platform_keys
+
+ def inherited(child_class)
+ child_class.platform_keys = self.platform_keys
+ end
end
def initialize(options = {})
@options = options
@platform_keys = self.class.platform_keys
@@ -39,11 +43,11 @@
true
end
platform_key = if trace_field
context = data.fetch(:query).context
- cached_platform_key(context, field) { platform_field_key(data[:owner], field) }
+ cached_platform_key(context, field, :field) { platform_field_key(data[:owner], field) }
else
nil
end
end
@@ -55,18 +59,18 @@
yield
end
when "authorized", "authorized_lazy"
type = data.fetch(:type)
context = data.fetch(:context)
- platform_key = cached_platform_key(context, type) { platform_authorized_key(type) }
+ platform_key = cached_platform_key(context, type, :authorized) { platform_authorized_key(type) }
platform_trace(platform_key, key, data) do
yield
end
when "resolve_type", "resolve_type_lazy"
type = data.fetch(:type)
context = data.fetch(:context)
- platform_key = cached_platform_key(context, type) { platform_resolve_type_key(type) }
+ platform_key = cached_platform_key(context, type, :resolve_type) { platform_resolve_type_key(type) }
platform_trace(platform_key, key, data) do
yield
end
else
# it's a custom key
@@ -133,10 +137,10 @@
# So, they can all share one cache.
#
# If the key isn't present, the given block is called and the result is cached for `key`.
#
# @return [String]
- def cached_platform_key(ctx, key)
+ def cached_platform_key(ctx, key, trace_phase)
cache = ctx.namespace(self.class)[:platform_key_cache] ||= {}
cache.fetch(key) { cache[key] = yield }
end
end
end