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

Self referencing model #10

Closed
mehdiym opened this issue Feb 24, 2018 · 5 comments
Closed

Self referencing model #10

mehdiym opened this issue Feb 24, 2018 · 5 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@mehdiym
Copy link

mehdiym commented Feb 24, 2018

Hello and thx for your lib,

I'd like to self-reference a model, but I'm not sure how to do it as I'm quite new to Python, what I do is:

class Player(Document):
    created_on = DateTimeField(default=datetime.now, db_field='d')
    name = StringField(required=True, db_field='n')

Player.friends = ListField(ReferenceField(Player))

But I get an AttributeError: 'NoneType' object has no attribute '_type' in python3.6/site-packages/graphene_mongo/converter.py

Am I doing it wrong or is it not possible?

@abawchen
Copy link
Collaborator

abawchen commented Feb 25, 2018

@mehdiym:
It's a good point!

Graphene-Mongo does not support list of self-reference yet, and I am working on it now. Hope I can get back to you soon.

@abawchen
Copy link
Collaborator

@mehdiym : The feature is supported on the updated master or pypi 0.1.4, but I find another issue #12 during the self-reference implementation :(

Please let me know if you need anything of self-reference, if not, I will close this one, and will fix above issue in another pull request.

Thanks.

@mehdiym
Copy link
Author

mehdiym commented Feb 27, 2018

Thank you @abawchen it works great now :)
As I'd like to have friends specific fields (eg. affinity score), next thing I'll need is the support for list of embedded docs. Keep up the good work.

@abawchen
Copy link
Collaborator

abawchen commented Mar 1, 2018

@mehdiym : I am glad to notify you the version 0.1.5 is supporting ListField(EmbeddedDocumentField) now.

Your request makes me more productive. 😜

@mehdiym
Copy link
Author

mehdiym commented Mar 1, 2018

Wow, you did it fast, thank you very much. I'll try that soon (it's a personal project on my spare time, for now anyway)

abhinand-c referenced this issue in strollby/graphene-mongo Jun 12, 2023
Pass mutation to graphene schema
abhinand-c referenced this issue in strollby/graphene-mongo Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants