-
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.
Document current behavior of conditional + requried
Reviewed By: tyao1 Differential Revision: D58797795 fbshipit-source-id: a07e3125af00d064d6d73cc7ff98ddfe09c6c4bd
- Loading branch information
1 parent
7bd521e
commit fc5894a
Showing
9 changed files
with
202 additions
and
3 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...r/tests/compile_relay_artifacts/fixtures/required-directive-on-conditional-field.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,47 @@ | ||
==================================== INPUT ==================================== | ||
fragment requiredDirectiveOnConditionalField_Foo_user on User { | ||
id | ||
name @required(action: THROW) @include(if: $condition) | ||
} | ||
==================================== OUTPUT =================================== | ||
{ | ||
"argumentDefinitions": [ | ||
{ | ||
"kind": "RootArgument", | ||
"name": "condition" | ||
} | ||
], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "requiredDirectiveOnConditionalField_Foo_user", | ||
"selections": [ | ||
{ | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "id", | ||
"storageKey": null | ||
}, | ||
{ | ||
"condition": "condition", | ||
"kind": "Condition", | ||
"passingValue": true, | ||
"selections": [ | ||
{ | ||
"kind": "RequiredField", | ||
"field": { | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "name", | ||
"storageKey": null | ||
}, | ||
"action": "THROW", | ||
"path": "name" | ||
} | ||
] | ||
} | ||
], | ||
"type": "User", | ||
"abstractKey": null | ||
} |
4 changes: 4 additions & 0 deletions
4
...er/tests/compile_relay_artifacts/fixtures/required-directive-on-conditional-field.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,4 @@ | ||
fragment requiredDirectiveOnConditionalField_Foo_user on User { | ||
id | ||
name @required(action: THROW) @include(if: $condition) | ||
} |
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
85 changes: 85 additions & 0 deletions
85
...ay-compiler/tests/relay_compiler_integration/fixtures/required_conditional_field.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,85 @@ | ||
==================================== INPUT ==================================== | ||
//- foo.js | ||
graphql` | ||
fragment foo on User { | ||
name @required(action: THROW) @skip(if: $condition) | ||
}`; | ||
|
||
//- relay.config.json | ||
{ | ||
"language": "flow", | ||
"schema": "./schema.graphql" | ||
} | ||
|
||
//- schema.graphql | ||
type Query { me: User } | ||
type User { name: String } | ||
==================================== OUTPUT =================================== | ||
//- __generated__/foo.graphql.js | ||
/** | ||
* <auto-generated> SignedSource<<e856535e023f8ce3347fff54074089de>> | ||
* @flow | ||
* @lightSyntaxTransform | ||
* @nogrep | ||
*/ | ||
|
||
/* eslint-disable */ | ||
|
||
'use strict'; | ||
|
||
/*:: | ||
import type { Fragment, ReaderFragment } from 'relay-runtime'; | ||
import type { FragmentType } from "relay-runtime"; | ||
declare export opaque type foo$fragmentType: FragmentType; | ||
export type foo$data = {| | ||
+name?: string, | ||
+$fragmentType: foo$fragmentType, | ||
|}; | ||
export type foo$key = { | ||
+$data?: foo$data, | ||
+$fragmentSpreads: foo$fragmentType, | ||
... | ||
}; | ||
*/ | ||
|
||
var node/*: ReaderFragment*/ = { | ||
"argumentDefinitions": [ | ||
{ | ||
"kind": "RootArgument", | ||
"name": "condition" | ||
} | ||
], | ||
"kind": "Fragment", | ||
"metadata": null, | ||
"name": "foo", | ||
"selections": [ | ||
{ | ||
"condition": "condition", | ||
"kind": "Condition", | ||
"passingValue": false, | ||
"selections": [ | ||
{ | ||
"kind": "RequiredField", | ||
"field": { | ||
"alias": null, | ||
"args": null, | ||
"kind": "ScalarField", | ||
"name": "name", | ||
"storageKey": null | ||
}, | ||
"action": "THROW", | ||
"path": "name" | ||
} | ||
] | ||
} | ||
], | ||
"type": "User", | ||
"abstractKey": null | ||
}; | ||
|
||
(node/*: any*/).hash = "9315d3c00a7787d5cc3f0930cf1ee1a5"; | ||
|
||
module.exports = ((node/*: any*/)/*: Fragment< | ||
foo$fragmentType, | ||
foo$data, | ||
>*/); |
15 changes: 15 additions & 0 deletions
15
...relay-compiler/tests/relay_compiler_integration/fixtures/required_conditional_field.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,15 @@ | ||
//- foo.js | ||
graphql` | ||
fragment foo on User { | ||
name @required(action: THROW) @skip(if: $condition) | ||
}`; | ||
|
||
//- relay.config.json | ||
{ | ||
"language": "flow", | ||
"schema": "./schema.graphql" | ||
} | ||
|
||
//- schema.graphql | ||
type Query { me: User } | ||
type User { 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
21 changes: 21 additions & 0 deletions
21
compiler/crates/relay-typegen/tests/generate_flow/fixtures/required-conditional.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,21 @@ | ||
==================================== INPUT ==================================== | ||
query FooQuery($condition: Boolean!) { | ||
me { | ||
firstName | ||
lastName @required(action: LOG) @skip(if: $condition) | ||
} | ||
} | ||
==================================== OUTPUT =================================== | ||
export type FooQuery$variables = {| | ||
condition: CustomBoolean, | ||
|}; | ||
export type FooQuery$data = {| | ||
+me: ?{| | ||
+firstName: ?string, | ||
+lastName?: string, | ||
|}, | ||
|}; | ||
export type FooQuery = {| | ||
response: FooQuery$data, | ||
variables: FooQuery$variables, | ||
|}; |
6 changes: 6 additions & 0 deletions
6
compiler/crates/relay-typegen/tests/generate_flow/fixtures/required-conditional.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,6 @@ | ||
query FooQuery($condition: Boolean!) { | ||
me { | ||
firstName | ||
lastName @required(action: LOG) @skip(if: $condition) | ||
} | ||
} |
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