[Modern] applying @include to a field with a non null argument.
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
```graphql
fragment Me_card on User @argumentDefinitions(
id: { type: "ID!" }
) {
card(id: $id) {
id
name
}
}
fragment Me_me on User @argumentDefinitions(
id: { type: "ID" }
withCard: { type: "Boolean!", defaultValue: false }
) {
id
...Me_card @arguments(
id: $id
) @include(if: $withCard)
}
`,
```
`$withCard` is externally set to `true` if `id` is set. Thus, `Me_card` will always have a non-null `id` while `Me_me` can have null `id`.
In graphql schema, there is a field `card(id: ID!)` with non null `id` argument.
I am having a hard time getting this query working.
It throws relay compile error complaining `ID` should be `ID!` for `Me_me`:
```
ERROR:
You supplied a GraphQL document with validation errors:
path/to/file.js: Variable "$id" of type "ID" used in position expecting type "ID!".
```
If I change it to `ID!`, it sends query to server, but server throws error saying `card.id` cannot be `null` even if `withCard` is correctly set to false:
```
variables: { id: null, withCard: false }
"message": Variable "$id" got invalid value null.
Expected "ID!", found null.
```
Is this scenario not supported by relay modern?
I also tried the following to no avail:
```
...card(id: $id) {
id
name
} @include(if: $withCard)
```
Contributor guide
Assessment
This issue has not been assessed yet.