File: legacy_trace.rb

package info (click to toggle)
ruby-graphql 2.2.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,584 kB
  • sloc: ruby: 67,505; ansic: 1,753; yacc: 831; javascript: 331; makefile: 6
file content (69 lines) | stat: -rw-r--r-- 2,834 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
module GraphQL
  module Tracing
    # This trace class calls legacy-style tracer with payload hashes.
    # New-style `trace_with` modules significantly reduce the overhead of tracing,
    # but that advantage is lost when legacy-style tracers are also used (since the payload hashes are still constructed).
    module CallLegacyTracers
      def lex(query_string:)
        (@multiplex || @query).trace("lex", { query_string: query_string }) { super }
      end

      def parse(query_string:)
        (@multiplex || @query).trace("parse", { query_string: query_string }) { super }
      end

      def validate(query:, validate:)
        query.trace("validate", { validate: validate, query: query }) { super }
      end

      def analyze_multiplex(multiplex:)
        multiplex.trace("analyze_multiplex", { multiplex: multiplex }) { super }
      end

      def analyze_query(query:)
        query.trace("analyze_query", { query: query }) { super }
      end

      def execute_multiplex(multiplex:)
        multiplex.trace("execute_multiplex", { multiplex: multiplex }) { super }
      end

      def execute_query(query:)
        query.trace("execute_query", { query: query }) { super }
      end

      def execute_query_lazy(query:, multiplex:)
        multiplex.trace("execute_query_lazy", { multiplex: multiplex, query: query }) { super }
      end

      def execute_field(field:, query:, ast_node:, arguments:, object:)
        query.trace("execute_field", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }) { super }
      end

      def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
        query.trace("execute_field_lazy", { field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, owner: field.owner, path: query.context[:current_path] }) { super }
      end

      def authorized(query:, type:, object:)
        query.trace("authorized", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
      end

      def authorized_lazy(query:, type:, object:)
        query.trace("authorized_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
      end

      def resolve_type(query:, type:, object:)
        query.trace("resolve_type", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
      end

      def resolve_type_lazy(query:, type:, object:)
        query.trace("resolve_type_lazy", { context: query.context, type: type, object: object, path: query.context[:current_path] }) { super }
      end
    end

    class LegacyTrace < Trace
      include CallLegacyTracers
    end
  end
end