GraphQL Performance Testing With Apache JMeter

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

GraphQL queries access not just the properties of one resource but also smoothly follow references between them.

Although GraphQL is still an API request from a point of view , but in JMeter it has a different Sampler.

In this quick guide we’re going to use one of the demo endpoints which is :
https://github.com/graphql/swapi-graphql

Let’s get started

  1. Open Apache JMeter
  2. Right-click on “Test Plan” and add a “Thread Group”
  3. Right-click on “Thread Group” , “Add” , “Sampler” , then select “GraphQL HTTP Request”
  4. Our target url is https://swapi-graphql.netlify.app/.netlify/functions/index”
  5. Let’s configure the “GraphQL HTTP Request” as the following screenshot.

6. We’re are going to use the following query :

query AllPlanets {
  allPlanets {
    planets {
      climates
    }
  }
}

7. One more thing is still missing , till now we don’t have request headers. Thats why we have to add “Http Header Manager” , as the following screen shot.

8. “content-type : application/json” is the header that will be added as the following screen shot.

9. Now we are ready to run , let’s add “View Results Tree” to check the response data.

You can find the JMeter project attached on this post.

That’s for today 🙂 , hope you find it useful.

Please share your tips, experience, comments, and questions for further enriching this topic of discussion.

Advertisement

One response to “GraphQL Performance Testing With Apache JMeter”

  1. [[..PingBack..]]
    This article is curated as a part of #67th Issue of Software Testing Notes Newsletter.
    https://softwaretestingnotes.substack.com/p/issue-67-software-testing-notes

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: