Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular-query): support required input signal on injectMutation #7016

Merged

Conversation

riccardoperra
Copy link
Contributor

@riccardoperra riccardoperra commented Mar 3, 2024

This pr add required input signal support for injectMutation and injectMutationState.

Like injectQuery does, we should support required input signals also for injectMutation and injectMutationState. The use may be related to some specific mutations that can have as mutationKey the value of a required input signal. Done that, we may want to get the state of the mutations via injectMutationState, which could have as "filter" that value passed as input

// Component A

class ComponentA { 
  readonly id = input.required<string>();
  readonly addMutation = injectMutation(() => ({
    mutationKey: ['entity', this.id(), 'add'],
    mutationFn: () => {}
  })
} 

// Component B

class ComponentB { 
  readonly id = input.required<string>();
  readonly mutationState = injectMutationState(() => ({
    filters: {mutationKey: ['entity', this.id()]}
  })
}

I'm adding some new tests via TestBed in both injectMutation/injectQuery in order to be sure that nothings break if we find another solution for the lazy initialization.

I'm also introducing some utils in order to set required signal input via testBed, which seems currently not "officially" supported. I found a related discussion but vitest seems not supporting that yet, so I couldn't use testing-library/angular.

  • Add support for injectIsMutating --> This may should be done in another PR. It's a breaking change that requires to update the function signature

@arnoud-dv

Copy link

vercel bot commented Mar 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Mar 5, 2024 9:48pm

@riccardoperra riccardoperra changed the title feat(angular-query): support required input signal to injectMutation feat(angular-query): support required input signal for injectMutation Mar 3, 2024
@riccardoperra riccardoperra changed the title feat(angular-query): support required input signal for injectMutation feat(angular-query): support required input signal on injectMutation Mar 3, 2024
Copy link

nx-cloud bot commented Mar 3, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 145bb9f. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link

codesandbox-ci bot commented Mar 3, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 145bb9f:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@riccardoperra riccardoperra force-pushed the feat/mutation_support_signal_input branch from dd9dea2 to a8ee8fd Compare March 3, 2024 21:44
@riccardoperra riccardoperra marked this pull request as ready for review March 3, 2024 23:23
@riccardoperra riccardoperra force-pushed the feat/mutation_support_signal_input branch from 302aee0 to 8012b4f Compare March 4, 2024 06:46
@riccardoperra riccardoperra force-pushed the feat/mutation_support_signal_input branch from 9449e53 to 8bc0d9a Compare March 4, 2024 09:53
@arnoud-dv arnoud-dv self-assigned this Mar 4, 2024
@arnoud-dv
Copy link
Collaborator

Nice! Thank you for the additional tests too.

@arnoud-dv arnoud-dv merged commit a00dc08 into TanStack:main Mar 5, 2024
6 checks passed
@riccardoperra riccardoperra deleted the feat/mutation_support_signal_input branch March 5, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants