-
-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
Which @ngneat/query-* package(s) are relevant/releated to the feature request?
query
Description
I was implementing SSR with new AngularAppNodeEngine and the current solution from docs of how to support hydration process is not available since now, server.ts no longer allows to specify providers, so we can't define a queryClient there and provide it downstream using provideQueryClient(client).
What we can do is to initialise query client on each request handler and put it into REQUEST_CONTEXT token which will be available in application scope, e.g. in app.server.config.
But we need to be in injection context and provideQueryClient() does not support passing factory function(so we can extract query client and use it).
Proposed solution
expected usage
provideQueryClient(() => {
const requestContext = inject(REQUEST_CONTEXT, { optional: true }) as {
queryClient: QueryClient;
} | undefined;
return requestContext?.queryClient || new QueryClient();
})
modified function
function provideQueryClient(queryClientOrFactory) {
return {
provide: QueryClientToken,
useFactory:
typeof queryClientOrFactory === 'function'
? queryClientOrFactory
: () => queryClientOrFactory,
};
}
Alternatives considered
export token which is provided by provideQueryClient?
Do you want to create a pull request?
Yes
Metadata
Metadata
Assignees
Labels
No labels