Calculating fields on the fly based on a variable
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I have a the following fragments
```
fragment Timeline_viewer on Viewer
routes(first: 100) @connection(key: "Timeline_routes") {
edges {
node {
...RouteSegments_route @version($version)
}
}
}
}
fragment RouteSegments_route on Route {
id
segments {
duration
startAt
}
}
```
I would like to be able to change `version` from `plan` to `live`. `plan` would return what is returned from the GraphQL server 1:1, and `live` will be augmented version that has some values altered in the client application, for example the order in the segments array will be different.
I believe before few years back in the docs there was a way to add fields that were calculated on the fly when data is received from the server and saved in the Store using a custom handler similar to ConnectionHandler. Is that still possible in 8.0 and what would be the best way to achieve it since it is not documented.
Thanks!
Contributor guide
Research direction
Start by reviewing the Relay 8.0 behavior around the @version fragment argument, the Store, and custom handlers such as ConnectionHandler. Determine whether client-calculated fields and reordered segments are supported, and document the recommended approach or the missing capability; the issue names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100