Performance test for graphQL API

前端 未结 7 1447
北恋
北恋 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:45

    Disclaimer: I work for LoadImpact; the company behind k6.

    If you are willing to consider an alternative, I've recently written a blog post about this topic: Load testing GraphQL with k6.

    This is how a k6 example looks like:

    let accessToken = "YOUR_GITHUB_ACCESS_TOKEN";
    
    let query = `
     query FindFirstIssue {
       repository(owner:"loadimpact", name:"k6") {
         issues(first:1) {
           edges {
             node {
               id
               number
               title
             }
           }
         }
       }
     }`;
    
    let headers = {
     'Authorization': `Bearer ${accessToken}`,
     "Content-Type": "application/json"
    };
    
    let res = http.post("https://api.github.com/graphql",
     JSON.stringify({ query: query }),
     {headers: headers}
    );
    

提交回复
热议问题