h-REA / hREA

A ValueFlows / REA economic network coordination system implemented on Holochain and with supplied Javascript GraphQL libraries
https://docs.hrea.io
Other
142 stars 15 forks source link

Agent simple inverse queries #312

Closed weswalla closed 2 years ago

weswalla commented 2 years ago

closes #298

weswalla commented 2 years ago

@Connoropolous @pospi there seems to be a gql level error when trying to query the commitmentsAsProvider/commitmentsAsReceiver fields of `agent, as done here: https://github.com/h-REA/hREA/blob/7f651d3424651fa16dbf38862a1276e0610b5699/test/agent/test_agent_links.js#L87 and here: https://github.com/h-REA/hREA/blob/7f651d3424651fa16dbf38862a1276e0610b5699/test/agent/test_agent_links.js#L96

The resolver functions aren't even executing: https://github.com/h-REA/hREA/blob/7f651d3424651fa16dbf38862a1276e0610b5699/modules/vf-graphql-holochain/resolvers/agent.ts#L57

which makes me suspect it has something to do with gql syntax and the fact that in the schema we define inputs: https://lab.allmende.io/valueflows/vf-schemas/vf-graphql/-/blob/sprout/lib/schemas/bridging/agent.commitment.gql#L53-54

Any ideas, do I need to define more input parameters to: https://github.com/h-REA/hREA/blob/7f651d3424651fa16dbf38862a1276e0610b5699/modules/vf-graphql-holochain/resolvers/agent.ts#L57

weswalla commented 2 years ago

I confirmed that the indexing is working properly and calling query_commitments returns the relevant CommitmentConnection object. So this is defintely a gql related issue, maybe something to do with the fact that Agent is an interface then Person and Organization implement that interface?

EDIT: actually the error does seem to be coming from zome side, something to do with construct_response

pospi commented 2 years ago

Glad you figured it out!

A couple of issues with those parameters- I would parameterize commitmentsAsReceiver too.

The other issue is passing all of them- it's actually considered undefined behavior to send all of them. You can omit after and before since we are starting from the end, and should only pass last to get the latest, not before. See https://relay.dev/graphql/connections.htm#sec-Pagination-algorithm for more info.

weswalla commented 2 years ago

@pospi there seems to be an error with get_link_fields: https://github.com/h-REA/hREA/blob/fc7d80565356e95e010610d5b866aa28e4166473/zomes/rea_agent/lib/src/lib.rs#L139-L165

It should be returning a vec of CommitmentAddresses, but it isn't. I'm assuming the error is either from read_index!() or create_index!() on the commitment side of things: https://github.com/h-REA/hREA/blob/fc7d80565356e95e010610d5b866aa28e4166473/zomes/rea_commitment/lib/src/lib.rs#L36

Although I'm a bit stumped as to why its not working.

To be more specific, I printed the output of the person query (in the api code), which should contain the commitmentsAsProvider and other related fields, but they are excluded from the object, which means these are empty vecs in get_link_fields

weswalla commented 2 years ago

@Connoropolous @pospi this is ready for review and should close #298