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

InputObjectType fields from models #65

Closed
nephew92 opened this issue Jan 17, 2019 · 7 comments
Closed

InputObjectType fields from models #65

nephew92 opened this issue Jan 17, 2019 · 7 comments
Labels

Comments

@nephew92
Copy link

I've used a MongoengineObjectType class to define the schema from model.
There's a way to use a reference model to define a InputObjectType or AbstractType class? Something like that:

class UserFields(graphene.AbstractType):
	class Meta:
		model = model.User

class User(graphene.ObjectType, UserFields):
	pass

class UserInput(graphene.InputObjectType, UserFields):
	pass


@abawchen
Copy link
Collaborator

@nephew92 : do you find a way to do it? if not, I will start to work on it recently.

@nephew92
Copy link
Author

@nephew92 : do you find a way to do it? if not, I will start to work on it recently.

hello @abawchen, I couldn't find a way to do this with graphene. I had to assign the fields from the model to InputObjectType manually, but I made my own function (and not beautiful) for this.

@abawchen
Copy link
Collaborator

@nephew92 : could you share your implementation? I can learn from it and try if I can hook (and refactor) it into graphene-mongo, thanks.

@codecakes
Copy link

the would help reduce verbosity. +1

@nephew92
Copy link
Author

@nephew92 : could you share your implementation? I can learn from it and try if I can hook (and refactor) it into graphene-mongo, thanks.

I can't help with this, sorry. I'd implemented that for a company that I don't have collaboration anymore, also I don't have repo backups neither I remember the code details to how I resolved this problem.

@BenoitToulet
Copy link
Contributor

BenoitToulet commented Nov 4, 2020

Hello, I just published on a fork, a simple implementation allowing interface and input graphene objects creation based on graphene_mongo....
https://github.com/BenoitToulet/graphene-mongo/tree/feat-support-inputs-and-interfaces
Maybe a candidate for future PR...

@abawchen
Copy link
Collaborator

close due to stale, feel free to re-open it.

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

No branches or pull requests

4 participants