Skip to content

Commit

Permalink
Merge pull request #521 from bookreport/updated-with-bens-fix
Browse files Browse the repository at this point in the history
Compare all args when testing for Overlapping Fields
  • Loading branch information
chris-ramon authored Feb 5, 2020
2 parents 59637ea + 319cd87 commit c532893
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rules_known_argument_names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgsWithSuggestions(
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "ddogCommand" on field "doesKnowCommand" of type "Dog". `+
`Did you mean "dogCommand"?`, 3, 25),
`Did you mean "dogCommand" or "nextDogCommand"?`, 3, 25),
})
}
func TestValidate_KnownArgumentNames_UnknownArgsDeeply(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rules_overlapping_fields_can_be_merged.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ func sameArguments(args1 []*ast.Argument, args2 []*ast.Argument) bool {
}
if arg1Name == arg2Name {
foundArgs2 = arg2
break
}
break
}
if foundArgs2 == nil {
return false
Expand Down
8 changes: 8 additions & 0 deletions rules_overlapping_fields_can_be_merged_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func TestValidate_OverlappingFieldsCanBeMerged_IdenticalFieldsWithIdenticalArgs(
}
`)
}
func TestValidate_OverlappingFieldsCanBeMerged_IdenticalFieldsWithMultipleIdenticalArgs(t *testing.T) {
testutil.ExpectPassesRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
fragment mergeIdenticalFieldsWithIdenticalArgs on Dog {
doesKnowCommand(dogCommand: SIT nextDogCommand: DOWN)
doesKnowCommand(dogCommand: SIT nextDogCommand: DOWN)
}
`)
}
func TestValidate_OverlappingFieldsCanBeMerged_IdenticalFieldsWithIdenticalDirectives(t *testing.T) {
testutil.ExpectPassesRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
fragment mergeSameFieldsWithSameDirectives on Dog {
Expand Down
3 changes: 3 additions & 0 deletions testutil/rules_test_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func init() {
"dogCommand": &graphql.ArgumentConfig{
Type: dogCommandEnum,
},
"nextDogCommand": &graphql.ArgumentConfig{
Type: dogCommandEnum,
},
},
},
"isHousetrained": &graphql.Field{
Expand Down

0 comments on commit c532893

Please sign in to comment.