How to filter the child of the main query?
See original GitHub issueI’m a relative newcomer to Graphene, I’m trying to make a query like this Query example
{
user(username: "Jon") {
name
last_lame
username
posts(in_draft : true) {
title
text
in_draft
update_at
}
}
}
Filter the posts that are in draft. Is this possible?
Query:
class Query(graphene.ObjectType):
user = graphene.Field(lambda: User, username=graphene.String())
def resolve_user(self, info, username):
query = User.get_query(info)
return query.filter(UserModel.username == username).first()
posts = graphene.List(lambda: Post, in_draft=graphene.Boolean())
def resolve_posts(self, info, in_draft):
query = Post.get_query(info)
return query.filter(PostModel.in_draft == in_draft).all()
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Subquerying filtering on main query field
!= to a field of the master. Account: Master Application__c : Child. Using Subquery: select acc.id,acc.Callista_Org_Unit_Code__c , ( ...
Read more >structure Access query to filter parent records on child record ...
I have a KitHdr table and a KitDlt table, and yes the KitDtl table is the child of the KitHdr table. There are...
Read more >How to filter the child entity while quering the parent in hibernate
2) HQL query is. SELECT eA FROM EntityA LEFT JOIN eA.entityBList eB WHERE eA.id =:id AND eB.modelPercent > 0.
Read more >How to Query a Parent-Child Tree in SQL | LearnSQL.com
Example 1: List All Children of 1 Parent. This is the simplest query, so I'll use it to make you more at ease...
Read more >Query parent object by filter on the child object
List<Contact> contacts = new List<Contact>([select name from contact where id in (select contactid from campaignmember where status = 'Sent')]);.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @aleks-fr, quick q re the code you provided above. While defining the
postsunderUserallows one to nest them thepostswont’ necessarily belong to the resolveduser.Is there a way to communicate the arguments of
resolve_userto the nestedresolve_postsso that posts can be limited to that user only?I am closing all old issues&PRs related to filtering. The discussion will continue in https://github.com/graphql-python/graphene-sqlalchemy/discussions/347 (WIP). A proposal for the implementation of filters is currently being worked on and will be posted there once it is ready.