GraphQL select dynamic property

What is the syntax for selecting a dynamic property as part of a GraphQL query? I created a dynamic Material property, which shows up in the object data on querying without select, but cannot seem to isolate that field with a select. It returns nulls if just treated as text, and returns a syntax error on the SQL side if an @ prefix is included.

Response with Plain Text:

Response with Prefix:

Material field visible in 3d viewer:

error message for clarity:

"message": "select \"id\", \"createdAt\", \"speckleType\", \"totalChildrenCount\", jsonb_path_query(data, $1) as \"0\", jsonb_path_query(data, $2) as \"1\", jsonb_path_query(data, $3) as \"2\" from \"object_children_closure\" right join \"objects\" on \"objects\".\"streamId\" = \"object_children_closure\".\"streamId\" and \"objects\".\"id\" = \"object_children_closure\".\"child\" where object_children_closure.\"streamId\" = $4 AND parent = $5 and \"minDepth\" < $6 and id > $7 order by \"objects\".\"id\" asc limit $8 - syntax error, unexpected '@' at or near \"@\" of jsonpath input",
 "locations": [
        {
          "line": 4,
          "column": 7
        }
      ],
      "path": [
        "stream",
        "object",
        "children"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "length": 129,
          "name": "error",
          "severity": "ERROR",
          "code": "42601",
          "file": "jsonpath_scan.l",
          "line": "290",
          "routine": "jsonpath_yyerror"
        }
      }
    }
  ],
  "data": {
    "stream": {
      "object": null
    }
  }
}

can you send me a link to that object? i can try checking up what’s going wrong!

Here’s an isolated object in the set with the material:

Bad news first: issue is we should be properly "@"s in queries, and I can’t remember now how to do it properly - sigh. The good news: since the prop is just a string, you can not make it detached? As that doesn’t do anything on primitive types!

query{
  stream(id:"6d6cbc1bdf"){
    object(id:"ab1a4d9d2c58985b94648a4b105c011e" ){
      children(select:["Material"]){
        totalCount
        objects{
          data
        }
      }
    }
  }
}

The object explorer confused me - material is actually quite simple to get to:

think the issue might be in $myQuery?

Yeah I ended up changing it to a non-dynamic property, I just thought it was weird that it couldn’t parse @ and I couldn’t escape it either (i.e. trying "\@Material") since it’s not a reserved character for SQL.

1 Like