Performance test for graphQL API

前端 未结 7 1458
北恋
北恋 2021-02-04 20:07

Today I\'m doing my API automation testing and performance testing with Jmeter when the server is a REST API.

Now the development changed to graphQL API, and I have two

7条回答
  •  春和景丽
    2021-02-04 20:42

    I have recently tried API testing with GraphQl with both GET and POST request in Jmeter

    Make sure its POST request for both Query and Mutation

    Example Your Graph Ql query

    {
      storeConfig{
        default_title
        copyright
      }
    }
    

    For Jmeter it would be like this

    {
        "query":"{ storeConfig { default_title copyright } }"
    }
    

    Step up HTTP Request

    In place of the localhost, your domain name will come. Make sure you don't add https

    Example:- https://mydomainname.com

    In Jmeter :- mydomainname.com

    Setup HTTP Header Manager

    For requesting Mutation in Jmeter

    Example mutation in Graphql

     mutation {
          generateCustomerToken(
              email: "rd@mailinator.com"
              password: "1234567"
          ) {
              token
       }
    }
    

    In Jemeter mutation will be like this

    {
        "query":"mutation { generateCustomerToken( email: \"rd@mailinator.com\" password: \"1234567\" ) { token } }"
    }
    

    Replace double quotes with (\") as shown in above query

提交回复
热议问题