graphql-python / graphql-python/graphene-mongo
No ability to get QuerySet in relay.Connection when use custom resolver in graphene.ObjectType
- Vorherrschende Sprache
- Python
- Sterne
- 287
- Forks
- 111
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
When I want to add some custom resolver (some complicated filter for example) for graphene.ObjectType I will lose opportunity to get filtered count number in Connection and etc. Example:
```
class Connection(relay.Connection):
"""Connection class"""
class Meta:
"""Meta class"""
abstract = True
total_count = graphene.Int()
def resolve_total_count(root, info, **kwargs):
"""Counts total number of documents with filters"""
return root.iterable.count()
class SomeModel(MongoengineObjectType):
class Meta:
connection_class = Connection
class SomeQueryRely(graphene.ObjectType):
q = MongoengineConnectionField(SomeModel, filter_one = graphene.String(name="filter_one"), filter_two =graphene.String(name="filter_two"))
def resolve_q(self, info: GraphQLResolveInfo, **kwargs):
query: QuerySet = info.context.queryset
QuerySet.filter(Q(filter_one=kwargs["filter_one"]) | Q(filter_two=kwargs["filter_two"]))
return query
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start by tracing the custom resolver through MongoengineConnectionField and relay.Connection, focusing on how the resolver's QuerySet reaches the connection. Reproduce the example with filter_one and filter_two, then verify that the filtered QuerySet remains available for total_count and related connection fields.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, database
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100