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

Feature Request: Enhance injectQuery to Accept an Options Object #197

Open
jon9090 opened this issue Aug 1, 2024 · 1 comment
Open

Feature Request: Enhance injectQuery to Accept an Options Object #197

jon9090 opened this issue Aug 1, 2024 · 1 comment

Comments

@jon9090
Copy link

jon9090 commented Aug 1, 2024

Which @ngneat/query-* package(s) are relevant/releated to the feature request?

query

Description

Description

Currently, the injectQuery function does not accept an options object directly. This feature would enhance the usability and flexibility of the function, making it more intuitive and powerful for developers.

Current Implementation

class MyComponent {
  #query = injectQuery();

  getTodos() {
    return this.#query({
      queryKey: ['todos'] as const,
      queryFn: () => {
        return this.#http.get<Todo[]>('https://jsonplaceholder.typicode.com/todos');
      },
    });
  }
}

Proposed Change

Modify the injectQuery function to accept an options object, allowing for more streamlined and readable code. The new usage would be similar to this:

import { injectQuery } from '@tanstack/angular-query-experimental';
...
class MyComponent {
  #query = injectQuery({
    queryKey: ['todos'] as const,
    queryFn: () => {
        return this.#http.get<Todo[]>('https://jsonplaceholder.typicode.com/todos');
    },
   });
  }
}

Benefits

  1. Consistency: Aligns with other common practices of passing an options object in similar libraries.
  2. Readability: Enhances code readability and maintainability.
  3. Flexibility: Allows for easier configuration and extension of queries.

Thank you for considering this enhancement!

@wizardnet972
Copy link

I love this feature idea!
@NetanelBasal, @luii, would you like me to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants