Sha256: a7ea278b2056edc2c2ff464d696cc76dd70b37bc70ae9a5d59fcbe765608d480
Contents?: true
Size: 1.56 KB
Versions: 18
Compression:
Stored size: 1.56 KB
Contents
require "spec_helper" describe GraphQL::Analysis::FieldUsage do let(:result) { [] } let(:field_usage_analyzer) { GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fields| result << query << used_fields << used_deprecated_fields } } let(:reduce_result) { GraphQL::Analysis.analyze_query(query, [field_usage_analyzer]) } let(:query) { GraphQL::Query.new(DummySchema, query_string, variables: variables) } let(:variables) { {} } describe "query with deprecated fields" do let(:query_string) {%| query { cheese(id: 1) { id fatContent } } |} it "returns query in reduced result" do reduce_result assert_equal query, result[0] end it "keeps track of used fields" do reduce_result assert_equal ['Cheese.id', 'Cheese.fatContent', 'Query.cheese'], result[1] end it "keeps track of deprecated fields" do reduce_result assert_equal ['Cheese.fatContent'], result[2] 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 reduce_result assert_equal ['Cheese.id', 'Cheese.fatContent', 'Query.cheese'], result[1] end it "omits duplicate usage of a deprecated field" do reduce_result assert_equal ['Cheese.fatContent'], result[2] end end end
Version data entries
18 entries across 18 versions & 1 rubygems