[useFragment] Using two fragments inside component result in unknown or {} type
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
# useFragment
Hello, while I'm using two `useFragment` inside my component, the data coming from the second call gets either `unknown` or `{}` with Typescript:
E.g:
```typescript
const data1 = useFragment(FirstFragment, props.queryRef);
const person = useFragment(PersonFragment, data1.person);
```
I'm spreading the `PersonFragment` inside the `FirstFragment`, I checked for the types created by relay and Indeed they show the right definition for it, but for some reason, either Typescript/VS-Code isn't able to infer the type here.
Contributor guide
Research direction
Start with the generated TypeScript definitions for FirstFragment and PersonFragment and the two-call useFragment example in the issue. Reproduce the inference result in VS Code or TypeScript, then trace why data1.person becomes unknown or {}. Done means the second useFragment receives and exposes the expected Person type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100