-
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.
add test that field args are dropped from scalar relay resolvers duri…
…ng transform Summary: ## Context When compiling relay resolvers we are missing validation on undefined global variables within resolvers. The global variables can be passed via resolver field or fragment arguments. We want to check whether the relay_resolvers transform is dropping field arguments for relay resolvers without a fragment attached + returning a scalar value. ## This diff Adds a test on the relay_resolvers transform to verify the above. Add a test that field arguments are dropped from scalar relay resolvers during the `relay_resolvers` transform step and added to the `RelayResolverMetadata`. Reviewed By: voideanvalue Differential Revision: D50624879 fbshipit-source-id: bdce4180f79b409271100d5810bcc7b0c8523bc2
- Loading branch information
1 parent
1f69c0a
commit 5c835e9
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...-transforms/tests/relay_resolvers/fixtures/relay-resolver-scalar-field-arguments.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,43 @@ | ||
==================================== INPUT ==================================== | ||
fragment Foo_user on User { | ||
pop_star_name(field_arg: 2) | ||
} | ||
|
||
# %extensions% | ||
|
||
extend type User { | ||
pop_star_name(field_arg: Int): String @relay_resolver(import_path: "PopStarNameResolver") | ||
} | ||
==================================== OUTPUT =================================== | ||
fragment Foo_user on User { | ||
__id @__RelayResolverMetadata | ||
# RelayResolverMetadata { | ||
# field_id: FieldID(516), | ||
# import_path: "PopStarNameResolver", | ||
# import_name: None, | ||
# field_alias: None, | ||
# field_path: "pop_star_name", | ||
# field_arguments: [ | ||
# Argument { | ||
# name: WithLocation { | ||
# location: relay-resolver-scalar-field-arguments.graphql:44:53, | ||
# item: ArgumentName( | ||
# "field_arg", | ||
# ), | ||
# }, | ||
# value: WithLocation { | ||
# location: relay-resolver-scalar-field-arguments.graphql:55:56, | ||
# item: Constant( | ||
# Int( | ||
# 2, | ||
# ), | ||
# ), | ||
# }, | ||
# }, | ||
# ], | ||
# live: false, | ||
# output_type_info: Legacy, | ||
# fragment_data_injection_mode: None, | ||
# } | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...y-transforms/tests/relay_resolvers/fixtures/relay-resolver-scalar-field-arguments.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,9 @@ | ||
fragment Foo_user on User { | ||
pop_star_name(field_arg: 2) | ||
} | ||
|
||
# %extensions% | ||
|
||
extend type User { | ||
pop_star_name(field_arg: Int): String @relay_resolver(import_path: "PopStarNameResolver") | ||
} |
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