Using @required on the `node` field of a connection type causes Relay compilation to fail
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
When attempting to use the `@required` directive on the response from a Connection type, Relay compilation errors with `All references to a field must have matching @required declaration`. As a quick example
```
const { data } = usePaginationFragment(graphql`
fragment RefetchableAndRequired on Query @refetchable(queryName: "PaginationQuery") {
users(first: $count after: $cursor) @connection(key: "PaginationQuery_users") {
edges {
node @required(action: THROW) {
id
}
}
}
}
`,
queryRef,
);
```
Running this will give an error in the compiler internals
```
[ERROR] Error in the project `xxx`: ✖︎ All references to a field must have matching @required declarations. The field 'node` is @required here
path/to/file.test.tsx:463:19
462 │ edges {
463 │ node @required(action: THROW) {
│ ^^^^
464 │ id
ℹ︎ but not @required here
:
```
The `: ` makes me think this is happening internally in Rust. I attempted to create a number of tests to reproduce this, but wasn't able to for some reason, so I'm not sure what is unique about this. I'll probably keep poking at tests to see if I can reproduce this, but figured I'd open this in the meantime.
Contributor guide
Assessment
This issue has not been assessed yet.