Sha256: a4e9a9046b44aa7ffdd3f87b1ff9d051383796b8f9c1f3ef099edf29a3faaea6

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Tracing::ActiveSupportNotificationsTracing do
  before do
    GraphQL::Tracing.install(GraphQL::Tracing::ActiveSupportNotificationsTracing)
  end

  after do
    GraphQL::Tracing.uninstall(GraphQL::Tracing::ActiveSupportNotificationsTracing)
  end

  it "pushes through AS::N" do
    traces = []

    callback = ->(name, started, finished, id, data) {
      traces << name
    }

    query_string = <<-GRAPHQL
    query Bases($id1: ID!, $id2: ID!){
      b1: batchedBase(id: $id1) { name }
      b2: batchedBase(id: $id2) { name }
    }
    GRAPHQL
    first_id = StarWars::Base.first.id
    last_id = StarWars::Base.last.id

    ActiveSupport::Notifications.subscribed(callback, /^graphql/) do
      star_wars_query(query_string, {
        "id1" => first_id,
        "id2" => last_id,
      })
    end

    expected_traces = [
      "graphql.lex",
      "graphql.parse",
      "graphql.validate",
      "graphql.analyze_query",
      "graphql.analyze_multiplex",
      "graphql.execute_field",
      "graphql.execute_field",
      "graphql.execute_query",
      "graphql.lazy_loader",
      "graphql.execute_field",
      "graphql.execute_field_lazy",
      "graphql.execute_field",
      "graphql.execute_field_lazy",
      "graphql.execute_field_lazy",
      "graphql.execute_field_lazy",
      "graphql.execute_query_lazy",
      "graphql.execute_multiplex",
    ]
    assert_equal expected_traces, traces
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
graphql-1.7.3 spec/graphql/tracing/active_support_notifications_tracing_spec.rb
graphql-1.7.2 spec/graphql/tracing/active_support_notifications_tracing_spec.rb
graphql-1.7.1 spec/graphql/tracing/active_support_notifications_tracing_spec.rb
graphql-1.7.0 spec/graphql/tracing/active_support_notifications_tracing_spec.rb