-
Notifications
You must be signed in to change notification settings - Fork 828
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
Query with "or" expression #681
Comments
@bwanglzu as far as I'm aware there is no such ability in the graphql spec: http://facebook.github.io/graphql/October2016/ Graphene is just a framework to implement a graphql server and so it must conform to the specification. If you want to allow your client to arbitrarily pass filters to your underlying data fetching method you could model it as a list argument as you suggested: class Query(graphene.ObjectType):
things = relay.ConnectionField(ThingConnection, or_filters=graphene.List(graphene.String) |
Thanks! @jkimbo , it works for me now! # backend
things = ConnectionField(ThingConnection, type=graphene.String())
# Graphiql front-end
query{
things(type: "a"){
edges{
node{
field_a
field_b
}
}
}
} And to query (filter) with a list of types: # graphene backend
things_by_type = ConnectionField(ThingConnection, type=graphene.List(graphene.String))
# Graphiql Front-end
query{
thingsByType(type: ["type_a", "type_b"]){
edges{
node{
field_a
field_b
}
}
}
} And also, it also supports for arguments: query($type:[String]){
thingsByType(type:$type){
edges{
node{
field_a
field_b
}
}
}
} need a parameter in {
"type": ["type_a", "type_b"]
} |
Great, glad I could help. Generally with graphql there is not a big overhead in having multiple ways to query the data since it's up the client to decide how to query. And it's usually better to be explicit with naming so what you've come up with looks great. |
In case you're using |
Hi everyone, maybe it's a stupid question, I'm new to graphene. Is it possible for me to query like this?
I mean the
type
argument could possibly be a String or multiple Strings (or a list).. I figured out that Django has something calleddjango_filter
.. But I'm using Flask.Thanks!
The text was updated successfully, but these errors were encountered: