Open wahello opened 6 years ago
up
@nesdis this issue has been open for more than a year and no answer. Is there any chance of getting support for Graphene?
It turns out integrating graphene is pretty simple. I would even go so far as to say djongo makes it easier than using graphene-mongo. The one difference is that models using EmbeddedModelField
and ArrayModelField
require custom types. For example, if you have defined a model that is all standard django fields, you can just inherit from DjangoObjectType
in the type definition:
#model
class Player(models.Model):
uuid = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False, unique=True)
name = models.CharField(max_length=200)
class Meta:
abstract = True
def __str__(self):
return self.name
#graphql type
class PlayerType(DjangoObjectType):
class Meta:
model = Player
If you have a list of players, then use a custom type:
#model
class Game(models.Model):
players = models.ArrayModelField(
model_container=Player,
)
#graphene custom type
class GameType(graphene.ObjectType):
players = graphene.List(PlayerType)
Any update on this?
No updates?
How to integrate graphene-django?
Is there any example?