|
| 1 | +# C. Appendix: Built-in Definitions |
| 2 | + |
| 3 | +## Scalars |
| 4 | + |
| 5 | +```graphql |
| 6 | +""" |
| 7 | +The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between |
| 8 | +-(2^31) and 2^31 - 1. |
| 9 | +""" |
| 10 | +scalar Int |
| 11 | + |
| 12 | +""" |
| 13 | +The `Float` scalar type represents signed double-precision fractional values as specified by |
| 14 | +[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). |
| 15 | +""" |
| 16 | +scalar Float |
| 17 | + |
| 18 | +""" |
| 19 | +The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is |
| 20 | +most often used by GraphQL to represent free-form human-readable text. |
| 21 | +""" |
| 22 | +scalar String |
| 23 | + |
| 24 | +""" |
| 25 | +The `Boolean` scalar type represents `true` or `false`. |
| 26 | +""" |
| 27 | +scalar Boolean |
| 28 | + |
| 29 | +""" |
| 30 | +The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. |
| 31 | +The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When |
| 32 | +expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as |
| 33 | +an ID. |
| 34 | +""" |
| 35 | +scalar ID |
| 36 | +``` |
| 37 | + |
| 38 | +## Directives |
| 39 | + |
| 40 | +```graphql |
| 41 | +""" |
| 42 | +Directs the executor to include this field or fragment only when the `if` argument is true |
| 43 | +""" |
| 44 | +directive @include( |
| 45 | + """ |
| 46 | + Included when true. |
| 47 | + """ |
| 48 | + if: Boolean! |
| 49 | +) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT |
| 50 | + |
| 51 | +""" |
| 52 | +Directs the executor to skip this field or fragment when the `if` argument is true. |
| 53 | +""" |
| 54 | +directive @skip( |
| 55 | + """ |
| 56 | + Skipped when true. |
| 57 | + """ |
| 58 | + if: Boolean! |
| 59 | +) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT |
| 60 | + |
| 61 | +""" |
| 62 | +Marks the field, argument, input field or enum value as deprecated |
| 63 | +""" |
| 64 | +directive @deprecated( |
| 65 | + """ |
| 66 | + The reason for the deprecation |
| 67 | + """ |
| 68 | + reason: String = "No longer supported" |
| 69 | +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION |
| 70 | + |
| 71 | +""" |
| 72 | +Exposes a URL that specifies the behaviour of this scalar. |
| 73 | +""" |
| 74 | +directive @specifiedBy( |
| 75 | + """ |
| 76 | + The URL that specifies the behaviour of this scalar. |
| 77 | + """ |
| 78 | + url: String! |
| 79 | +) on SCALAR |
| 80 | +``` |
| 81 | + |
| 82 | +## Introspection types |
| 83 | + |
| 84 | +```graphql |
| 85 | +""" |
| 86 | +A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives |
| 87 | +on the server, as well as the entry points for query, mutation, and subscription operations. |
| 88 | +""" |
| 89 | +type __Schema { |
| 90 | + description: String |
| 91 | + |
| 92 | + """ |
| 93 | + A list of all types supported by this server. |
| 94 | + """ |
| 95 | + types: [__Type!]! |
| 96 | + |
| 97 | + """ |
| 98 | + The type that query operations will be rooted at. |
| 99 | + """ |
| 100 | + queryType: __Type! |
| 101 | + |
| 102 | + """ |
| 103 | + If this server supports mutation, the type that mutation operations will be rooted at. |
| 104 | + """ |
| 105 | + mutationType: __Type |
| 106 | + |
| 107 | + """ |
| 108 | + If this server support subscription, the type that subscription operations will be rooted at. |
| 109 | + """ |
| 110 | + subscriptionType: __Type |
| 111 | + |
| 112 | + """ |
| 113 | + A list of all directives supported by this server. |
| 114 | + """ |
| 115 | + directives: [__Directive!]! |
| 116 | +} |
| 117 | + |
| 118 | +""" |
| 119 | +The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as |
| 120 | +represented by the `__TypeKind` enum. |
| 121 | +
|
| 122 | +Depending on the kind of a type, certain fields describe information about that type. |
| 123 | +""" |
| 124 | +type __Type { |
| 125 | + kind: __TypeKind! |
| 126 | + name: String |
| 127 | + description: String |
| 128 | + """ |
| 129 | + must be non-null for OBJECT and INTERFACE, otherwise null. |
| 130 | + """ |
| 131 | + fields(includeDeprecated: Boolean = false): [__Field!] |
| 132 | + """ |
| 133 | + must be non-null for OBJECT and INTERFACE, otherwise null. |
| 134 | + """ |
| 135 | + interfaces: [__Type!] |
| 136 | + """ |
| 137 | + must be non-null for INTERFACE and UNION, otherwise null. |
| 138 | + """ |
| 139 | + possibleTypes: [__Type!] |
| 140 | + """ |
| 141 | + must be non-null for ENUM, otherwise null. |
| 142 | + """ |
| 143 | + enumValues(includeDeprecated: Boolean = false): [__EnumValue!] |
| 144 | + """ |
| 145 | + must be non-null for INPUT_OBJECT, otherwise null. |
| 146 | + """ |
| 147 | + inputFields(includeDeprecated: Boolean = false): [__InputValue!] |
| 148 | + """ |
| 149 | + must be non-null for NON_NULL and LIST, otherwise null. |
| 150 | + """ |
| 151 | + ofType: __Type |
| 152 | + """ |
| 153 | + may be non-null for custom SCALAR, otherwise null. |
| 154 | + """ |
| 155 | + specifiedByURL: String |
| 156 | +} |
| 157 | + |
| 158 | +""" |
| 159 | +An enum describing what kind of type a given `__Type` is. |
| 160 | +""" |
| 161 | +enum __TypeKind { |
| 162 | + """ |
| 163 | + Indicates this type is a scalar. |
| 164 | + """ |
| 165 | + SCALAR |
| 166 | + |
| 167 | + """ |
| 168 | + Indicates this type is an object. `fields` and `interfaces` are valid fields. |
| 169 | + """ |
| 170 | + OBJECT |
| 171 | + |
| 172 | + """ |
| 173 | + Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields. |
| 174 | + """ |
| 175 | + INTERFACE |
| 176 | + |
| 177 | + """ |
| 178 | + Indicates this type is a union. `possibleTypes` is a valid field. |
| 179 | + """ |
| 180 | + UNION |
| 181 | + |
| 182 | + """ |
| 183 | + Indicates this type is an enum. `enumValues` is a valid field. |
| 184 | + """ |
| 185 | + ENUM |
| 186 | + |
| 187 | + """ |
| 188 | + Indicates this type is an input object. `inputFields` is a valid field. |
| 189 | + """ |
| 190 | + INPUT_OBJECT |
| 191 | + |
| 192 | + """ |
| 193 | + Indicates this type is a list. `ofType` is a valid field. |
| 194 | + """ |
| 195 | + LIST |
| 196 | + |
| 197 | + """ |
| 198 | + Indicates this type is a non-null. `ofType` is a valid field. |
| 199 | + """ |
| 200 | + NON_NULL |
| 201 | +} |
| 202 | + |
| 203 | +""" |
| 204 | +Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of |
| 205 | +arguments, and a return type. |
| 206 | +""" |
| 207 | +type __Field { |
| 208 | + name: String! |
| 209 | + description: String |
| 210 | + args(includeDeprecated: Boolean = false): [__InputValue!]! |
| 211 | + type: __Type! |
| 212 | + isDeprecated: Boolean! |
| 213 | + deprecationReason: String |
| 214 | +} |
| 215 | + |
| 216 | +""" |
| 217 | +Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input |
| 218 | +Values which describe their type and optionally a default value. |
| 219 | +""" |
| 220 | +type __InputValue { |
| 221 | + name: String! |
| 222 | + description: String |
| 223 | + type: __Type! |
| 224 | + |
| 225 | + """ |
| 226 | + A GraphQL-formatted string representing the default value for this input value. |
| 227 | + """ |
| 228 | + defaultValue: String |
| 229 | + isDeprecated: Boolean! |
| 230 | + deprecationReason: String |
| 231 | +} |
| 232 | + |
| 233 | +""" |
| 234 | +One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric |
| 235 | +value. However an Enum value is returned in a JSON response as a string. |
| 236 | +""" |
| 237 | +type __EnumValue { |
| 238 | + name: String! |
| 239 | + description: String |
| 240 | + isDeprecated: Boolean! |
| 241 | + deprecationReason: String |
| 242 | +} |
| 243 | + |
| 244 | +""" |
| 245 | +A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL |
| 246 | +document. |
| 247 | +
|
| 248 | +In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will |
| 249 | +not suffice, such as conditionally including or skipping a field. Directives provide this by describing |
| 250 | +additional information to the executor. |
| 251 | +""" |
| 252 | +type __Directive { |
| 253 | + name: String! |
| 254 | + description: String |
| 255 | + isRepeatable: Boolean! |
| 256 | + locations: [__DirectiveLocation!]! |
| 257 | + args(includeDeprecated: Boolean = false): [__InputValue!]! |
| 258 | +} |
| 259 | + |
| 260 | +""" |
| 261 | +A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such |
| 262 | +possible adjacencies. |
| 263 | +""" |
| 264 | +enum __DirectiveLocation { |
| 265 | + """ |
| 266 | + Location adjacent to a query operation. |
| 267 | + """ |
| 268 | + QUERY |
| 269 | + |
| 270 | + """ |
| 271 | + Location adjacent to a mutation operation. |
| 272 | + """ |
| 273 | + MUTATION |
| 274 | + |
| 275 | + """ |
| 276 | + Location adjacent to a subscription operation. |
| 277 | + """ |
| 278 | + SUBSCRIPTION |
| 279 | + |
| 280 | + """ |
| 281 | + Location adjacent to a field. |
| 282 | + """ |
| 283 | + FIELD |
| 284 | + |
| 285 | + """ |
| 286 | + Location adjacent to a fragment definition. |
| 287 | + """ |
| 288 | + FRAGMENT_DEFINITION |
| 289 | + |
| 290 | + """ |
| 291 | + Location adjacent to a fragment spread. |
| 292 | + """ |
| 293 | + FRAGMENT_SPREAD |
| 294 | + |
| 295 | + """ |
| 296 | + Location adjacent to an inline fragment. |
| 297 | + """ |
| 298 | + INLINE_FRAGMENT |
| 299 | + |
| 300 | + """ |
| 301 | + Location adjacent to a variable definition. |
| 302 | + """ |
| 303 | + VARIABLE_DEFINITION |
| 304 | + |
| 305 | + """ |
| 306 | + Location adjacent to a schema definition. |
| 307 | + """ |
| 308 | + SCHEMA |
| 309 | + |
| 310 | + """ |
| 311 | + Location adjacent to a scalar definition. |
| 312 | + """ |
| 313 | + SCALAR |
| 314 | + |
| 315 | + """ |
| 316 | + Location adjacent to an object type definition. |
| 317 | + """ |
| 318 | + OBJECT |
| 319 | + |
| 320 | + """ |
| 321 | + Location adjacent to a field definition. |
| 322 | + """ |
| 323 | + FIELD_DEFINITION |
| 324 | + |
| 325 | + """ |
| 326 | + Location adjacent to an argument definition. |
| 327 | + """ |
| 328 | + ARGUMENT_DEFINITION |
| 329 | + |
| 330 | + """ |
| 331 | + Location adjacent to an interface definition. |
| 332 | + """ |
| 333 | + INTERFACE |
| 334 | + |
| 335 | + """ |
| 336 | + Location adjacent to a union definition. |
| 337 | + """ |
| 338 | + UNION |
| 339 | + |
| 340 | + """ |
| 341 | + Location adjacent to an enum definition. |
| 342 | + """ |
| 343 | + ENUM |
| 344 | + |
| 345 | + """ |
| 346 | + Location adjacent to an enum value definition. |
| 347 | + """ |
| 348 | + ENUM_VALUE |
| 349 | + |
| 350 | + """ |
| 351 | + Location adjacent to an input object type definition. |
| 352 | + """ |
| 353 | + INPUT_OBJECT |
| 354 | + |
| 355 | + """ |
| 356 | + Location adjacent to an input object field definition. |
| 357 | + """ |
| 358 | + INPUT_FIELD_DEFINITION |
| 359 | +} |
| 360 | +``` |
0 commit comments