the-guild-org / the-guild-org/apollo-angular
FetchtResult for mutation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 309
- Avg merge
- 1h 45m
- Merged PRs (30d)
- 3
Description
Holla!
.mutate() method of apollo-angular uses FetchResult<T> for the return type, which internally uses ExecutionResult<T> from graphql module itself. The data property in ExecutionResult defined as optional and nullable. This brings problems because TS always complain that data might be null even when your mutation result is neve nullable (we use types generated from the schema). So you have to fight with nullability and of course, it's confusing because the schema result is non-nullable.
In contradiction query method defines data as data<T>, so we don't have this problem for queries.
What would be a solution to this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the .mutate() and query method return types, especially their use of FetchResult<T>, ExecutionResult<T>, and data<T>. Determine how the mutation result can preserve the schema's non-nullability without producing TypeScript nullability errors, then verify the resulting mutation typing against the query behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, graphql, typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100