GraphQL + JSONObjects as variables

:wave: Hey everyone,

I'm connecting to a graphql resource, so far I have variables working, however when I try send a JSONObject as a variable my query fails - I get a error message back from the endpoint. I've tried writing the JSONObject into the variable field of the query, as well as setting it as a Javascript transformer myQuery and then referencing it into the graphql query get_objects

The graphql query get_objects looks something like this:

query ($idname: String!, $objectid: String!, $myQuery: [JSONObject!]) {
  stream(id: $idname) {
    object(id: $objectid) {
      totalChildrenCount
      children(query: $myQuery) {
        objects {
          data
        }
      }
    }
  }
}

with myQuery looking like:

{
  "myQuery": [
    {
      "field": "type",
      "value": "Objects.Other",
      "operator": "="
    }
  ]
}

I've tested with Postman and myQuery works fine. Is it not possible to use JSONObjects as variables? Am I formatting my JSONObject wrong?

Any help would be fantastic. :+1:

Hey @lukxf! This should be supported (from what I thought at least). Would you mind sharing a screenshot of your query? As well as a detailed preview (by clicking into the input field to pop the green preview box up) of the JSON input value itself?

1 Like

Hey @victoria~

I think I managed to get this to work: I was using {{myquery.value}} which was accessing the top level of my JSONObject. Changing the reference value so it was sending just the three keys worked i.e. only sending [{ "field": "type", "value": "Objects.Other", "operator": "=" }].

Hopefully makes sense? :sweat_smile:

Yup, definitely makes sense! So glad to hear it. All is well now? :slight_smile:

1 Like