Skip to content
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

Default Filters for FindMany #5

Closed
ibrahimyaacob92 opened this issue Jul 2, 2022 · 4 comments
Closed

Default Filters for FindMany #5

ibrahimyaacob92 opened this issue Jul 2, 2022 · 4 comments

Comments

@ibrahimyaacob92
Copy link

Problem

Filters for list (find many) are not appear out of the box

Suggested solution

Have default optional filters like Hasura where we can filters based on other fields (columns) and it should be as powerful like having equal, greater than, lesser than and like.

@omar-dulaimi
Copy link
Owner

Hello @ibrahimyaacob92

I have heard of Hasura, but never really used it before. So, could you provide an example of what you want to achieve?

@ibrahimyaacob92
Copy link
Author

ibrahimyaacob92 commented Jul 3, 2022

hi @omar-dulaimi, let me share you this, in Hasura, its building the graphql API automagically and it includes all the necessary filters that you can think of.

example below:

query listOfUsers{
  users{
    username
    email
    age
    address_state
    address_city

  }
}

i can actually filter all the users based on any field and any method (equal, greater than, less than, like..)
next, the ordering is also included! I could actually order the user list based on the date created or their username alphabetically,
last of all, pagination is also comes out of the box by setting the offset and limit on the variables

image

its going to be a very big thing if this library able to pull this off. let me know if you need more detail, i'm very much happy to help

@omar-dulaimi
Copy link
Owner

Hey @ibrahimyaacob92

If I understood you correctly, I think what you want is already built and supported.

For example:

  .query("findManyCompany", {
    input: CompanyFindManySchema,
    async resolve({ ctx, input }) {
      const findManyCompany = await ctx.prisma.company.findMany(input);
      return findManyCompany;
    },
  })

The CompanyFindManySchema have the following keys, which can be used to filter the result:

where
orderBy
cursor
take
skip
distinct

If you go inside where, you could filter by field level as well. The operators you mentioned are also available, and they depend on the field type. This library was created to match Prisma's API.

Unless I got you wrong, please explain to me again :)

@omar-dulaimi
Copy link
Owner

Closing for cleanup purposes. Feel free to comment to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants