Replies: 1 comment
-
I solved this by looking at an existing pull request here: Moving the function useTypedMutation<
O extends "mutation_root",
TData extends ValueTypes[O],
TResult = InputType<GraphQLTypes[O], TData, typeof scalars>,
TVariables = ExtractVariables<TData>
>(
mutationKey: unknown[],
q: TData | ValueTypes[O],
options?: Omit<
UseMutationOptions<TResult, any, any>,
"mutationKey" | "mutationFn"
>
) {
return useMutation<TResult, any, TVariables>(
mutationKey,
(variables) =>
mutation(q, { variables: variable as Record<string, unknown> }) as Promise<TResult>,
options
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to get type-safe variables when using react-query together with graphql zeus. I accomplished this by using the
ExtractVariables
type, and it works, but it absolutely destroys my performance to the point that vscode is almost unusable.My useMutation function looks like this:
I am getting a lot of
Type instantiation is excessively deep and possibly infinite.
andType of property '__alias' circularly references itself in mapped type
in the{ variables: variable }
line.I noticed that
ExtractVariables
are not used in the generated react-query nor in theThunder
function. I am thinking it might have been removed because of performance issues? Any way to make this work?Beta Was this translation helpful? Give feedback.
All reactions