Skip to content

GQL query is not being intercepted even though it is fired using graphql-test-utils.js #18365

Answered by pmerwin
pmerwin asked this question in Plugins
Discussion options

You must be logged in to vote

hmm I think I solved this, our endpoints do not have an operationName prop all the time so I tried this:

Cypress.Commands.add('interceptGQL', (opName, route) => {
cy.intercept('POST', https://api.adept.at/${route}/graphql, req => {
const { body } = req;
console.log(body.query);
if (body.hasOwnProperty('query') && body.query.includes(opName)) {
req.alias = opName;
}
});
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pmerwin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant