class Chapter(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String, nullable=False)
chapter_id = db.Column(ForeignKey('go_tab_chapters.id'))
sub_chapters = relationship('Chapter', backref=backref('chapter', remote_side=[id]),
primaryjoin=id == chapter_id)
checklists = relationship(Checklist, backref=backref('chapter'), uselist=True)
Checklist.py
class Checklist(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String, nullable=False)
chapter_id = db.Column(ForeignKey('go_tab_chapters.id'))
This is my GraphQL entities:
class ChapterFilter(FilterSet):
class Meta:
model = Chapter
fields = {'name': [...]}
class ChecklistFilter(FilterSet):
class Meta:
model = Checklist
fields = {
'name': [...]
}
class CustomField(FilterableConnectionField):
filters = {
Chapter: ChapterFilter(),
Checklist: ChecklistFilter()
}
class ChapterNode(SQLAlchemyObjectType):
class Meta:
model = Chapter
interfaces = (graphene.relay.Node,)
connection_field_factory = CustomField.factory
class ChapterConnection(Connection):
class Meta:
node = ChapterNode
class ChecklistNode(SQLAlchemyObjectType):
class Meta:
model = Checklist
interfaces = (graphene.relay.Node,)
connection_field_factory = CustomField.factory
class ChecklistConnection(Connection):
class Meta:
node = ChecklistNode
I get the following error:
graphql.error.located_error.GraphQLLocatedError: Can't construct a join from Mapper|Chapter|chapters to Mapper|Chapter|chapters, they are the same entity
When I comment the following line the query works but not the nested filter:
class ChapterNode(SQLAlchemyObjectType):
class Meta:
model = Chapter
interfaces = (graphene.relay.Node,)
# connection_field_factory = CustomField.factory
First of all thanks for the awesome library! :)
I have a system with this sort of hierarchy:
Chapter.py
Checklist.py
This is my GraphQL entities:
When I'm trying to run the following query:
I get the following error:
graphql.error.located_error.GraphQLLocatedError: Can't construct a join from Mapper|Chapter|chapters to Mapper|Chapter|chapters, they are the same entity
When I comment the following line the query works but not the nested filter:
@art1415926535 , Can you please help?
Many thanks!