hasura / hasura/graphql-engine

Is it possible to inject/pass/cascade query params to a custom function?

Open
#7,488 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Hello everyone.

I wrote some custom functions that handle my business logic, it was exposed and working fine in Hasura so far.
However, my table is getting bigger (2 million records) and the function is getting poor performance, I already added indexes, added `limit`, `offset `params but the problem is the following:

Based on the query analysis, apparently, Hasura calls the function and gets all the results (returning the 2 million record), and after that filters according to the `where `/`limit`/`offset `conditions provided.

I already tried to rewrite the function to receive the `limit`, `offset`, and `order by` parameters but the problem is how to handle the `where `condition because it can be as complex as the parameters provided by the user.

Of course, I can write custom functions that receive specific parameters that handle the where clause as we need, however because of the number of tables it will be a mess dealing with a large set of different functions that need to be coded.

It would be nice to inject/pass/cascade the same query parameters to the function, similar as we can pass the hasura_session token. Any thoughts or am I missing something?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.