mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Improved django example
This commit is contained in:
parent
0a395fec58
commit
d13d7c0f68
|
@ -12,7 +12,6 @@ schema = graphene.Schema(name='Starwars Django Relay Schema')
|
|||
|
||||
|
||||
class Ship(DjangoNode):
|
||||
|
||||
class Meta:
|
||||
model = ShipModel
|
||||
|
||||
|
@ -21,15 +20,12 @@ class Ship(DjangoNode):
|
|||
return Ship(get_ship(id))
|
||||
|
||||
|
||||
@schema.register
|
||||
class Character(DjangoObjectType):
|
||||
|
||||
class Meta:
|
||||
model = CharacterModel
|
||||
|
||||
|
||||
class Faction(DjangoNode):
|
||||
|
||||
class Meta:
|
||||
model = FactionModel
|
||||
|
||||
|
@ -39,7 +35,6 @@ class Faction(DjangoNode):
|
|||
|
||||
|
||||
class IntroduceShip(relay.ClientIDMutation):
|
||||
|
||||
class Input:
|
||||
ship_name = graphene.StringField(required=True)
|
||||
faction_id = graphene.StringField(required=True)
|
||||
|
@ -79,5 +74,9 @@ class Mutation(graphene.ObjectType):
|
|||
introduce_ship = graphene.Field(IntroduceShip)
|
||||
|
||||
|
||||
# We register the Character Model because if not would be
|
||||
# inaccessible for the schema
|
||||
schema.register(Character)
|
||||
|
||||
schema.query = Query
|
||||
schema.mutation = Mutation
|
||||
|
|
Loading…
Reference in New Issue
Block a user