strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.87k stars 511 forks source link

Support comparison operators #3070

Open cikay opened 11 months ago

cikay commented 11 months ago

Strawberry should support comparison operators such as greater than, less than, starts with etc. strawbeery-graphql-django package supports it but strawberry should support it independent of an ORM.

Feature Request Type

Upvote & Fund

Fund with Polar

patrick91 commented 11 months ago

how should strawberry support them?

cikay commented 11 months ago

how should strawberry support them?

The basic support is to just add this type to the package

and document how to use it like below

@strawberry.type
class User:
    name: FilterLookup[str]

To make all fields as Lookup you can follow the same way in strawberry-graphql-django

@strawberry.input(lookups=True)
class User:
    firstname: str
    lastname: str

will be equivalent

@strawberry.input
class User:
    firstname: FilterLooup[str]
    lastname: FilterLookup[str]
patrick91 commented 11 months ago

I think this might be a case where this feature could be implemented in a 3rd party package 😊

/cc @bellini666

cikay commented 11 months ago

I have written an article about it by the way.

bellini666 commented 11 months ago

I think this might be a case where this feature could be implemented in a 3rd party package 😊

/cc @bellini666

I agree, specially because the implementation of those operators will be ORM specific.