📜  cypress graphql 请求 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:10.440000             🧑  作者: Mango

代码示例1
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);
    })