apollographql / apollographql/apollo-tooling
typescript codgen should export single root level type useable by useMutation
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Given mutation query like this:
```
const TOGGLE_LOCATION_STATUS = gql`
mutation toggleLocationStatus($input: UpdateLocationInput!) {
updateLocation(input: $input) {
location {
status
}
}
}
`;
```
Running apollo codegen produces types which can be imported like this:
```
import {
toggleLocationStatus,
toggleLocationStatusVariables
} from "./__generated__/toggleLocationStatus";
```
Then to useMutation with generated types you call like:
```
useMutation({variables: {...}})
```
The amount that has to be wired up here is obnoxious -- would be much better if useMutation<> aligned directly with some single type exported by the generated types to reduce noise and unnecessary name creation ...
Contributor guide
Research direction
Start by tracing Apollo codegen's TypeScript output for the shown mutation and compare its generated types with the useMutation generic shape. Done means the generated output exposes one root-level type that can be passed to useMutation without separately wiring the operation and variables types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100