Hi everyone! Thanks for taking the time to read this. I’m working on a project to be able to create an ETF-like structure out of nonprofits and ultimately hope to donate to a basket of such nonprofits following a custom weight distribution.
My current schema looks something like this -
type Cause {
name: String!
connections: [CauseWeights] @relation
charityRef: Charity
owner: User!
description: String
image: String
}
type Charity {
name: String! @unique
tags: [String!]
taxInfo: taxInfo
causeNode: Cause!
}
type CauseWeights {
parent: Cause! @relation
child: Cause!
weight: Float!
}
Sample graphql query and result
I was able to get this to work in the graphql playground and create connections between Causes but I’m not sure how to iterate through such a tree structure in a UDF. GQL works great to request data if you know how deep the structure goes, but the confusion comes in how to make it dynamic.
Ideally, I’d like a graphql query to start from a specific cause reference and return the entire tree underneath or, to be more specific, return a list of underlying charities and their ultimate weight.
For example, a cause with two connections.
1 50% ( 50% A and 50% B )
2. 50% B
Return (A: 0.25%, B: 0.75%)
Would greatly appreciate any advice or feedback on better ways to accomplish this goal. Thanks a lot!