-
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.
Validate that resolver fields are always nullable
Reviewed By: josephsavona Differential Revision: D46498216 fbshipit-source-id: e0f430da9c65b66f9c76039ae87810fe76c0a47b
- Loading branch information
1 parent
a2c2b64
commit feaba45
Showing
11 changed files
with
195 additions
and
8 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
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
73 changes: 73 additions & 0 deletions
73
.../relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable-list-item.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,73 @@ | ||
==================================== INPUT ==================================== | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: [String!] | ||
* Non-nullable | ||
*/ | ||
==================================== OUTPUT =================================== | ||
TerseRelayResolver( | ||
TerseRelayResolverIr { | ||
field: FieldDefinition { | ||
name: Identifier { | ||
span: 25:43, | ||
token: Token { | ||
span: 25:43, | ||
kind: Identifier, | ||
}, | ||
value: "mandatory_greeting", | ||
}, | ||
type_: List( | ||
ListTypeAnnotation { | ||
span: 45:54, | ||
open: Token { | ||
span: 45:46, | ||
kind: OpenBracket, | ||
}, | ||
type_: NonNull( | ||
NonNullTypeAnnotation { | ||
span: 46:53, | ||
type_: Named( | ||
NamedTypeAnnotation { | ||
name: Identifier { | ||
span: 46:52, | ||
token: Token { | ||
span: 46:52, | ||
kind: Identifier, | ||
}, | ||
value: "String", | ||
}, | ||
}, | ||
), | ||
exclamation: Token { | ||
span: 52:53, | ||
kind: Exclamation, | ||
}, | ||
}, | ||
), | ||
close: Token { | ||
span: 53:54, | ||
kind: CloseBracket, | ||
}, | ||
}, | ||
), | ||
arguments: None, | ||
directives: [], | ||
description: None, | ||
}, | ||
type_: WithLocation { | ||
location: /path/to/test/fixture/terse-relay-resolver-non-nullable-list-item.js:20:24, | ||
item: "User", | ||
}, | ||
root_fragment: None, | ||
deprecated: None, | ||
live: None, | ||
location: /path/to/test/fixture/terse-relay-resolver-non-nullable-list-item.js:0:71, | ||
fragment_arguments: None, | ||
}, | ||
) |
11 changes: 11 additions & 0 deletions
11
...crates/relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable-list-item.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: [String!] | ||
* Non-nullable | ||
*/ |
22 changes: 22 additions & 0 deletions
22
...rates/relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable-list.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,22 @@ | ||
==================================== INPUT ==================================== | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// expected-to-throw | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: [String]! | ||
* Non-nullable | ||
*/ | ||
==================================== ERROR ==================================== | ||
✖︎ Unexpected Relay Resolver field with non-nullable type. Relay expects all Resolver fields to be nullable since errors thrown by Resolvers are turned into `null` values. | ||
|
||
/path/to/test/fixture/terse-relay-resolver-non-nullable-list.js:11:44 | ||
10 │ * | ||
11 │ * @RelayResolver User.mandatory_greeting: [String]! | ||
│ ^^^^^^^^^ | ||
12 │ * Non-nullable |
13 changes: 13 additions & 0 deletions
13
...iler/crates/relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable-list.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// expected-to-throw | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: [String]! | ||
* Non-nullable | ||
*/ |
22 changes: 22 additions & 0 deletions
22
...ler/crates/relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable.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,22 @@ | ||
==================================== INPUT ==================================== | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// expected-to-throw | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: String! | ||
* Non-nullable | ||
*/ | ||
==================================== ERROR ==================================== | ||
✖︎ Unexpected Relay Resolver field with non-nullable type. Relay expects all Resolver fields to be nullable since errors thrown by Resolvers are turned into `null` values. | ||
|
||
/path/to/test/fixture/terse-relay-resolver-non-nullable.js:11:44 | ||
10 │ * | ||
11 │ * @RelayResolver User.mandatory_greeting: String! | ||
│ ^^^^^^^ | ||
12 │ * Non-nullable |
13 changes: 13 additions & 0 deletions
13
compiler/crates/relay-docblock/tests/parse/fixtures/terse-relay-resolver-non-nullable.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// expected-to-throw | ||
|
||
/** | ||
* @RelayResolver User.mandatory_greeting: String! | ||
* Non-nullable | ||
*/ |
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
10 changes: 5 additions & 5 deletions
10
...es/react-relay/__tests__/__generated__/RelayResolverModelTestInterfaceFragment.graphql.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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