@@ -16,17 +16,109 @@ import {
1616 GraphQLString
1717} from 'graphql' ;
1818
19+ const schemaString = `
20+ schema {
21+ query: Query
22+ mutation: Mutation
23+ }
24+
25+ type Query {
26+ hero(episode: Episode): Character
27+ search(query: String): [SearchResult]
28+ }
29+
30+ # The episodes in the Star Wars trilogy
31+ enum Episode {
32+ # Star Wars Episode IV: A New Hope, released in 1977.
33+ NEWHOPE
34+
35+ # Star Wars Episode V: The Empire Strikes Back, released in 1980.
36+ EMPIRE
37+
38+ # Star Wars Episode VI: Return of the Jedi, released in 1983.
39+ JEDI
40+ }
41+
42+ # A character from the Star Wars universe
43+ interface Character {
44+ # The ID of the character
45+ id: ID!
46+
47+ # The name of the character
48+ name: String!
49+
50+ # The friends of the character, or an empty list if they have none
51+ friends: [Character]
52+
53+ # The movies this character appears in
54+ appearsIn: [Episode]!
55+ }
56+
57+ # A humanoid creature from the Star Wars universe
58+ type Human implements Character {
59+ # The ID of the human
60+ id: ID!
61+
62+ # What this human calls themselves
63+ name: String!
64+
65+ # This human's friends, or an empty list if they have none
66+ friends: [Character]
67+
68+ # The movies this human appears in
69+ appearsIn: [Episode]!
70+
71+ # A list of starships this person has piloted, or an empty list if none
72+ starships: [Starship]
73+ }
74+
75+ # An autonomous mechanical character in the Star Wars universe
76+ type Droid implements Character {
77+ # The ID of the droid
78+ id: ID!
79+
80+ # What others call this droid
81+ name: String!
82+
83+ # This droid's friends, or an empty list if they have none
84+ friends: [Character]
85+
86+ # The movies this droid appears in
87+ appearsIn: [Episode]!
88+
89+ # This droid's primary function
90+ primaryFunction: String
91+ }
92+
93+ # Units of length
94+ enum LengthUnit {
95+ # The standard unit around the world
96+ METER
97+
98+ # Primarily used in the United States
99+ FOOT
100+ }
101+
102+ type Starship {
103+ # The ID of the starship
104+ id: ID!
105+
106+ # The name of the starship
107+ name: String!
108+
109+ # The length of the starship, in meters
110+ length(unit: LengthUnit = METER): Float!
111+ }
112+
113+ union SearchResult = Character | Starship
114+ ` ;
115+
116+
117+
118+
119+
120+
19121
20- /**
21- * This is designed to be an end-to-end test, demonstrating
22- * the full GraphQL stack.
23- *
24- * We will create a GraphQL schema that describes the major
25- * characters in the original Star Wars trilogy.
26- *
27- * NOTE: This may contain spoilers for the original Star
28- * Wars trilogy.
29- */
30122
31123/**
32124 * This defines a basic set of data for our Star Wars Schema.
0 commit comments