Sha256: 4ae916a4c92c98cb6c357a52dc92ee6778af97bfebf53fbda9c7d674ceb4baff

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Analysis::AST::FieldUsage do
  let(:result) { GraphQL::Analysis::AST.analyze_query(query, [GraphQL::Analysis::AST::FieldUsage]).first }
  let(:query) { GraphQL::Query.new(Dummy::Schema, query_string, variables: variables) }
  let(:variables) { {} }

  describe "query with deprecated fields" do
    let(:query_string) {%|
      query {
        cheese(id: 1) {
          id
          fatContent
        }
      }
    |}

    it "keeps track of used fields" do
      assert_equal ['Cheese.id', 'Cheese.fatContent', 'Query.cheese'], result[:used_fields]
    end

    it "keeps track of deprecated fields" do
      assert_equal ['Cheese.fatContent'], result[:used_deprecated_fields]
    end
  end

  describe "query with deprecated fields used more than once" do
    let(:query_string) {%|
      query {
        cheese1: cheese(id: 1) {
          id
          fatContent
        }

        cheese2: cheese(id: 2) {
          id
          fatContent
        }
      }
    |}

    it "omits duplicate usage of a field" do
      assert_equal ['Cheese.id', 'Cheese.fatContent', 'Query.cheese'], result[:used_fields]
    end

    it "omits duplicate usage of a deprecated field" do
      assert_equal ['Cheese.fatContent'], result[:used_deprecated_fields]
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql-1.9.11 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.10 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.9 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.8 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.7 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.6 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.5 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.4 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.3 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.2 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.1 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.0 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.0.pre4 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.0.pre3 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.0.pre2 spec/graphql/analysis/ast/field_usage_spec.rb
graphql-1.9.0.pre1 spec/graphql/analysis/ast/field_usage_spec.rb