[Custom Resolver] How to ensure the shape and depth of response matches the query

Hey there :wave:

My question regards the use of custom resolvers.

To be more specific, we have a hard time returning a response from the backend that matches the shape of the query requested from the front-end.

We are building an application that aggregates banking transactions.

Our main table is called Transaction.

We have designed a feature that clusters similar transactions.

To identify similar transactions, we deployed a custom function transactionMatch that takes a transaction id: ID as an argument and returns a TransactionManyResponse type as a response, which represents a set of similar transactions.

Our function works fine.

However, since the shape of the query is highly nested, it often happens that our front-end unwraps data that is not returned within the TransactionManyResponse.

Our response is not depth enough.

At first, to make sure our TransactionManyResponse provided from the backend covered all the use-cases requested from the front-end, we tended to over-fetch data. Which led to poor performances.

Ideally, we would like the resolver to return a response in which the shape and depth match exactly the shape and depth of the query.

With native resolvers (e.g. transaction, transactionsList, transactionUpdate, etc.) this works out of the box (e.g. you get exactly what you asked for).

However, with custom resolvers, this behavior doesn’t seem to work out of the box.

When using custom resolvers, how can we ensure the shape and depth of the response returned match the shape and depth of the query?

I hope my question is clear enough.

Thanks for your help,



Can you share an example of the custom response you’re trying to build?