-
-
Notifications
You must be signed in to change notification settings - Fork 603
Open
Labels
bugSomething isn't workingSomething isn't workingopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query
Description
openapi-react-query version
0.2.5
Description
I’m trying to create a custom helper function to call useMutation without manually retrieving the client from the context each time:
export const useMutation: UseMutationMethod<paths, `${string}/${string}`> = (...args) => {
const { client } = useClientContext();
return client.useMutation(...args);
};
However, TypeScript throws the following error:
Type 'paths' does not satisfy the constraint 'Record<string, Record<HttpMethod, {}>>'.
Index signature for type 'string' is missing in type 'paths'.ts(2344)
Reproduction
I have a client stored inside a React Context because I need access to the auth.js session to provide access tokens in the fetch middleware. The entire application is already wrapped in the client provider. I’m trying to avoid manually calling useClientContext() everywhere — I want a simple, local useMutation hook.
Expected result
One should be able to use the paths type with UseMutationMethod.
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-react-queryRelevant to openapi-react-queryRelevant to openapi-react-query