-
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 compiler validation to error on resolver that returns plural serv…
…er type Reviewed By: tyao1 Differential Revision: D70109268 fbshipit-source-id: a8a0fbc58ee2c3c4a22b6344799a7d4f1c348eef
- Loading branch information
1 parent
cf4f547
commit 687e996
Showing
13 changed files
with
175 additions
and
129 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
.../relay_compiler_integration/fixtures/resolver_returns_plural_server_type.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,42 @@ | ||
==================================== INPUT ==================================== | ||
//- PersonComponent.js | ||
graphql`query PersonComponentQuery { | ||
plural_server @waterfall { | ||
name | ||
} | ||
}` | ||
|
||
//- QueryResolvers.js | ||
/** | ||
* @RelayResolver Query.plural_server: [User] | ||
*/ | ||
|
||
//- relay.config.json | ||
{ | ||
"language": "flow", | ||
"jsModuleFormat": "haste", | ||
"schema": "schema.graphql" | ||
} | ||
|
||
//- schema.graphql | ||
type Query { | ||
greeting: String | ||
node(id: ID!): Node | ||
} | ||
|
||
interface Node { | ||
id: ID! | ||
} | ||
|
||
type User implements Node { | ||
id: ID! | ||
name: String | ||
} | ||
==================================== OUTPUT =================================== | ||
✖︎ Unexpected Relay Resolver returning plual edge to type defined on the server. Relay Resolvers do not curretly support returning plural edges to server types. As a work around, consider defining a plural edge to a client type which has a singular edge to the server type. | ||
|
||
QueryResolvers.js:2:25 | ||
1 │ * | ||
2 │ * @RelayResolver Query.plural_server: [User] | ||
│ ^^^^^^^^^^^^^ | ||
3 │ |
33 changes: 33 additions & 0 deletions
33
...sts/relay_compiler_integration/fixtures/resolver_returns_plural_server_type.invalid.input
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,33 @@ | ||
//- PersonComponent.js | ||
graphql`query PersonComponentQuery { | ||
plural_server @waterfall { | ||
name | ||
} | ||
}` | ||
|
||
//- QueryResolvers.js | ||
/** | ||
* @RelayResolver Query.plural_server: [User] | ||
*/ | ||
|
||
//- relay.config.json | ||
{ | ||
"language": "flow", | ||
"jsModuleFormat": "haste", | ||
"schema": "schema.graphql" | ||
} | ||
|
||
//- schema.graphql | ||
type Query { | ||
greeting: String | ||
node(id: ID!): Node | ||
} | ||
|
||
interface Node { | ||
id: ID! | ||
} | ||
|
||
type User implements Node { | ||
id: ID! | ||
name: String | ||
} |
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
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
Oops, something went wrong.