sample.graphql.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. # GraphQL Schema Definition Language
  2. """
  3. Color value
  4. """
  5. scalar Color
  6. """
  7. Node interface
  8. - allows (re)fetch arbitrary entity only by ID
  9. - allows client side cache normalization
  10. See [Relay Global Object Identification Specification](https://facebook.github.io/relay/graphql/objectidentification.htm)
  11. """
  12. interface Node {
  13. """
  14. Globally unique identifier,
  15. typically `${__typename}:${dbId}`
  16. may be encoded in *base64*
  17. """
  18. id: ID!
  19. }
  20. """
  21. A character in the Star Wars Trilogy
  22. """
  23. interface Character {
  24. """
  25. The id of the character.
  26. """
  27. id: ID!
  28. """
  29. The name of the character.
  30. """
  31. name: String
  32. """
  33. The friends of the character, or an empty list if they have none.
  34. """
  35. friends: [Character]
  36. """
  37. Which movies they appear in
  38. """
  39. appearsIn: [Episode]
  40. """
  41. All secrets about their past
  42. """
  43. secretBackstory: String
  44. }
  45. """
  46. A mechanical creature in the Star Wars universe.
  47. """
  48. type Droid implements Character {
  49. """
  50. The id of the droid.
  51. """
  52. id: ID!
  53. """
  54. The name of the droid.
  55. """
  56. name: String
  57. """
  58. The friends of the droid, or an empty list if they have none.
  59. """
  60. friends: [Character]
  61. """
  62. Which movies they appear in.
  63. """
  64. appearsIn: [Episode]
  65. """
  66. Construction date and the name of the designer.
  67. """
  68. secretBackstory: String
  69. """
  70. The primary function of the droid.
  71. """
  72. primaryFunction: String
  73. """
  74. Chase color of the droid.
  75. """
  76. color: Color
  77. }
  78. # One of the films in the Star Wars Trilogy
  79. enum Episode {
  80. """
  81. Released in 1977.
  82. """
  83. NEWHOPE
  84. """
  85. Released in 1980.
  86. """
  87. EMPIRE
  88. """
  89. Released in 1983.
  90. """
  91. JEDI
  92. }
  93. """
  94. A humanoid creature in the Star Wars universe.
  95. """
  96. type Human implements Character {
  97. """
  98. The id of the human.
  99. """
  100. id: ID!
  101. """
  102. The name of the human.
  103. """
  104. name: String
  105. """
  106. The friends of the human, or an empty list if they have none.
  107. """
  108. friends: [Character]
  109. """
  110. Which movies they appear in.
  111. """
  112. appearsIn: [Episode]
  113. """
  114. The home planet of the human, or null if unknown.
  115. """
  116. homePlanet: String
  117. """
  118. Where are they from and how they came to be who they are.
  119. """
  120. secretBackstory: String
  121. }
  122. enum LengthUnit {
  123. METER
  124. FEET
  125. }
  126. type Starship {
  127. id: ID!
  128. name: String!
  129. length(unit: LengthUnit = METER): Float
  130. }
  131. union SearchResult = Human | Droid | Starship
  132. input SearchInput {
  133. name: String
  134. episode: Episode
  135. }
  136. """
  137. Root Query
  138. """
  139. type Query {
  140. """
  141. Return the hero by episode.
  142. """
  143. hero(
  144. """
  145. If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.
  146. """
  147. episode: Episode
  148. ): Character
  149. """
  150. Return the Human by ID.
  151. """
  152. human(
  153. """
  154. id of the human
  155. """
  156. id: ID!
  157. ): Human
  158. """
  159. Return the Droid by ID.
  160. """
  161. droid(
  162. """
  163. id of the droid
  164. """
  165. id: ID!
  166. ): Droid
  167. """
  168. Search everything by name
  169. __NOTE__: You should use Relay pagination
  170. """
  171. search(search: SearchInput!): [SearchResult]
  172. @deprecated(reason: "`search` will be replaced.")
  173. }
  174. """
  175. Root Mutation
  176. """
  177. type Mutation {
  178. """
  179. Save the favorite episode.
  180. """
  181. favorite(
  182. """
  183. Favorite episode.
  184. """
  185. episode: Episode!
  186. ): Episode
  187. }
  188. """
  189. Subscriptions — live events
  190. """
  191. type Subscription {
  192. """
  193. Message
  194. """
  195. message: String
  196. }
  197. extend type Query {
  198. """
  199. Dummy query for highlighting test
  200. """
  201. dummy(
  202. int: Int = 123
  203. float: Float = 123.456
  204. str: String = "Hello World!"
  205. boolDefaultTrue: Boolean = true
  206. boolDefaultFalse: Boolean = false
  207. id: ID
  208. search: SearchInput = null
  209. ): Boolean
  210. }
  211. schema {
  212. query: Query
  213. mutation: Mutation
  214. subscription: Subscription
  215. }
  216. # GraphQL Query Language
  217. query dummyQuery($int: Int) {
  218. dummy(int: $int)
  219. }
  220. mutation favoriteEpisode($episode: Episode) {
  221. favorite(episode: $episode)
  222. }