blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Allow configuring React Query default options #50

Closed codytooker closed 2 years ago

codytooker commented 3 years ago

What do you want and why?

The ability to set React Query QueryClient default options. Blitz provides some defaults adding to React Queries already aggressive fetching defaults. Being able to configure the rest of default options from React Query would be a great addition

Possible implementation(s)

Adding a new key to BlitzConfig named queryClient that accepts DefaultOptions from React Query might be the best way to approach this. Then when Blitz initializes a new QueryClient the options can be merged. I think we would want to figure out if we should allow overriding of the current settings Blitz provides which are queries.suspense and queries.retry

Additional context

While the default options will work for 90% of the use cases, this is a simple addition that will allow for more flexible use cases for Blitz.

flybayer commented 3 years ago

Thanks! We should definitely add this and add ability to override our default options.

This needs to wait until https://github.com/blitz-js/blitz/pull/2516 is merged.

I think adding the config in blitz.config makes sense, but we'll just have to figure out how to get that code into both server and client environments for runtime.

beerose commented 2 years ago

This is covered by the Blitz Toolkit. Docs: https://alpha.blitzjs.com/docs/rpc-setup