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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3506cc0860b7003f6ed0eb345f1cf3d578310422831035a71c63ecf9a4713cb2 |
|
MD5 | 9cb50d2c312412d6db65f921a485b638 |
|
BLAKE2b-256 | 9c195896aebef586f09107c9b57bc68a45bb583fc44966aad2b191340a8fcccf |
Close
Hashes for graphene_sqlalchemy_filter-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8603a536b71acfc4d3cfe4a7344b930056c15c2b43b350bd1cc79008d7ab072 |
|
MD5 | 66cbb9724caaa91c8b04ec1065324aba |
|
BLAKE2b-256 | b58e6d4a34a58567aff4da4b6203b51542abb8221c4977218f56cb501b41b6aa |