additionalTypenames should be a property of useMutation contex?! #1132
Replies: 2 comments 5 replies
-
|
Hey @ivan-kleshnin thanks for the detailed proposal! 👋 I see where you're coming from, it would be nice to declare the I'm curious, are there many use cases where the execute function is being called from multiple places? For myself, I can't think of a use case where I've had more than one handler for a mutation - even if said mutation is triggered by multiple sources. Here's an example: // ...
const [mutationState, executeMutation] = useMutation(SomeQuery);
// Trigger mutation - for both click and "Enter" key press
const handleSubmit = useCallback(
() => executeMutation({ ...someAppState }, { additionalTypenames: ["Vote"] }),
[someAppState, executeMutation]
);
const handleKeyPress = useCallback((e) => {
if (e.key !== "Enter") {
return;
}
handleSubmit();
}, [handleSubmit])
return (
<>
<input {...inputStateProps} onKeyDown={hanldeKeyPress} />
<button onClick={handleSubmit}>Submit</button>
</>
); |
Beta Was this translation helpful? Give feedback.
-
Yes, thank you. To be honest, I also didn't have such case in my code. But my key concern is Readability rather than DRY rule. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
additionalTypenamesis a great feature I always lack in Apollo Client.Hovewer, it's current API pends a question about
additionalTypenamespassing location.It's a query-level feature, which has nothing to do with variables.
I'm going to pass the same
additionalTypenamesin allexecutecalls... right?If so, it signalizes that it should be moved to
useMutationcontext.Current API:
vs
or rather
to make it closer to
useQuery.I have little experience with URQL so please correct me if I'm wrong about the use patterns and API.
It's just a question/suggestion not a rock-solid opinion from my side.
Beta Was this translation helpful? Give feedback.
All reactions