Sha256: a0aafa8c94d23e048ee2c281c2e7979c8a02690a0ff346029beae0776ce9b84f
Contents?: true
Size: 1.01 KB
Versions: 6
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'active_support/core_ext/module/attr_internal' module Rails # :nodoc: module GraphQL # :nodoc: # = GraphQL Controller Runtime # # Tool that calculates the runtime of a GraphQL operation. This works # similar to how Rails ActiveRecord calculate its execution time while # performing a request. module ControllerRuntime extend ActiveSupport::Concern module ClassMethods # :nodoc: all def log_process_action(payload) messages, gql_runtime = super, payload[:gql_runtime] messages << format('GraphQL: %.1fms', gql_runtime.to_f) if gql_runtime messages end end private attr_internal :gql_runtime def process_action(*) LogSubscriber.runtime = 0 super end def append_info_to_payload(payload) super payload[:gql_runtime] = LogSubscriber.runtime \ if (LogSubscriber.runtime || 0).positive? end end end end
Version data entries
6 entries across 6 versions & 1 rubygems