Sha256: b92f09865f97f541dbfaa835fe0102afff9e8139e6fce7c15e99efeea2ee91e3

Contents?: true

Size: 1.69 KB

Versions: 7

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Tracing::SkylightTracing do
  module SkylightTest
    class Query < GraphQL::Schema::Object
      field :int, Integer, null: false

      def int
        1
      end
    end

    class SchemaWithoutTransactionName < GraphQL::Schema
      query(Query)
      use(GraphQL::Tracing::SkylightTracing)
    end

    class SchemaWithTransactionName < GraphQL::Schema
      query(Query)
      use(GraphQL::Tracing::SkylightTracing, set_endpoint_name: true)
    end

    class SchemaWithScalarTrace < GraphQL::Schema
      query(Query)
      use(GraphQL::Tracing::SkylightTracing, trace_scalars: true)
    end
  end

  before do
    Skylight.clear_all
  end

  it "can leave the transaction name in place" do
    SkylightTest::SchemaWithoutTransactionName.execute "query X { int }"
    assert_equal [], Skylight::ENDPOINT_NAMES
  end

  it "can override the transaction name" do
    SkylightTest::SchemaWithTransactionName.execute "query X { int }"
    assert_equal ["GraphQL/query.X"], Skylight::ENDPOINT_NAMES
  end

  it "can override the transaction name per query" do
    # Override with `false`
    SkylightTest::SchemaWithTransactionName.execute "{ int }", context: { set_skylight_endpoint_name: false }
    assert_equal [], Skylight::ENDPOINT_NAMES
    # Override with `true`
    SkylightTest::SchemaWithoutTransactionName.execute "{ int }", context: { set_skylight_endpoint_name: true }
    assert_equal ["GraphQL/query.<anonymous>"], Skylight::ENDPOINT_NAMES
  end

  it "traces scalars when trace_scalars is true" do
    SkylightTest::SchemaWithScalarTrace.execute "query X { int }"
    assert_includes Skylight::TITLE_NAMES, "graphql.Query.int"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
graphql-1.8.18 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.17 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.16 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.15 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.14 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.13 spec/graphql/tracing/skylight_tracing_spec.rb
graphql-1.8.12 spec/graphql/tracing/skylight_tracing_spec.rb