Sha256: a8cf8b9b36cfb9eef8f8aeffe7f86b31493b37c3c47566138f2029be446c1dbf
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 KB
Contents
require 'spec_helper' describe GraphQL::StaticValidation::FieldsWillMerge do let(:query_string) {" query getCheese($sourceVar: DairyAnimal!) { cheese(id: 1) { id, nickname: name, nickname: fatContent, fatContent differentLevel: fatContent similarCheese(source: $sourceVar) similarCow: similarCheese(source: COW) { similarCowSource: source, differentLevel: fatContent } ...cheeseFields ... on Cheese { fatContent: name similarCheese(source: SHEEP) } } } fragment cheeseFields on Cheese { fatContent, similarCow: similarCheese(source: COW) { similarCowSource: id, id } id @someFlag } "} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FieldsWillMerge]) } let(:query) { GraphQL::Query.new(DummySchema, query_string) } let(:errors) { validator.validate(query) } let(:error_messages) { errors.map { |e| e["message" ] }} it 'finds field naming conflicts' do expected_errors = [ "Field 'id' has a directive conflict: [] or [someFlag]?", # different directives "Field 'id' has a directive argument conflict: [] or [{}]?", # not sure this is a great way to handle it but here we are! "Field 'nickname' has a field conflict: name or fatContent?", # alias conflict in query "Field 'fatContent' has a field conflict: fatContent or name?", # alias/name conflict in query and fragment "Field 'similarCheese' has an argument conflict: {\"source\":\"sourceVar\"} or {\"source\":\"SHEEP\"}?", # different arguments "Field 'similarCowSource' has a field conflict: source or id?", # nested conflict ] assert_equal(expected_errors, error_messages) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.12.1 | spec/graphql/static_validation/rules/fields_will_merge_spec.rb |
graphql-0.12.0 | spec/graphql/static_validation/rules/fields_will_merge_spec.rb |