-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[relay] Show a helpful error if a resolver returns an interface with no implementors #4428
Closed
Closed
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bf6123f
[relay] Show a helpful error if a resolver returns an interface with …
0e07c43
Update client-edge-to-client-interface test
0059bba
Merge branch 'main' of https://github.com/facebook/relay into resolvers
74bb8ab
address suggestions
a86d3e9
delete @outputType from error msg
f9f7f13
fix tests
d13a43c
cargo test
83b6250
Merge branch 'main' of https://github.com/facebook/relay into resolvers
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...xtures/relay-resolver-edge-to-interface-with-child-interface-and-no-implementors.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 ==================================== | ||
# expected-to-throw | ||
query relayResolverEdgeToInterfaceWithChildInterfaceAndNoImplementorsQuery { | ||
resolver_field { | ||
name | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
""" | ||
An interface with no concrete implementors | ||
""" | ||
interface SomeInterface { | ||
name: String | ||
} | ||
|
||
interface ChildInterface implements SomeInterface { | ||
name: String | ||
age: Int | ||
} | ||
|
||
extend type Query { | ||
resolver_field: SomeInterface | ||
@relay_resolver(import_path: "./path/to/Resolver.js") | ||
} | ||
==================================== ERROR ==================================== | ||
✖︎ Client Edges that reference client-defined interface types are not currently supported in Relay. | ||
|
||
relay-resolver-edge-to-interface-with-child-interface-and-no-implementors.graphql:3:3 | ||
2 │ query relayResolverEdgeToInterfaceWithChildInterfaceAndNoImplementorsQuery { | ||
3 │ resolver_field { | ||
│ ^^^^^^^^^^^^^^ | ||
4 │ name | ||
|
||
|
||
✖︎ No types implement the client interface SomeInterface. Interfaces returned by a @RelayResolver @outputType must have at least one concrete implementation. | ||
|
||
<generated>:2:44 | ||
1 │ # expected-to-throw | ||
2 │ query relayResolverEdgeToInterfaceWithChildInterfaceAndNoImplementorsQuery { | ||
│ ^^^^^^^^^^^^^ | ||
3 │ resolver_field { |
25 changes: 25 additions & 0 deletions
25
...ixtures/relay-resolver-edge-to-interface-with-child-interface-and-no-implementors.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,25 @@ | ||
# expected-to-throw | ||
query relayResolverEdgeToInterfaceWithChildInterfaceAndNoImplementorsQuery { | ||
resolver_field { | ||
name | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
""" | ||
An interface with no concrete implementors | ||
""" | ||
interface SomeInterface { | ||
name: String | ||
} | ||
|
||
interface ChildInterface implements SomeInterface { | ||
name: String | ||
age: Int | ||
} | ||
|
||
extend type Query { | ||
resolver_field: SomeInterface | ||
@relay_resolver(import_path: "./path/to/Resolver.js") | ||
} |
38 changes: 38 additions & 0 deletions
38
...e_relay_artifacts/fixtures/relay-resolver-edge-to-interface-with-no-implementors.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,38 @@ | ||
==================================== INPUT ==================================== | ||
# expected-to-throw | ||
query relayResolverEdgeToInterfaceWithNoImplementorsQuery { | ||
resolver_field { | ||
name | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
""" | ||
An interface with no implementors | ||
""" | ||
interface SomeInterface { | ||
name: String | ||
} | ||
|
||
extend type Query { | ||
resolver_field: SomeInterface | ||
@relay_resolver(import_path: "./path/to/Resolver.js") | ||
} | ||
==================================== ERROR ==================================== | ||
✖︎ Client Edges that reference client-defined interface types are not currently supported in Relay. | ||
|
||
relay-resolver-edge-to-interface-with-no-implementors.graphql:3:3 | ||
2 │ query relayResolverEdgeToInterfaceWithNoImplementorsQuery { | ||
3 │ resolver_field { | ||
│ ^^^^^^^^^^^^^^ | ||
4 │ name | ||
|
||
|
||
✖︎ No types implement the client interface SomeInterface. Interfaces returned by a @RelayResolver @outputType must have at least one concrete implementation. | ||
|
||
<generated>:2:35 | ||
1 │ # expected-to-throw | ||
2 │ query relayResolverEdgeToInterfaceWithNoImplementorsQuery { | ||
│ ^^^^^^^^^^^^^ | ||
3 │ resolver_field { |
20 changes: 20 additions & 0 deletions
20
...le_relay_artifacts/fixtures/relay-resolver-edge-to-interface-with-no-implementors.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,20 @@ | ||
# expected-to-throw | ||
query relayResolverEdgeToInterfaceWithNoImplementorsQuery { | ||
resolver_field { | ||
name | ||
} | ||
} | ||
|
||
# %extensions% | ||
|
||
""" | ||
An interface with no implementors | ||
""" | ||
interface SomeInterface { | ||
name: String | ||
} | ||
|
||
extend type Query { | ||
resolver_field: SomeInterface | ||
@relay_resolver(import_path: "./path/to/Resolver.js") | ||
} |
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
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This underline being in the wrong place is not a problem with your diff. Our test util is not fully roust in this case and does not print location info correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it should be underlining
resolver_field
here. Just wondering, where does that get determined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here:
relay/compiler/crates/relay-compiler/tests/compile_relay_artifacts/mod.rs
Line 206 in 74bb8ab
The problem is that the fixture file actually models two different files, and so the error location should actually get mapped to an offset based on if its an error in the schema portion of the file or the fragment portion.