Closed zelief closed 1 day ago
Solves #252, #317 Improve #253 Previously, the variables are not used in the Chain Function, so the generated query result will not include variables. This PR fixes that.
Chain
With built-in variable types:
const mutation = useTypedMutation('addCard', { addCard: [ { card: { Attack: $('attack', 'Int!'), Defense: 5, description: 'new card', name: $('name', 'String!') } }, { Attack: true, Defense: true, id: true }, ], }); mutation.mutate({ variables: { attack: 10, name: 'Charmander' } });
With ZEUS_VARIABLES Type:
ZEUS_VARIABLES
import { $ } from 'zeus'; import { useTypedMutation } from './reactQuery'; const mutation = useTypedMutation('addCard', { addCard: [{ card: $('card', 'createCard') }, { Attack: true, Defense: true, id: true }], }); mutation.mutate({ variables: { card: { Attack: 10, Defense: 5, description: 'new card', name: 'Bulbasaur' } } });
And it will force you to be type-safe when calling mutate() function.
mutate()
Solves #252, #317 Improve #253 Previously, the variables are not used in the
Chain
Function, so the generated query result will not include variables. This PR fixes that.Usage with useTypedMutation
With built-in variable types:
With
ZEUS_VARIABLES
Type:And it will force you to be type-safe when calling
mutate()
function.