Unable to pass an attribute value inside a graphQL request payload

What I’m trying to achieve here is storing a value from previous response in a list (vector) and then passing it to the next request.
Note that the the API is in graphQL and when Im trying to pass the attribute ID “elementID” below inside the request body, its not getting identified, am I missing on any syntax here ?

20:45:23.935 [main][ERROR][ZincCompiler.scala:153] i.g.c.ZincCompiler$ - /Users/rshinkar/Desktop/Projects/Performance/gatling-ec2/src/test/scala/com/GraphQLCreateLoad.scala:71:96: not found: value elementID
genericReadObject(type: “BaseComponent”, id: “${elementID}” {
^
20:45:23.974 [main][ERROR][ZincCompiler.scala:124] i.g.c.ZincCompiler$ - one error found
20:45:23.979 [main][ERROR][ZincCompiler.scala:220] i.g.c.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null

Here’s the snippet of the code:

.foreach("${mList}", "elementID") {
  exec(
    http("Read Component")
      .post("/api/graphql")
      .header("dataspace", "default")
      .body(StringBody(session => s"""query {
                                             genericReadObject(type: "BaseComponent", id: "${elementID}" {
                                              result
                                            }
                                       }"""))

You’re confusing Scala String interpolation and Gatling Expression Language.
You have to remove the s prefix if you want the latter.
I guess you use IntelliJ and it’s the one that automatically added this cumbersome s.

Thank you Stephane, this is a great help.

However, sorry for bugging you again , removing “s” from the payload helped me identify the attribute, post which I’m getting following error as “object with ${elementID} does not exist”

Please see the below error:

{“errors”:[{“message”:“Exception while fetching data (/genericReadObject) : java.lang.RuntimeException: com.abc.api.exceptions.HttpCodedException: com.tracelink.dnp.api.exceptions.HttpCodedException: object with ${elementID} does not exist”,“locations”:[{“line”:3,“column”:67}],“path”:[“genericReadObject”],“extensions”:{“classification”:“DataFetchingException”}}],“data”:{“genericReadObject”:null}}

Do you think there’s any problem with the way we have given the query?

.body(StringBody(session =>  """
                                query {
                                       genericReadObject(type: "Component", id: "${elementID}") {
                                       result
                                        }
                                      }"""))

Because you’re passing a function that returns a String.
If you want to use Gatling EL, you must pass a String and Gatling will take care of parsing it and turn it into a function that would return a String resolved against Session’s content.

Basically, remove “session =>”.

Awesome, This really worked and I get your point now, I’m now able to get the APIs orchestrated perfectly.

Thank you for all the assistance , Stephane!