Working with mutations
To make mutations you need a query schema and a client set up with our GraphQL adapter.
Getting Started
import { graphqlAdapter } from "@hyper-fetch/graphql";
// Initialize Client with adapter
const client = new Client({ url: "http://localhost:3000/grahql" }).setAdapter(graphqlAdapter);
type Variables = {
username: string;
password: string;
};
// It's ready to use!
const login = client.createRequest<boolean, Variables>()({
endpoint: gql`
mutation Login($username: String!, $password: String!) {
login(username: $username, password: $password) {
username
password
}
}
`,
});
const { data, status, extra, success, error } = await getUser
.setData({
username: "Some username",
password: "Some password",
})
.send();