Metadata-Version: 2.1
Name: graphene-sqlalchemy-filter
Version: 1.0.1
Summary: Filters for Graphene SQLAlchemy integration
Home-page: https://github.com/art1415926535/graphene-sqlalchemy-filter
Author: Artem Fedotov
License: MIT
Keywords: api graphql protocol rest relay graphene
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.6
Requires-Dist: graphene-sqlalchemy (<3,>=2.2.1)
Requires-Dist: SQLAlchemy (<2)

============================
graphene-sqlalchemy-filter
============================
Filters for `Graphene SQLAlchemy integration <https://github.com/graphql-python/graphene-sqlalchemy>`_

.. image:: https://github.com/art1415926535/graphene-sqlalchemy-filter/blob/master/preview.gif?raw=true

Quick start
-----------

Create a filter and add it to the graphene field.

.. code-block:: python

    from graphene_sqlalchemy_filter import FilterableConnectionField, FilterSet


    class UserFilter(FilterSet):
        is_admin = Boolean()

        class Meta:
            model = User
            fields = {
                'username': ['eq', 'ne', 'in', 'ilike'],
                'is_active': [...],  # shortcut!
            }

        @classmethod
        def is_admin_filter(cls, info, query, value):
            if value:
                return User.username == 'admin'
            else:
                return User.username != 'admin'


    class Query(ObjectType):
        all_users = FilterableConnectionField(UserConnection, filters=UserFilter())


Now, we're going to create query.

.. code-block::

    {
      allUsers (
        filters: {
          isActive: true,
          or: [
            {isAdmin: true},
            {usernameIn: ["moderator", "cool guy"]}
          ]
        }
      ){
        edges {
          node {
            id
            username
          }
        }
      }
    }


---------------

**Let's rock!**

