graphql-python / graphql-python/graphene-mongo

How do embeded documents without `id`?

Open
#179 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
287
Forks
111
PR merge metrics
No merged PRs in 30d

Description

i've spend a week already to find some solution for this.

i have next mongo models:

```
class Inner(EmbeddedDocument):
meta = {
'strict': False,
}
foo = fields.StringField()
bar = fields.StringField()

class Outer(Document):
meta = {
"collection": "outer",
"auto_create_index": False,
'strict': False,
}

fizz = fields.StringField(unique=True)
inner = fields.EmbeddedDocumentField(Inner, default=None)
```

Graphene nodes:
```
class InnerGraph(MongoengineObjectType):
class Meta:
model = Inner
interfaces = (relay.Node,)

class OuterGraph(MongoengineObjectType):
class Meta:
model = Outer
interfaces = (relay.Node,)
```

And graphene query
```
class Query(ObjectType):
patient_list = MongoengineConnectionField(OuterGraph)

# some resolver - removing it change nothing
```

Outer entity working fine, as expected, no problems.

But inner entity has `id` field (which is not exists in first place)
~And no other fields~ fixed.

Output in docs. Query -> Outer (edges, node) -> inner (type: InnerGraph)
```
InnerGraph
Fields
id ID!
The ID of the object.
Implements
Node
An object with an ID (edited)
```

Any ideas, how to make this combination work?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.