ngneat / query

🚀 Powerful asynchronous state management, server-state utilities and data fetching for Angular Applications

Home Page:https://ngneat.github.io/query

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

provideQueryClientOptions changes behaviour of queries even when not changing any default properties

stevebrowndotco opened this issue · comments

Which @ngneat/query-* package(s) are the source of the bug?

query

Is this a regression?

Yes

Description

If I use provideQueryClientOptions, and pass in an empty object, it changes the behaviour of the queries when it shouldn't.

Specifically, one of my queries is stuck in the "fetching" state

// app.module.ts

  provideQueryClientOptions({
      defaultOptions: {}
    })

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

My query is stuck in "fetching"

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

@ngneat/query is just a mere wrapper/adapter to the underlying @tanstack/query, it doesnt transform any default options, every default option that is set from the get go is set by @tanstack/query.

Taken from the actual file (packages/ng-query/src/lib/providers.ts):

export const QUERY_CLIENT_OPTIONS = new InjectionToken<QueryClientConfig>(
  'QUERY_CLIENT_OPTIONS',
  {
    providedIn: 'root',
    factory() {
      return {}; // <-- 
    },
  }
);

as you can see it only provides an empty object, that later gets passed to the QueryCore instance (packages/ng-query/src/lib/query-client.ts):

const QueryClient = new InjectionToken<QueryCore>('QueryClient', {
  providedIn: 'root',
  factory() {
    return new QueryCore(inject(QUERY_CLIENT_OPTIONS));
  },
});

these are the only references and it doesnt get transformed midway.
I think that your "bug" is not related to either of these packages. For the "stuck in fetching" part we would need to see an example, a stackblitz or reproducable repository would be good.

@NetanelBasal i think you'd agree if i say that this issue can be closed and continued in the discussions section

Yes I don't mind if you move to the discussions page. I understand that this is an adapter but was wondering if the behaviour is still introduced on this side. I also use tanstack query in react projects and don't get the same problem unfortunately