nautls / ergo-graphql

Ergo Platform GraphQL server
MIT License
16 stars 1 forks source link

Add a way to know if a box is being spent #23

Closed capt-nemo429 closed 2 years ago

capt-nemo429 commented 2 years ago

Currently, there is no way to know if a box is being used as an input in mempool. So I propose to add a boolean field called beingSpent in BoxResolver do address this as a one-query way.

If this field is selected in the query, it should return true if the boxId is present in node_u_inputs.

Observe that using @FieldResolver() decorator is not the best approach for this specific case, since it can result in multiple undesired database queries for a single GraphQL query. You can take a look at AddressResolver specifically at balance field to see a way to avoid this by using isFieldSelected function.