1

Given data with unknown structure, I would like to find all instances of 'label'.

{
    label: 'test',
    ...,
    child: {
       label: 'another test',
       ...,
       child: {
           label: 'more info',
           ...,
       },
       child: {
           no-label: 'I do not have a label field',
           ...,
       }
    },
}

I would like to return something like the above, just w/out the "other" fields because I would need to know "where" the labels are. The trick is that not all items or children will have a label and the specific structure is unknown at query time. (there may or may not be children on any item, etc.)

Wayne F. Kaskie
  • 3,257
  • 5
  • 33
  • 43
  • do you want a recursive query? and do you know the max child of an item? – Henock Mar 23 '22 at 15:42
  • This question sounds a lot like this one. Does this help? https://stackoverflow.com/questions/34199982/how-to-query-all-the-graphql-type-fields-without-writing-a-long-query#:~:text=Yes%2C%20you%20can%20do%20this%20using%20introspection.%20Make,names%20will%20depend%20on%20your%20actual%20schema%2Ftype%20definition%29 – Ayush Gudipati Mar 23 '22 at 19:29
  • @Henock I suppose a recursive query would work. Can you Answer with an example? – Wayne F. Kaskie Mar 24 '22 at 15:58
  • @AyushGudipati That question is almost the opposite of what I want. That question wants all fields without specifying the name. I want to specify the name, and only get that one field, but at any level. – Wayne F. Kaskie Mar 24 '22 at 15:59

0 Answers0