-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Generic Filter Functionality #76
Comments
I love this, I think it's great 💯 I was bummed to find out we need to directly modify the existing objects in order to index specific block fields, like the proposer, but if this is a long term solution then I'm all for it @jinoosss what do you think? |
@zivkovicmilos @ajnavarro , |
Closed by #90 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
We are suffering from Feature Creep on the filtering side of GraphQL API implementation, and we can still not cover most of the use cases (we cannot filter blocks by the proposer, for example).
I did a quick research and it is possible to implement a plugin on gqlgen that can generate the filter objects we need to be able to filter by all the fields we want.
Proposal
Implement a
gqlgen
pluginWe can create a plugin implementing
CodeGenerator
interface:That will allow us to scan all existing objects in the schema, get their fields with their types, and generate the needed objects for applying the filtering.
Proposed Filter structure
A filter will contain And filters, Or filters, Not filter, and field filters. They will be composed as follows (we are using Block filter as an example):
That will allow us to create filters like:
That will be the same as:
Schema tagging for filter creation
We can scan the existing graphql schema to find specific annotations, and from that, generate the needed filters. Example:
That will allow us to create filters only from the types and fields we want/need. In the future we can be more specific, like only creating
eq
filter for a field: (# plugin:filter(types:[eq]))
)Special cases
We have filters that are used outside the filtering logic, for example, to query the storage (block height). We need to expose this values to retrieve them. One idea (still thinking if it is the best) will be add a special tag to these values to expose a method to retrieve the max and min values from the filters, something like:
Generating the following method in the generated filter struct:
The text was updated successfully, but these errors were encountered: