facebook / facebook/relay

Bug: incorrect Flow types for plural fragments

Open
#2,545 8 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Hello! I think I found an error in generated Flow types. Fragments like this:

```graphql
fragment Ticket_passengers on Passenger @relay(plural: true) {
id
...MyFragment
}
```

currently generate this Flow type:

```js
export type Ticket_passengers = $ReadOnlyArray<{|
+id: string,
+$fragmentRefs: MyFragment$ref
+$refType: Ticket_passengers$ref,
|}>;
```

However, most of our types are nullable. This is not problem for most of the cases because we can just import the type and prefix it with `?`. But we cannot do it here because it should be:

```js
export type Ticket_passengers = $ReadOnlyArray;
```

I am afraid it is not possible to do it from outside when imported. It's unfortunate because parrent component defines this type:

```js
+passengers: ?$ReadOnlyArray
```

and as you can see these types are incompatible (inner object is correctly nullable here).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.