I'm trying to import JSON files containing product categories with gatsby-transformer-json that contain multiple products with fields which have dynamic sub fields depending on the category they are in. There are hundreds of different categories so I would like to keep these subfields like "attributes" dynamic. They also might change over time. The client logic would handle this.
Unfortunately GraphQL only let's me query fields explicitly and the query needs to know all subfields.
This is the JSON:
{
"name": "Car Hifi",
"categorydesc": "This should be a very long text",
"products": [{
"name": "JVC KW-DB93BT",
"attributes": {
"Has USB": "JVC",
"compatible formats": {},
"Hands free": "true"
},
"advantages": {
"0": "More bass",
"1": "Less power consumption",
"2": "Simple UI"
}
}
]
}
and this a query:
query MyQuery {
dataJson {
name
categorydesc
products {
name
attributes {
// This should be dynamic
}
}
}
}