Open
Description
Description
I'm referring to these lines.
Add client parameter to queryKey
Currently, the implementation has a potential issue because useQuery
calls from different clients are assigned the same key, even though they're querying different endpoints.
For example:
import { default as createFetchClient } from 'openapi-fetch'
import createClient from 'openapi-react-query'
const client1 = createClient(createFetchClient({ baseUrl: 'https://api1.example.com' }))
const client2 = createClient(createFetchClient({ baseUrl: 'https://api2.example.com' }))
function useSomething() {
return [client1.useQuery('get', '/a'), client2.useQuery('get', '/a')]
}
Here, both queries receive the same key, even though they are querying different sources.
... and remove options
parameter
Currently queryOptions
spreads the options
parameter in the last argument. It might be cleaner to make this the library user's responsibility, as shown in the following examples, which yield the same result but simplify the implementation:
const queryOptions1 = client.queryOptions('get', '/', {}, { enabled: false } )
const queryOptions2 = { ...client.queryOptions('get', '/', {}), enabled: false }
Proposal
The title summarizes the changes.
Checklist
- I’m willing to open a PR for this (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Type
Projects
Status
No status