Forum Discussion

_Oliver_'s avatar
_Oliver_
Contributor
4 years ago

GraphQl request : extra quotes added to the Query Variables when the QUery Variables is a property

Hi all,

I am using ReadyApi 3.7.0 to perform a graphQl query using the integrated GraphQl Query function.

If I write the following on the Query Variables field :

{"testId": "{ABCDEF}"}

Then the query that is actually sent is correct and works fine. We have this in the sent query :

"variables":{"testId":"{ABCDEF}"}

 

Now, I want to use a property in the Query Variables field. I have defined a queryVar property and its content is exactly 

{"testId": "{ABCDEF}"}

And the content of the Query Variables field is now

${#TestSuite#queryVar)

But when I do that, I see that extra quotes are added at the beginning and at the end of the query variable value which is actually sent :

"variables":"{"testId": "{ABCDEF}"}"

(extra quotes in red)

I have no idea where this comes from. For test purpose, I have copied/pasted the value from the Query Variables field to the property value field, and I have also tried to write this property value with a groovy script, and the issue is the same ðŸ¤”

Any hint would be more than welcome.

 

Thanks

 

 

  • nmrao's avatar
    nmrao
    Champion Level 3
    Attach screen shot or simple project please? so that it would he easy to understand the issue?

    Note that the value in custom property is always read as String. In case you need it differently, then it has to be parsed accordingly.
    • _Oliver_'s avatar
      _Oliver_
      Contributor

      At first I set the value of the Query Variables field in the Query Var field

      At first, it is defined like this

       

      Here is what is sent, this is correct The syntax in the query that is sent is ok

       

      Then I put the exact same string in a property

       

      Then I put this exact same string in a property

       

      And I call this property in the Query Variables field

      I call this property in the Query Variables field

       

      The error is here : extra quotes are being added in the query which is sent

      Extra quotes are added in the query that is sent

  • Hello _Oliver_ 

    After four years, this is still occurring...  :(  

    I ran upon your stated issue today...

    A work around is to give a functional shell structure of the Query Variables and use property expansion within that shell...

    instead of the only Query Variables content of:

    ${#TestSuite#queryVar}

    Use this in the Query Variables (after you define queryUUID test suite property):

    {"testId": "{${#TestSuite#queryUUID}}"}

    So that the structure is maintained but you parameter replace just the portion that is needed to fulfill the request.

    Regards,

    Todd