Hi All
Im not familiar with GraphQL. I can do some basic queries, but the query i want to do now is quite complex, and I’m struggling to write one.
I’ve used the beta connectors to upload some Civil 3D corridors, and im now using Python to try and download some of the data.
Could somebody help me with a query that would do the following?
Find all objects that have a “speckle_type” property equal to “Base”, the “type” equal to “baseline”, and “alignmentId” = “abc123”
This part i can do with the following code:
query($myQuery: [JSONObject!]) {
project(id: "f0447c2f94") {
object(id: "2113be889574eb3362b67e6d199ca940") {
id
children(query: $myQuery) {
totalCount
objects {
data
}
}
}
}
}
Variables:
{
"myQuery": [
{
"field": "speckle_type",
"value": "Base",
"operator": "="
},
{
"field": "type",
"value": "Baseline",
"operator": "="
},
{
"field": "alignmentId",
"value": "86104",
"operator": "="
}
]
}
This returns the following json results (ive heavily trimmed the data to just show the relevant parts i need to work with:
{
"data": {
"project": {
"object": {
"id": "2113be889574eb3362b67e6d199ca940",
"children": {
"totalCount": 1,
"objects": [
{
"data": {
"id": "4e4e5e5ddb0693187e66b23f6995e8cd",
"name": "BL_XL_M60_EB_HS_OS_0004",
"type": "Baseline",
"units": "m",
"elements": [
{
"id": "6aaa0892b32e1b3c729b62d8e318c1f0",
"name": "RG_A-M60-EB-ML-01_1",
"type": "BaselineRegion",
"units": "m",
"assembly": {
"id": "81d075ec446a89c3f1da5e3774a23165",
"name": "A-M60-EB-ML-01",
"type": "Assembly",
"speckle_type": "Base",
"applicationId": "77318",
"subassemblies": [
"..."
]
},
"endStation": 1057.5616426297522,
"speckle_type": "Base",
"startStation": 1042.8951959641888,
"applicationId": "989d2574-94f8-4aea-98cb-324879974315",
"appliedAssemblies": {
"1050": {"..." : "..."},
"1060": {"..." : "..."},
"1070": {"..." : "..."}
}
}]
}
}
]
}
}
}
}
}
I now need to amend my GraphQL query so that within the list of “elements” of the found “baseline” objects, it only returns elements which have a “type” of “BaselineRegion”.
Of those “BaselineRegion” objects, i want to go into the “appliedAssemblies” property and then return just the keys of the dictionary. So in the result above, i just want the following list of numbers returned
[ “1050”, “1060”, “1070”]
There could be multiple “Baseline” objects found, and more than likely will be multiple “baselineRegion” objects within them, so im expecting a list of lists to be returned
Is this query possible?
At the moment im just getting the list of baselines using GraphQL and then using python to travel through the tree to et the information i want, but the GraphQL call is returning far more information that i actually need (there is a huge amount of data within the “appliedAssemblies” and i dont need any of it other than the keys in the dictionary.
Any help appreciated!