-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiler incorrectly reports missing required fields (#4123)
Summary: Resolves #4122 Hi, I stumbled across this error when I misremembered the an enum variant and got a weird error. Took me awhile to figure out the issue because the compiler error was wrong. I've added tests for both orderings & for the constant & variable cases. Let me know if there's any other tests you'd like updating 😄 Pull Request resolved: #4123 Reviewed By: davidmccabe Differential Revision: D41266571 Pulled By: alunyov fbshipit-source-id: 9a76211a8fa8b7a637693f65a76f58ba4eef5ab3
- Loading branch information
1 parent
fa0a3a6
commit ce5e1ed
Showing
6 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...phql-ir/tests/parse/fixtures/complex-object-with-invalid-constant-fields.invalid.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
==================================== INPUT ==================================== | ||
# expected-to-throw | ||
mutation LikeMutation { | ||
feedbackLikeStrict(input: { | ||
feedbackId: false | ||
userID: "some-user-id" | ||
}) { | ||
__typename | ||
} | ||
} | ||
|
||
mutation LikeMutationReverse { | ||
feedbackLikeStrict(input: { | ||
userID: "some-user-id" | ||
feedbackId: false | ||
}) { | ||
__typename | ||
} | ||
} | ||
==================================== ERROR ==================================== | ||
✖︎ Expected a value of type 'ID' | ||
|
||
complex-object-with-invalid-constant-fields.invalid.graphql:4:17 | ||
3 │ feedbackLikeStrict(input: { | ||
4 │ feedbackId: false | ||
│ ^^^^^ | ||
5 │ userID: "some-user-id" | ||
|
||
|
||
✖︎ Expected a value of type 'ID' | ||
|
||
complex-object-with-invalid-constant-fields.invalid.graphql:14:17 | ||
13 │ userID: "some-user-id" | ||
14 │ feedbackId: false | ||
│ ^^^^^ | ||
15 │ }) { |
19 changes: 19 additions & 0 deletions
19
...aphql-ir/tests/parse/fixtures/complex-object-with-invalid-constant-fields.invalid.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# expected-to-throw | ||
mutation LikeMutation { | ||
feedbackLikeStrict(input: { | ||
feedbackId: false | ||
userID: "some-user-id" | ||
}) { | ||
__typename | ||
} | ||
} | ||
|
||
mutation LikeMutationReverse { | ||
feedbackLikeStrict(input: { | ||
userID: "some-user-id" | ||
feedbackId: false | ||
}) { | ||
__typename | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
...rates/graphql-ir/tests/parse/fixtures/complex-object-with-invalid-fields.invalid.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
==================================== INPUT ==================================== | ||
# expected-to-throw | ||
mutation LikeMutation($feedbackId: ID! $userID: String!) { | ||
feedbackLikeStrict(input: { | ||
userID: $userID | ||
feedbackId: $feedbackId | ||
}) { | ||
__typename | ||
} | ||
} | ||
|
||
mutation LikeMutationReverse($feedbackId: ID! $userID: String!) { | ||
feedbackLikeStrict(input: { | ||
feedbackId: $feedbackId | ||
userID: $userID | ||
}) { | ||
__typename | ||
} | ||
} | ||
==================================== ERROR ==================================== | ||
✖︎ Variable was defined as type 'String!' but used where a variable of type 'ID!' is expected. | ||
|
||
complex-object-with-invalid-fields.invalid.graphql:4:13 | ||
3 │ feedbackLikeStrict(input: { | ||
4 │ userID: $userID | ||
│ ^^^^^^^ | ||
5 │ feedbackId: $feedbackId | ||
|
||
|
||
✖︎ Variable was defined as type 'String!' but used where a variable of type 'ID!' is expected. | ||
|
||
complex-object-with-invalid-fields.invalid.graphql:14:13 | ||
13 │ feedbackId: $feedbackId | ||
14 │ userID: $userID | ||
│ ^^^^^^^ | ||
15 │ }) { |
18 changes: 18 additions & 0 deletions
18
...crates/graphql-ir/tests/parse/fixtures/complex-object-with-invalid-fields.invalid.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# expected-to-throw | ||
mutation LikeMutation($feedbackId: ID! $userID: String!) { | ||
feedbackLikeStrict(input: { | ||
userID: $userID | ||
feedbackId: $feedbackId | ||
}) { | ||
__typename | ||
} | ||
} | ||
|
||
mutation LikeMutationReverse($feedbackId: ID! $userID: String!) { | ||
feedbackLikeStrict(input: { | ||
feedbackId: $feedbackId | ||
userID: $userID | ||
}) { | ||
__typename | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters