facebook / facebook/relay

GenerateIDFieldTransform is not automatically adding ID fields

Open
#3,931 5 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

Based on https://github.com/facebook/relay/blob/1b43a4671d07ae69b3cbe36f1c21c2978f6419f2/packages/relay-compiler/transforms/GenerateIDFieldTransform.js, it seems like `GenerateIDFieldTransform` should automatically query for `id` fields when available.

This is also mentioned here: https://stackoverflow.com/questions/64524994/do-i-need-to-always-pull-the-id-field-when-using-react-relay

However, for this query:

```
const query = graphql`
query AccountSetupModalContainerUserQuery($id: String!) {
User_by_pk(id: $id) {
__typename
}
}
`;
```

Relay generates the following:

```
"text": "query AccountSetupModalContainerUserQuery(\n $id: String!\n) {\n User_by_pk(id: $id) {\n __typename\n }\n}\n"
```

It does *not* query for the `id` field, even though it is present on our `User` type (the abbreviated type is below)

```
type User {
id: String!
}
```

And here's the type of `User_by_pk`
```
User_by_pk(id: String!): User
```

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.