facebook / facebook/relay

optional field in array is generated as not undefined but nullable

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

Description

Hi maintainers,

When I designate optional field in array on graphql like below,
```typescript
import { graphql } from 'relay-runtime';

export const getDataQuery = graphql`
query GetDataQuery() {
data() {
users {
id // String!
name // String
}
flag // Boolean
}
}
`;

```

generated type of it is not undefined but nullable.

On the other hand, when I designate optional field not in array, generated type is optional like below.
```typescript
export type GetDataQuery$data = {
readonly data: {
readonly users?: ReadonlyArray<{
readonly id: string;
readonly name: string | null;
}>;
readonly flag?: boolean;
};
```

Is this by design or bug?

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.