MCPcopy Index your code
hub / github.com/graphql-python/graphene-django / initialize

Function initialize

examples/starwars/data.py:4–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3
4def initialize():
5 human = Character(name="Human")
6 human.save()
7
8 droid = Character(name="Droid")
9 droid.save()
10
11 rebels = Faction(id="1", name="Alliance to Restore the Republic", hero=human)
12 rebels.save()
13
14 empire = Faction(id="2", name="Galactic Empire", hero=droid)
15 empire.save()
16
17 xwing = Ship(id="1", name="X-Wing", faction=rebels)
18 xwing.save()
19
20 human.ship = xwing
21 human.save()
22
23 ywing = Ship(id="2", name="Y-Wing", faction=rebels)
24 ywing.save()
25
26 awing = Ship(id="3", name="A-Wing", faction=rebels)
27 awing.save()
28
29 # Yeah, technically it's Corellian. But it flew in the service of the rebels,
30 # so for the purposes of this demo it's a rebel ship.
31 falcon = Ship(id="4", name="Millennium Falcon", faction=rebels)
32 falcon.save()
33
34 homeOne = Ship(id="5", name="Home One", faction=rebels)
35 homeOne.save()
36
37 tieFighter = Ship(id="6", name="TIE Fighter", faction=empire)
38 tieFighter.save()
39
40 tieInterceptor = Ship(id="7", name="TIE Interceptor", faction=empire)
41 tieInterceptor.save()
42
43 executor = Ship(id="8", name="Executor", faction=empire)
44 executor.save()
45
46
47def create_ship(ship_name, faction_id):

Calls 4

saveMethod · 0.80
CharacterClass · 0.70
FactionClass · 0.70
ShipClass · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…