How to use the graphene-django.examples.starwars.models.Character function in graphene-django

To help you get started, we’ve selected a few graphene-django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / graphene / graphene-django / examples / starwars / models.py View on Github external
from __future__ import absolute_import

from django.db import models


class Character(models.Model):
    name = models.CharField(max_length=50)

    def __str__(self):
        return self.name


class Faction(models.Model):
    name = models.CharField(max_length=50)
    hero = models.ForeignKey(Character)

    def __str__(self):
        return self.name


class Ship(models.Model):
    name = models.CharField(max_length=50)
    faction = models.ForeignKey(Faction, related_name='ships')

    def __str__(self):
        return self.name
github graphql-python / graphene / graphene-django / examples / starwars / data.py View on Github external
def initialize():
    human = Character(
        name='Human'
    )
    human.save()

    droid = Character(
        name='Droid'
    )
    droid.save()

    rebels = Faction(
        id='1',
        name='Alliance to Restore the Republic',
        hero=human
    )
    rebels.save()

    empire = Faction(
        id='2',
        name='Galactic Empire',
        hero=droid
    )
github graphql-python / graphene / graphene-django / examples / starwars / data.py View on Github external
def initialize():
    human = Character(
        name='Human'
    )
    human.save()

    droid = Character(
        name='Droid'
    )
    droid.save()

    rebels = Faction(
        id='1',
        name='Alliance to Restore the Republic',
        hero=human
    )
    rebels.save()