cypress mock with graphql code example
Example: cypress graphql request
const query = `{
findUser(username:"hello")
{
id
}
}`;
cy.request(
{
url: 'http://localhost/graphql/', // graphql endpoint
body: { query }, // or { query: query } depending if you are writing with es6
failOnStatusCode: false // not a must but in case the fail code is not 200 / 400
}
).then((res) => {
cy.log(res);
})