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
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:
However, TypeScript throws the following error:
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, localuseMutationhook.Expected result
One should be able to use the
pathstype withUseMutationMethod.Extra