Using React and Apollo I have a mutation like this:
const UPDATE_USER = gql`
mutation UpdateUser($id: ID!, $someValue: String!, $someOtherValue: String!) {
updateUser(id: $id, someValue: $someValue, someOtherValue: $someOtherValue) {
id
name
}
}
`;
const [mutateUser] = useMutation(UPDATE_USER, {
variables: { id: 123, someValue: 'Hello', someOtherValue: 'World' },
});
Works perfectly but the UpdateUser mutation is now just passing on arguments which doesn't seem very DRY to me.
I'm wondering if there is a way to shorten the code or make it a bit more manageable so that when another argument is added for example I don't have to retype it 4 times.
If you have access to the api, you can define it a little bit different:
Then in your api:
And then add UpdateUserInputType to your data arg at your resolver