Filters for Graphene SQLAlchemy integration
Project description
Filters for Graphene SQLAlchemy integration
Quick start
Create a filter and add it to the graphene field.
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.
{
allUsers (
filters: {
isActive: true,
or: [
{isAdmin: true},
{usernameIn: ["moderator", "cool guy"]}
]
}
){
edges {
node {
id
username
}
}
}
}
Let’s rock!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for graphene-sqlalchemy-filter-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 216294325a624d7ebe8f561a31963b56d4cb83adede53c6555587171dec0bd84 |
|
MD5 | 8ae4b4254f3d8a88c02820651b9f1011 |
|
BLAKE2b-256 | fd9d334c10950b12a7a1c249ed00681a87a1927710e7021cb37eab5885e73556 |
Close
Hashes for graphene_sqlalchemy_filter-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eae611e6470a0cc102d526c52e79df60b4aab3add2026c3d45dd8905d77cc32a |
|
MD5 | 0fbe3edd3701efc9a319b6d287f6bc1a |
|
BLAKE2b-256 | a710e1fdf95df0539dfa55006c77e4aa61b024717f070c2359897e3b38a51e61 |