Suresh Kumar
Suresh Kumar

Reputation: 21

Graphql with Jmeter

I am trying to use jmeter to Automate graphql API testing. I have done the manual testing with postman. However, since some one suggested i am trying to automate with jmeter. unfortunately i am new to API testing itself and having great difficulties.

As i understand Graphql method only deals with POST, but in my Jmeter it is throwing an error, but when i change it to GET, i get 200 ok response.

Also in the body data i am directly entered the graphQL query is this correct. In the return response data i don get any information related to my query.

I have added header manager with

Content-type = "Application/json"
Accept-encoding
Authorization
Accept
Connection

My graphql query is

query{cmCases(filters: {caseId:"case-6"})
 {
    items {
      id

    }
  }
}

In the response i am just receiving meta data.

Upvotes: 2

Views: 2620

Answers (2)

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34556

Starting with upcoming JMeter 5.3.1 or 5.4 you’ll be able to use the GraphQL Http Request.

Until it is released you can try a nightly build:

See:

GraphQL query

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168147

  1. Looking into HTTP Methods, Headers, and Body chapter of the GraphQL documentation GraphQL supports both GET and POST methods so you can choose whatever you want or whatever you need
  2. Looking into HTTP Headers documentation chapter header values are case-sensitive so you need to change Application/json to application/json in the HTTP Header Manager
  3. Given you can successfully execute request in Postman you should be able to record this request by JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy

Upvotes: 0

Related Questions