riverfr0zen / graphene-mongo-extras

Provides some additional functionality on top of graphene-mongo
MIT License
13 stars 0 forks source link

I am receiving AttributeError: type object 'MongoengineConnectionField' has no attribute 'name' #5

Open anilwarbhe opened 5 years ago

anilwarbhe commented 5 years ago

Again getting the same error AttributeError: type object 'MongoengineConnectionField' has no attribute 'name'

This time the culprit is

ListField(ReferenceField(City))

Please help me with fixing it. Thank you for making this package. Great Job!

riverfr0zen commented 5 years ago

I'm on vacation right now, but will look at it when I return in about a week.

In the meantime, can you post your model and gql type declarations so that I can try to reproduce? The ReferenceField within ListField is used in the unit tests successfully (see Game model here), so it might be something about your City model.

EDIT: Actually, now that I look at it, support for List of Reference fields is not yet implemented, as indicated in the README. Please see GameType and GameType2 here for how to exclude them until it is implemented (see the scores field mentions). Unfortunately I can't give you an estimate on when that will be right now.

anilwarbhe commented 5 years ago

:: Here is the Code::

# models.py
class City(Document):
    meta = {'collection': 'city'}
    cityname = StringField(required=True)

class TestSubs(EmbeddedDocument):
    meta = {'collection': 'testsubuscription'}
    id = StringField(primary_key=False)
    subname = StringField() 
    dta = DateTimeField()
    dtd = DateTimeField()
    showincity = ListField(ReferenceField(City))

class TestFilterDemo(Document):
    meta = {'collection':'testproducts'}
    name = StringField()
    description =  StringField()
    subs = EmbeddedDocumentListField(TestSubs)
# schema.py
from models import TestFilterDemo as TestFilterDemoModel
class TestFilterDemo(MongoengineObjectType):
    class Meta:
        model = TestFilterDemoModel
        interfaces = (Node,)

class Query(graphene.ObjectType):
    node = Node.Field()
    all_test_city_subs = FilteringConnectionField(TestFilterDemo)

schema = graphene.Schema(query=Query)

Throws Error: AttributeError: type object 'MongoengineConnectionField' has no attribute 'name'