Uddhav Raut
Uddhav Raut

Reputation: 11

GraphQL in Jmeter- Variables and Parameters

I want to send variable as float but when I am trying like this

latitude:"${latitudeValue}"

where latitudeValue is user defined variable.

and in graphQl query value come as String. and I get this error

{"errors":[{"message":"Variable "$latitude" got invalid value "41.98240048026275F"; Float cannot represent non numeric value: "41.98240048026275F"","locations":[{"line":1,"column":96}],"extensions":{"code":"INTERNAL_SERVER_ERROR"}},{"message":"Variable "$longitude" got invalid value "-102.07540422677995F"; Float cannot represent non numeric value: "-102.07540422677995F"","locations":[{"line":1,"column":114}],"extensions":{"code":"INTERNAL_SERVER_ERROR"}}]}

Is there any solution for this?

Upvotes: 0

Views: 1985

Answers (2)

Felix Schumacher
Felix Schumacher

Reputation: 331

I think you are looking at Bug 65108 which could be solved by PR 660 or PR 651

At the moment you can only insert variable values, that lead to a valid JSON structure.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168147

There is "Variables" tab in the GraphQL HTTP Request sampler:

enter image description here

where you can define GraphQL variables like:

{
  "id": "${id}"
}

and this ${id} comes from a User-Defined Variable

Once you do this you can use it in the "Query" tab like:

query ($id: ID!){
  droid(id: $id){
    id
    name
    friends{
      name
    }
    appearsIn
    primaryFunction
  }
}

Without variables:

enter image description here

With variables:

enter image description here

More information:

Upvotes: 1

Related Questions