Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do embeded documents without id? #179

Open
bm13kk opened this issue Jun 10, 2021 · 0 comments
Open

How do embeded documents without id? #179

bm13kk opened this issue Jun 10, 2021 · 0 comments

Comments

@bm13kk
Copy link

bm13kk commented Jun 10, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant