How to Send GraphQL Mutation Request in JMeter

This post explains how to send a GraphQL Mutation request using JMeter.

If you are performance testing an application which has a GraphQL layer, then you need to send GraphQL queries to the endpoint.

GraphQL Mutation Request

Let’s suppose we have an application running on local and with a /graphql endpoint. In this application we are able to create orders.

URL: http://localhost:9040/graphql

GraphQL Mutation request:

mutation createOrder ($order: OrderInput!) {
    createOrder(order: $order) {
        id,
        name
    }
}

Query Variables:

{
    "order": {
        "name": "test-order"
    }
}

In order to send the above GraphQL query using JMeter, we need to convert the query to raw request.

The above query and the data will become

{
    "query":"mutation createOrder ($order: OrderInput!) {
        createOrder(order: $order) {
            id,
            name
        }
    }",
    "variables":{
        "order":{
            "name":"test-amir"
        }
    }
}

JMeter GraphQL Request

In JMeter, our request will look like:

jmeter graphql