Skip to content

Commit d13d7c0

Browse files
committed
Improved django example
1 parent 0a395fe commit d13d7c0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/starwars_django/schema.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class Ship(DjangoNode):
15-
1615
class Meta:
1716
model = ShipModel
1817

@@ -21,15 +20,12 @@ def get_node(cls, id):
2120
return Ship(get_ship(id))
2221

2322

24-
@schema.register
2523
class Character(DjangoObjectType):
26-
2724
class Meta:
2825
model = CharacterModel
2926

3027

3128
class Faction(DjangoNode):
32-
3329
class Meta:
3430
model = FactionModel
3531

@@ -39,7 +35,6 @@ def get_node(cls, id):
3935

4036

4137
class IntroduceShip(relay.ClientIDMutation):
42-
4338
class Input:
4439
ship_name = graphene.StringField(required=True)
4540
faction_id = graphene.StringField(required=True)
@@ -79,5 +74,9 @@ class Mutation(graphene.ObjectType):
7974
introduce_ship = graphene.Field(IntroduceShip)
8075

8176

77+
# We register the Character Model because if not would be
78+
# inaccessible for the schema
79+
schema.register(Character)
80+
8281
schema.query = Query
8382
schema.mutation = Mutation

0 commit comments

Comments
 (0)