the-guild-org / the-guild-org/apollo-angular

FetchtResult for mutation

Open
#1,477 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.