Feature Request: Flatten fragments in requests
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
## What?
As part of the relay compiler generate "flattened" queries to use in the network request body
Request body example
```graphql
query useAppleQuery(
$requestBody: v1_AppleRequestBody
) {
apple(requestBody: $requestBody) {
__typename
... on Apple {
id
flavour
...OneFragment
...TwoFragment
...ThreeFragment
}
... on Error {
errors {
code
}
}
}
}
fragment OneFragment on Apple {
id
taste
}
fragment TwoFragment on Apple {
id
taste
colour
}
fragment ThreeFragment on Apple {
id
colour
}
```
becomes
```graphql
query useAppleQuery(
$requestBody: v1_AppleRequestBody
) {
apple(requestBody: $requestBody) {
__typename
... on Apple {
id
flavour
taste
colour
}
... on Error {
errors {
code
}
}
}
}
```
## Why?
The server response is identical, so given were already running a compiler, do a bit more computation at build time, to improve server performance (less input to parse) and reduce the amount of data the client needs to send to the server (when not using persisted queries)
For large applications (where theres hundreds of fragments) this could have huge performance improvements
Contributor guide
Assessment
This issue has not been assessed yet.