graphql-python / graphql-python/graphene-mongo

Problem with EmbeddedFiled (Can't query via graphql

Offen
#152 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
287
Forks
111
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi Guys, Currently I set up a simple model, schema, type as below. However, I don't know why when I use EmbeddedField it works in the runtime (It doesn't show any runtime error) but I can't operate any query on this field.

`Error messge`
"Cannot query field \"metadata\" on type \"Scenario\"

Environment:
Python3.6
Python3.8

Computer system
Mac: MacOC

Models.py
```
# EmbeddedDocument Models
class Scenario(EmbeddedDocument):
name = models.StringField(max_length=100)
creationDatetime = models.DateTimeField()
lastUpdateDatetime = models.DateTimeField()
data = models.DictField()
cancellation = models.BooleanField(default=False)
isDefault = models.BooleanField(default=False)

# Document Models
class View(Document):
name = models.StringField(max_length=100)
scenarios = models.EmbeddedDocumentListField(Scenario)
cancellation = models.BooleanField(default=False)
```

Types.py
```
class ViewType(MongoengineObjectType):
class Meta:
model = View
interfaces = (relay.Node,)
```

Schema.py
```
class Query(graphene.ObjectType):
node = Node.Field()
view = MongoengineConnectionField(ViewType)
views = graphene.List(ViewType)

def resolve_views(self, info, name):
return View.objects.get(name=name)
```

Also, I have tried the solution on this issue as well
https://github.com/graphql-python/graphene-mongo/issues/32

I will get an error when I declare the reference model

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start by reviewing the EmbeddedDocument definitions in Models.py and how ViewType in Types.py exposes View through the Query fields in Schema.py. Reproduce the reported inability to query metadata or the embedded scenarios field and determine which schema behavior should be corrected so the embedded data is queryable without runtime errors.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
graphql, python
Bereich
api, database
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.