graphql 0.12.3 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/error/GraphQLError.js +2 -3
  2. package/error/GraphQLError.js.flow +3 -4
  3. package/{module/error/GraphQLError.js → error/GraphQLError.mjs} +2 -3
  4. package/error/formatError.js +1 -1
  5. package/error/formatError.js.flow +1 -1
  6. package/{module/error/formatError.js → error/formatError.mjs} +1 -1
  7. package/error/index.js.flow +1 -1
  8. package/{module/error/index.js → error/index.mjs} +1 -1
  9. package/error/locatedError.js +2 -1
  10. package/error/locatedError.js.flow +2 -1
  11. package/{module/error/locatedError.js → error/locatedError.mjs} +2 -1
  12. package/error/printError.js +1 -1
  13. package/error/printError.js.flow +1 -1
  14. package/{module/error/printError.js → error/printError.mjs} +1 -1
  15. package/error/syntaxError.js +1 -1
  16. package/error/syntaxError.js.flow +1 -1
  17. package/{module/error/syntaxError.js → error/syntaxError.mjs} +1 -1
  18. package/execution/execute.js +70 -90
  19. package/execution/execute.js.flow +83 -106
  20. package/{module/execution/execute.js → execution/execute.mjs} +53 -81
  21. package/execution/index.js.flow +1 -1
  22. package/{module/execution/index.js → execution/index.mjs} +1 -1
  23. package/execution/values.js +2 -6
  24. package/execution/values.js.flow +6 -7
  25. package/{module/execution/values.js → execution/values.mjs} +2 -2
  26. package/graphql.js +1 -1
  27. package/graphql.js.flow +3 -2
  28. package/{module/graphql.js → graphql.mjs} +1 -1
  29. package/index.js +24 -6
  30. package/index.js.flow +16 -2
  31. package/{module/index.js → index.mjs} +10 -2
  32. package/jsutils/MaybePromise.js +1 -0
  33. package/{module/jsutils/ObjMap.js.flow → jsutils/MaybePromise.js.flow} +2 -2
  34. package/{module/jsutils/ObjMap.js → jsutils/MaybePromise.mjs} +0 -0
  35. package/jsutils/ObjMap.js.flow +1 -1
  36. package/{module/language/ast.js → jsutils/ObjMap.mjs} +0 -0
  37. package/jsutils/dedent.js +23 -18
  38. package/jsutils/dedent.js.flow +21 -20
  39. package/jsutils/dedent.mjs +50 -0
  40. package/jsutils/find.js +1 -1
  41. package/jsutils/find.js.flow +1 -1
  42. package/{module/jsutils/find.js → jsutils/find.mjs} +1 -1
  43. package/jsutils/instanceOf.js +17 -16
  44. package/jsutils/instanceOf.js.flow +21 -15
  45. package/jsutils/instanceOf.mjs +31 -0
  46. package/jsutils/invariant.js +1 -1
  47. package/jsutils/invariant.js.flow +1 -1
  48. package/{module/jsutils/invariant.js → jsutils/invariant.mjs} +1 -1
  49. package/jsutils/isInvalid.js +1 -1
  50. package/jsutils/isInvalid.js.flow +1 -1
  51. package/{module/jsutils/isInvalid.js → jsutils/isInvalid.mjs} +1 -1
  52. package/jsutils/isNullish.js +1 -1
  53. package/jsutils/isNullish.js.flow +1 -1
  54. package/{module/jsutils/isNullish.js → jsutils/isNullish.mjs} +1 -1
  55. package/jsutils/isPromise.js +24 -0
  56. package/jsutils/isPromise.js.flow +20 -0
  57. package/jsutils/isPromise.mjs +18 -0
  58. package/jsutils/keyMap.js +1 -1
  59. package/jsutils/keyMap.js.flow +1 -1
  60. package/{module/jsutils/keyMap.js → jsutils/keyMap.mjs} +1 -1
  61. package/jsutils/keyValMap.js +1 -1
  62. package/jsutils/keyValMap.js.flow +1 -1
  63. package/{module/jsutils/keyValMap.js → jsutils/keyValMap.mjs} +1 -1
  64. package/jsutils/memoize3.js +48 -0
  65. package/jsutils/memoize3.js.flow +44 -0
  66. package/jsutils/memoize3.mjs +42 -0
  67. package/jsutils/objectValues.js +24 -0
  68. package/jsutils/objectValues.js.flow +18 -0
  69. package/jsutils/objectValues.mjs +19 -0
  70. package/jsutils/orList.js +1 -1
  71. package/jsutils/orList.js.flow +1 -1
  72. package/{module/jsutils/orList.js → jsutils/orList.mjs} +1 -1
  73. package/jsutils/promiseForObject.js +34 -0
  74. package/jsutils/promiseForObject.js.flow +30 -0
  75. package/jsutils/promiseForObject.mjs +28 -0
  76. package/jsutils/promiseReduce.js +34 -0
  77. package/jsutils/promiseReduce.js.flow +32 -0
  78. package/jsutils/promiseReduce.mjs +26 -0
  79. package/jsutils/quotedOrList.js +1 -1
  80. package/jsutils/quotedOrList.js.flow +1 -1
  81. package/{module/jsutils/quotedOrList.js → jsutils/quotedOrList.mjs} +1 -1
  82. package/jsutils/suggestionList.js +1 -1
  83. package/jsutils/suggestionList.js.flow +1 -1
  84. package/{module/jsutils/suggestionList.js → jsutils/suggestionList.mjs} +1 -1
  85. package/language/ast.js.flow +3 -30
  86. package/language/ast.mjs +0 -0
  87. package/language/blockStringValue.js +1 -1
  88. package/language/blockStringValue.js.flow +1 -1
  89. package/{module/language/blockStringValue.js → language/blockStringValue.mjs} +1 -1
  90. package/language/directiveLocation.js +3 -3
  91. package/language/directiveLocation.js.flow +4 -4
  92. package/{module/language/directiveLocation.js → language/directiveLocation.mjs} +3 -3
  93. package/language/index.js +10 -10
  94. package/language/index.js.flow +5 -4
  95. package/{module/language/index.js → language/index.mjs} +3 -3
  96. package/language/kinds.js +70 -71
  97. package/language/kinds.js.flow +71 -71
  98. package/language/kinds.mjs +79 -0
  99. package/language/lexer.js +73 -87
  100. package/language/lexer.js.flow +87 -93
  101. package/{module/language/lexer.js → language/lexer.mjs} +73 -87
  102. package/language/location.js +1 -1
  103. package/language/location.js.flow +1 -1
  104. package/{module/language/location.js → language/location.mjs} +1 -1
  105. package/language/parser.js +68 -58
  106. package/language/parser.js.flow +104 -110
  107. package/{module/language/parser.js → language/parser.mjs} +69 -59
  108. package/language/printer.js +52 -55
  109. package/language/printer.js.flow +74 -120
  110. package/{module/language/printer.js → language/printer.mjs} +52 -55
  111. package/language/source.js +1 -1
  112. package/language/source.js.flow +1 -1
  113. package/{module/language/source.js → language/source.mjs} +1 -1
  114. package/language/visitor.js +1 -1
  115. package/language/visitor.js.flow +1 -1
  116. package/{module/language/visitor.js → language/visitor.mjs} +1 -1
  117. package/package.json +4 -9
  118. package/subscription/asyncIteratorReject.js +1 -1
  119. package/subscription/asyncIteratorReject.js.flow +1 -1
  120. package/{module/subscription/asyncIteratorReject.js → subscription/asyncIteratorReject.mjs} +1 -1
  121. package/subscription/index.js.flow +1 -1
  122. package/{module/subscription/index.js → subscription/index.mjs} +1 -1
  123. package/subscription/mapAsyncIterator.js +3 -1
  124. package/subscription/mapAsyncIterator.js.flow +7 -4
  125. package/{module/subscription/mapAsyncIterator.js → subscription/mapAsyncIterator.mjs} +4 -1
  126. package/subscription/subscribe.js +1 -1
  127. package/subscription/subscribe.js.flow +1 -1
  128. package/{module/subscription/subscribe.js → subscription/subscribe.mjs} +1 -1
  129. package/type/definition.js +76 -10
  130. package/type/definition.js.flow +105 -13
  131. package/{module/type/definition.js → type/definition.mjs} +72 -4
  132. package/type/directives.js +4 -4
  133. package/type/directives.js.flow +3 -3
  134. package/{module/type/directives.js → type/directives.mjs} +8 -8
  135. package/type/index.js +2 -5
  136. package/type/index.js.flow +6 -5
  137. package/{module/type/index.js → type/index.mjs} +3 -5
  138. package/type/introspection.js +34 -41
  139. package/type/introspection.js.flow +7 -10
  140. package/{module/type/introspection.js → type/introspection.mjs} +6 -15
  141. package/type/scalars.js +6 -10
  142. package/type/scalars.js.flow +2 -2
  143. package/{module/type/scalars.js → type/scalars.mjs} +2 -2
  144. package/type/schema.js +39 -15
  145. package/type/schema.js.flow +73 -22
  146. package/{module/type/schema.js → type/schema.mjs} +37 -16
  147. package/type/validate.js +33 -30
  148. package/type/validate.js.flow +40 -37
  149. package/{module/type/validate.js → type/validate.mjs} +30 -30
  150. package/utilities/TypeInfo.js +23 -27
  151. package/utilities/TypeInfo.js.flow +2 -2
  152. package/{module/utilities/TypeInfo.js → utilities/TypeInfo.mjs} +2 -2
  153. package/utilities/assertValidName.js +2 -6
  154. package/utilities/assertValidName.js.flow +2 -10
  155. package/{module/utilities/assertValidName.js → utilities/assertValidName.mjs} +2 -6
  156. package/utilities/astFromValue.js +37 -37
  157. package/utilities/astFromValue.js.flow +36 -44
  158. package/{module/utilities/astFromValue.js → utilities/astFromValue.mjs} +26 -25
  159. package/utilities/buildASTSchema.js +65 -82
  160. package/utilities/buildASTSchema.js.flow +52 -59
  161. package/{module/utilities/buildASTSchema.js → utilities/buildASTSchema.mjs} +48 -62
  162. package/utilities/buildClientSchema.js +12 -15
  163. package/utilities/buildClientSchema.js.flow +7 -11
  164. package/{module/utilities/buildClientSchema.js → utilities/buildClientSchema.mjs} +4 -5
  165. package/utilities/coerceValue.js +1 -1
  166. package/utilities/coerceValue.js.flow +1 -1
  167. package/{module/utilities/coerceValue.js → utilities/coerceValue.mjs} +1 -1
  168. package/utilities/concatAST.js +1 -1
  169. package/utilities/concatAST.js.flow +1 -1
  170. package/{module/utilities/concatAST.js → utilities/concatAST.mjs} +1 -1
  171. package/utilities/extendSchema.js +91 -77
  172. package/utilities/extendSchema.js.flow +93 -68
  173. package/{module/utilities/extendSchema.js → utilities/extendSchema.mjs} +65 -52
  174. package/utilities/findBreakingChanges.js +1 -1
  175. package/utilities/findBreakingChanges.js.flow +1 -1
  176. package/{module/utilities/findBreakingChanges.js → utilities/findBreakingChanges.mjs} +1 -1
  177. package/utilities/findDeprecatedUsages.js +1 -1
  178. package/utilities/findDeprecatedUsages.js.flow +1 -1
  179. package/{module/utilities/findDeprecatedUsages.js → utilities/findDeprecatedUsages.mjs} +1 -1
  180. package/utilities/getOperationAST.js +2 -2
  181. package/utilities/getOperationAST.js.flow +3 -3
  182. package/{module/utilities/getOperationAST.js → utilities/getOperationAST.mjs} +3 -3
  183. package/utilities/index.js +30 -0
  184. package/utilities/index.js.flow +10 -3
  185. package/{module/utilities/index.js → utilities/index.mjs} +10 -3
  186. package/utilities/introspectionFromSchema.js +43 -0
  187. package/utilities/introspectionFromSchema.js.flow +37 -0
  188. package/utilities/introspectionFromSchema.mjs +31 -0
  189. package/utilities/introspectionQuery.js +1 -1
  190. package/utilities/introspectionQuery.js.flow +1 -1
  191. package/{module/utilities/introspectionQuery.js → utilities/introspectionQuery.mjs} +1 -1
  192. package/utilities/isValidJSValue.js +1 -1
  193. package/utilities/isValidJSValue.js.flow +1 -1
  194. package/{module/utilities/isValidJSValue.js → utilities/isValidJSValue.mjs} +1 -1
  195. package/utilities/isValidLiteralValue.js +8 -4
  196. package/utilities/isValidLiteralValue.js.flow +4 -4
  197. package/{module/utilities/isValidLiteralValue.js → utilities/isValidLiteralValue.mjs} +4 -4
  198. package/utilities/lexicographicSortSchema.js +243 -0
  199. package/utilities/lexicographicSortSchema.js.flow +198 -0
  200. package/utilities/lexicographicSortSchema.mjs +225 -0
  201. package/utilities/schemaPrinter.js +31 -29
  202. package/utilities/schemaPrinter.js.flow +28 -15
  203. package/{module/utilities/schemaPrinter.js → utilities/schemaPrinter.mjs} +21 -20
  204. package/utilities/separateOperations.js +1 -1
  205. package/utilities/separateOperations.js.flow +1 -1
  206. package/{module/utilities/separateOperations.js → utilities/separateOperations.mjs} +1 -1
  207. package/utilities/typeComparators.js +7 -10
  208. package/utilities/typeComparators.js.flow +7 -10
  209. package/{module/utilities/typeComparators.js → utilities/typeComparators.mjs} +7 -10
  210. package/utilities/typeFromAST.js +7 -11
  211. package/utilities/typeFromAST.js.flow +3 -3
  212. package/{module/utilities/typeFromAST.js → utilities/typeFromAST.mjs} +3 -3
  213. package/utilities/valueFromAST.js +26 -28
  214. package/utilities/valueFromAST.js.flow +14 -23
  215. package/{module/utilities/valueFromAST.js → utilities/valueFromAST.mjs} +9 -10
  216. package/utilities/valueFromASTUntyped.js +17 -22
  217. package/utilities/valueFromASTUntyped.js.flow +6 -7
  218. package/{module/utilities/valueFromASTUntyped.js → utilities/valueFromASTUntyped.mjs} +6 -7
  219. package/validation/ValidationContext.js +184 -0
  220. package/{module/validation/validate.js.flow → validation/ValidationContext.js.flow} +4 -60
  221. package/{module/validation/validate.js → validation/ValidationContext.mjs} +15 -57
  222. package/validation/index.js +12 -7
  223. package/validation/index.js.flow +6 -2
  224. package/{module/validation/index.js → validation/index.mjs} +6 -2
  225. package/validation/rules/ExecutableDefinitions.js +3 -3
  226. package/validation/rules/ExecutableDefinitions.js.flow +6 -10
  227. package/{module/validation/rules/ExecutableDefinitions.js → validation/rules/ExecutableDefinitions.mjs} +4 -4
  228. package/validation/rules/FieldsOnCorrectType.js +1 -1
  229. package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
  230. package/{module/validation/rules/FieldsOnCorrectType.js → validation/rules/FieldsOnCorrectType.mjs} +1 -1
  231. package/validation/rules/FragmentsOnCompositeTypes.js +1 -1
  232. package/validation/rules/FragmentsOnCompositeTypes.js.flow +2 -2
  233. package/{module/validation/rules/FragmentsOnCompositeTypes.js → validation/rules/FragmentsOnCompositeTypes.mjs} +1 -1
  234. package/validation/rules/KnownArgumentNames.js +3 -3
  235. package/validation/rules/KnownArgumentNames.js.flow +6 -8
  236. package/{module/validation/rules/KnownArgumentNames.js → validation/rules/KnownArgumentNames.mjs} +4 -4
  237. package/validation/rules/KnownDirectives.js +23 -27
  238. package/validation/rules/KnownDirectives.js.flow +3 -3
  239. package/{module/validation/rules/KnownDirectives.js → validation/rules/KnownDirectives.mjs} +2 -2
  240. package/validation/rules/KnownFragmentNames.js +1 -1
  241. package/validation/rules/KnownFragmentNames.js.flow +2 -2
  242. package/{module/validation/rules/KnownFragmentNames.js → validation/rules/KnownFragmentNames.mjs} +1 -1
  243. package/validation/rules/KnownTypeNames.js +1 -1
  244. package/validation/rules/KnownTypeNames.js.flow +2 -2
  245. package/{module/validation/rules/KnownTypeNames.js → validation/rules/KnownTypeNames.mjs} +1 -1
  246. package/validation/rules/LoneAnonymousOperation.js +2 -2
  247. package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
  248. package/{module/validation/rules/LoneAnonymousOperation.js → validation/rules/LoneAnonymousOperation.mjs} +3 -3
  249. package/validation/rules/NoFragmentCycles.js +1 -1
  250. package/validation/rules/NoFragmentCycles.js.flow +2 -2
  251. package/{module/validation/rules/NoFragmentCycles.js → validation/rules/NoFragmentCycles.mjs} +1 -1
  252. package/validation/rules/NoUndefinedVariables.js +1 -1
  253. package/validation/rules/NoUndefinedVariables.js.flow +2 -2
  254. package/{module/validation/rules/NoUndefinedVariables.js → validation/rules/NoUndefinedVariables.mjs} +1 -1
  255. package/validation/rules/NoUnusedFragments.js +1 -1
  256. package/validation/rules/NoUnusedFragments.js.flow +2 -2
  257. package/{module/validation/rules/NoUnusedFragments.js → validation/rules/NoUnusedFragments.mjs} +1 -1
  258. package/validation/rules/NoUnusedVariables.js +1 -1
  259. package/validation/rules/NoUnusedVariables.js.flow +2 -2
  260. package/{module/validation/rules/NoUnusedVariables.js → validation/rules/NoUnusedVariables.mjs} +1 -1
  261. package/validation/rules/OverlappingFieldsCanBeMerged.js +4 -8
  262. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +3 -3
  263. package/{module/validation/rules/OverlappingFieldsCanBeMerged.js → validation/rules/OverlappingFieldsCanBeMerged.mjs} +2 -2
  264. package/validation/rules/PossibleFragmentSpreads.js +1 -1
  265. package/validation/rules/PossibleFragmentSpreads.js.flow +2 -2
  266. package/{module/validation/rules/PossibleFragmentSpreads.js → validation/rules/PossibleFragmentSpreads.mjs} +1 -1
  267. package/validation/rules/ProvidedNonNullArguments.js +1 -1
  268. package/validation/rules/ProvidedNonNullArguments.js.flow +2 -2
  269. package/{module/validation/rules/ProvidedNonNullArguments.js → validation/rules/ProvidedNonNullArguments.mjs} +1 -1
  270. package/validation/rules/ScalarLeafs.js +1 -1
  271. package/validation/rules/ScalarLeafs.js.flow +2 -2
  272. package/{module/validation/rules/ScalarLeafs.js → validation/rules/ScalarLeafs.mjs} +1 -1
  273. package/validation/rules/SingleFieldSubscriptions.js +1 -1
  274. package/validation/rules/SingleFieldSubscriptions.js.flow +2 -2
  275. package/{module/validation/rules/SingleFieldSubscriptions.js → validation/rules/SingleFieldSubscriptions.mjs} +1 -1
  276. package/validation/rules/UniqueArgumentNames.js +1 -1
  277. package/validation/rules/UniqueArgumentNames.js.flow +2 -2
  278. package/{module/validation/rules/UniqueArgumentNames.js → validation/rules/UniqueArgumentNames.mjs} +1 -1
  279. package/validation/rules/UniqueDirectivesPerLocation.js +1 -1
  280. package/validation/rules/UniqueDirectivesPerLocation.js.flow +2 -2
  281. package/{module/validation/rules/UniqueDirectivesPerLocation.js → validation/rules/UniqueDirectivesPerLocation.mjs} +1 -1
  282. package/validation/rules/UniqueFragmentNames.js +1 -1
  283. package/validation/rules/UniqueFragmentNames.js.flow +2 -2
  284. package/{module/validation/rules/UniqueFragmentNames.js → validation/rules/UniqueFragmentNames.mjs} +1 -1
  285. package/validation/rules/UniqueInputFieldNames.js +1 -1
  286. package/validation/rules/UniqueInputFieldNames.js.flow +2 -2
  287. package/{module/validation/rules/UniqueInputFieldNames.js → validation/rules/UniqueInputFieldNames.mjs} +1 -1
  288. package/validation/rules/UniqueOperationNames.js +1 -1
  289. package/validation/rules/UniqueOperationNames.js.flow +2 -2
  290. package/{module/validation/rules/UniqueOperationNames.js → validation/rules/UniqueOperationNames.mjs} +1 -1
  291. package/validation/rules/UniqueVariableNames.js +1 -1
  292. package/validation/rules/UniqueVariableNames.js.flow +2 -2
  293. package/{module/validation/rules/UniqueVariableNames.js → validation/rules/UniqueVariableNames.mjs} +1 -1
  294. package/validation/rules/ValuesOfCorrectType.js +1 -1
  295. package/validation/rules/ValuesOfCorrectType.js.flow +2 -2
  296. package/{module/validation/rules/ValuesOfCorrectType.js → validation/rules/ValuesOfCorrectType.mjs} +1 -1
  297. package/validation/rules/VariablesAreInputTypes.js +1 -1
  298. package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
  299. package/{module/validation/rules/VariablesAreInputTypes.js → validation/rules/VariablesAreInputTypes.mjs} +1 -1
  300. package/validation/rules/VariablesDefaultValueAllowed.js +1 -1
  301. package/validation/rules/VariablesDefaultValueAllowed.js.flow +2 -2
  302. package/{module/validation/rules/VariablesDefaultValueAllowed.js → validation/rules/VariablesDefaultValueAllowed.mjs} +1 -1
  303. package/validation/rules/VariablesInAllowedPosition.js +9 -11
  304. package/validation/rules/VariablesInAllowedPosition.js.flow +3 -4
  305. package/{module/validation/rules/VariablesInAllowedPosition.js → validation/rules/VariablesInAllowedPosition.mjs} +2 -3
  306. package/validation/specifiedRules.js +1 -1
  307. package/validation/specifiedRules.js.flow +2 -2
  308. package/{module/validation/specifiedRules.js → validation/specifiedRules.mjs} +1 -1
  309. package/validation/validate.js +14 -175
  310. package/validation/validate.js.flow +3 -209
  311. package/validation/validate.mjs +57 -0
  312. package/module/error/GraphQLError.js.flow +0 -209
  313. package/module/error/formatError.js.flow +0 -34
  314. package/module/error/index.js.flow +0 -16
  315. package/module/error/locatedError.js.flow +0 -37
  316. package/module/error/printError.js.flow +0 -82
  317. package/module/error/syntaxError.js.flow +0 -25
  318. package/module/execution/execute.js.flow +0 -1375
  319. package/module/execution/index.js.flow +0 -13
  320. package/module/execution/values.js.flow +0 -206
  321. package/module/graphql.js.flow +0 -202
  322. package/module/index.js.flow +0 -389
  323. package/module/jsutils/dedent.js +0 -45
  324. package/module/jsutils/dedent.js.flow +0 -49
  325. package/module/jsutils/find.js.flow +0 -19
  326. package/module/jsutils/instanceOf.js +0 -27
  327. package/module/jsutils/instanceOf.js.flow +0 -44
  328. package/module/jsutils/invariant.js.flow +0 -15
  329. package/module/jsutils/isInvalid.js.flow +0 -15
  330. package/module/jsutils/isNullish.js.flow +0 -15
  331. package/module/jsutils/keyMap.js.flow +0 -43
  332. package/module/jsutils/keyValMap.js.flow +0 -38
  333. package/module/jsutils/orList.js.flow +0 -24
  334. package/module/jsutils/quotedOrList.js.flow +0 -17
  335. package/module/jsutils/suggestionList.js.flow +0 -94
  336. package/module/language/ast.js.flow +0 -594
  337. package/module/language/blockStringValue.js.flow +0 -64
  338. package/module/language/directiveLocation.js.flow +0 -39
  339. package/module/language/index.js.flow +0 -84
  340. package/module/language/kinds.js +0 -80
  341. package/module/language/kinds.js.flow +0 -80
  342. package/module/language/lexer.js.flow +0 -762
  343. package/module/language/location.js.flow +0 -34
  344. package/module/language/parser.js.flow +0 -1537
  345. package/module/language/printer.js.flow +0 -311
  346. package/module/language/source.js.flow +0 -43
  347. package/module/language/visitor.js.flow +0 -476
  348. package/module/subscription/asyncIteratorReject.js.flow +0 -41
  349. package/module/subscription/index.js.flow +0 -10
  350. package/module/subscription/mapAsyncIterator.js.flow +0 -78
  351. package/module/subscription/subscribe.js.flow +0 -288
  352. package/module/type/definition.js.flow +0 -1225
  353. package/module/type/directives.js.flow +0 -168
  354. package/module/type/index.js.flow +0 -156
  355. package/module/type/introspection.js.flow +0 -482
  356. package/module/type/scalars.js.flow +0 -158
  357. package/module/type/schema.js.flow +0 -271
  358. package/module/type/validate.js.flow +0 -723
  359. package/module/type/wrappers.js +0 -80
  360. package/module/type/wrappers.js.flow +0 -91
  361. package/module/utilities/TypeInfo.js.flow +0 -296
  362. package/module/utilities/assertValidName.js.flow +0 -56
  363. package/module/utilities/astFromValue.js.flow +0 -159
  364. package/module/utilities/buildASTSchema.js.flow +0 -518
  365. package/module/utilities/buildClientSchema.js.flow +0 -418
  366. package/module/utilities/coerceValue.js.flow +0 -257
  367. package/module/utilities/concatAST.js.flow +0 -29
  368. package/module/utilities/extendSchema.js.flow +0 -374
  369. package/module/utilities/findBreakingChanges.js.flow +0 -851
  370. package/module/utilities/findDeprecatedUsages.js.flow +0 -68
  371. package/module/utilities/getOperationAST.js.flow +0 -40
  372. package/module/utilities/index.js.flow +0 -111
  373. package/module/utilities/introspectionQuery.js.flow +0 -271
  374. package/module/utilities/isValidJSValue.js.flow +0 -22
  375. package/module/utilities/isValidLiteralValue.js.flow +0 -36
  376. package/module/utilities/schemaPrinter.js.flow +0 -402
  377. package/module/utilities/separateOperations.js.flow +0 -100
  378. package/module/utilities/typeComparators.js.flow +0 -135
  379. package/module/utilities/typeFromAST.js.flow +0 -56
  380. package/module/utilities/valueFromAST.js.flow +0 -184
  381. package/module/utilities/valueFromASTUntyped.js.flow +0 -64
  382. package/module/validation/index.js.flow +0 -138
  383. package/module/validation/rules/ExecutableDefinitions.js.flow +0 -52
  384. package/module/validation/rules/FieldsOnCorrectType.js.flow +0 -144
  385. package/module/validation/rules/FragmentsOnCompositeTypes.js.flow +0 -74
  386. package/module/validation/rules/KnownArgumentNames.js.flow +0 -98
  387. package/module/validation/rules/KnownDirectives.js.flow +0 -116
  388. package/module/validation/rules/KnownFragmentNames.js.flow +0 -36
  389. package/module/validation/rules/KnownTypeNames.js.flow +0 -59
  390. package/module/validation/rules/LoneAnonymousOperation.js.flow +0 -41
  391. package/module/validation/rules/NoFragmentCycles.js.flow +0 -85
  392. package/module/validation/rules/NoUndefinedVariables.js.flow +0 -57
  393. package/module/validation/rules/NoUnusedFragments.js.flow +0 -59
  394. package/module/validation/rules/NoUnusedVariables.js.flow +0 -62
  395. package/module/validation/rules/OverlappingFieldsCanBeMerged.js.flow +0 -847
  396. package/module/validation/rules/PossibleFragmentSpreads.js.flow +0 -94
  397. package/module/validation/rules/ProvidedNonNullArguments.js.flow +0 -105
  398. package/module/validation/rules/ScalarLeafs.js.flow +0 -69
  399. package/module/validation/rules/SingleFieldSubscriptions.js.flow +0 -44
  400. package/module/validation/rules/UniqueArgumentNames.js.flow +0 -48
  401. package/module/validation/rules/UniqueDirectivesPerLocation.js.flow +0 -57
  402. package/module/validation/rules/UniqueFragmentNames.js.flow +0 -42
  403. package/module/validation/rules/UniqueInputFieldNames.js.flow +0 -53
  404. package/module/validation/rules/UniqueOperationNames.js.flow +0 -44
  405. package/module/validation/rules/UniqueVariableNames.js.flow +0 -44
  406. package/module/validation/rules/ValuesOfCorrectType.js.flow +0 -218
  407. package/module/validation/rules/VariablesAreInputTypes.js.flow +0 -48
  408. package/module/validation/rules/VariablesDefaultValueAllowed.js.flow +0 -55
  409. package/module/validation/rules/VariablesInAllowedPosition.js.flow +0 -83
  410. package/module/validation/specifiedRules.js.flow +0 -127
  411. package/type/wrappers.js +0 -89
  412. package/type/wrappers.js.flow +0 -91
@@ -1,482 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow
8
- */
9
-
10
- import isInvalid from '../jsutils/isInvalid';
11
- import { astFromValue } from '../utilities/astFromValue';
12
- import { print } from '../language/printer';
13
- import {
14
- GraphQLObjectType,
15
- GraphQLEnumType,
16
- isScalarType,
17
- isObjectType,
18
- isInterfaceType,
19
- isUnionType,
20
- isEnumType,
21
- isInputObjectType,
22
- isListType,
23
- isNonNullType,
24
- isAbstractType,
25
- isNamedType,
26
- } from './definition';
27
- import { GraphQLList, GraphQLNonNull } from '../type/wrappers';
28
- import { GraphQLString, GraphQLBoolean } from './scalars';
29
- import { DirectiveLocation } from '../language/directiveLocation';
30
- import type { GraphQLField } from './definition';
31
-
32
- export const __Schema = new GraphQLObjectType({
33
- name: '__Schema',
34
- isIntrospection: true,
35
- description:
36
- 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' +
37
- 'exposes all available types and directives on the server, as well as ' +
38
- 'the entry points for query, mutation, and subscription operations.',
39
- fields: () => ({
40
- types: {
41
- description: 'A list of all types supported by this server.',
42
- type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__Type))),
43
- resolve(schema) {
44
- const typeMap = schema.getTypeMap();
45
- return Object.keys(typeMap).map(key => typeMap[key]);
46
- },
47
- },
48
- queryType: {
49
- description: 'The type that query operations will be rooted at.',
50
- type: GraphQLNonNull(__Type),
51
- resolve: schema => schema.getQueryType(),
52
- },
53
- mutationType: {
54
- description:
55
- 'If this server supports mutation, the type that ' +
56
- 'mutation operations will be rooted at.',
57
- type: __Type,
58
- resolve: schema => schema.getMutationType(),
59
- },
60
- subscriptionType: {
61
- description:
62
- 'If this server support subscription, the type that ' +
63
- 'subscription operations will be rooted at.',
64
- type: __Type,
65
- resolve: schema => schema.getSubscriptionType(),
66
- },
67
- directives: {
68
- description: 'A list of all directives supported by this server.',
69
- type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__Directive))),
70
- resolve: schema => schema.getDirectives(),
71
- },
72
- }),
73
- });
74
-
75
- export const __Directive = new GraphQLObjectType({
76
- name: '__Directive',
77
- isIntrospection: true,
78
- description:
79
- 'A Directive provides a way to describe alternate runtime execution and ' +
80
- 'type validation behavior in a GraphQL document.' +
81
- "\n\nIn some cases, you need to provide options to alter GraphQL's " +
82
- 'execution behavior in ways field arguments will not suffice, such as ' +
83
- 'conditionally including or skipping a field. Directives provide this by ' +
84
- 'describing additional information to the executor.',
85
- fields: () => ({
86
- name: { type: GraphQLNonNull(GraphQLString) },
87
- description: { type: GraphQLString },
88
- locations: {
89
- type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__DirectiveLocation))),
90
- },
91
- args: {
92
- type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue))),
93
- resolve: directive => directive.args || [],
94
- },
95
- // NOTE: the following three fields are deprecated and are no longer part
96
- // of the GraphQL specification.
97
- onOperation: {
98
- deprecationReason: 'Use `locations`.',
99
- type: GraphQLNonNull(GraphQLBoolean),
100
- resolve: d =>
101
- d.locations.indexOf(DirectiveLocation.QUERY) !== -1 ||
102
- d.locations.indexOf(DirectiveLocation.MUTATION) !== -1 ||
103
- d.locations.indexOf(DirectiveLocation.SUBSCRIPTION) !== -1,
104
- },
105
- onFragment: {
106
- deprecationReason: 'Use `locations`.',
107
- type: GraphQLNonNull(GraphQLBoolean),
108
- resolve: d =>
109
- d.locations.indexOf(DirectiveLocation.FRAGMENT_SPREAD) !== -1 ||
110
- d.locations.indexOf(DirectiveLocation.INLINE_FRAGMENT) !== -1 ||
111
- d.locations.indexOf(DirectiveLocation.FRAGMENT_DEFINITION) !== -1,
112
- },
113
- onField: {
114
- deprecationReason: 'Use `locations`.',
115
- type: GraphQLNonNull(GraphQLBoolean),
116
- resolve: d => d.locations.indexOf(DirectiveLocation.FIELD) !== -1,
117
- },
118
- }),
119
- });
120
-
121
- export const __DirectiveLocation = new GraphQLEnumType({
122
- name: '__DirectiveLocation',
123
- isIntrospection: true,
124
- description:
125
- 'A Directive can be adjacent to many parts of the GraphQL language, a ' +
126
- '__DirectiveLocation describes one such possible adjacencies.',
127
- values: {
128
- QUERY: {
129
- value: DirectiveLocation.QUERY,
130
- description: 'Location adjacent to a query operation.',
131
- },
132
- MUTATION: {
133
- value: DirectiveLocation.MUTATION,
134
- description: 'Location adjacent to a mutation operation.',
135
- },
136
- SUBSCRIPTION: {
137
- value: DirectiveLocation.SUBSCRIPTION,
138
- description: 'Location adjacent to a subscription operation.',
139
- },
140
- FIELD: {
141
- value: DirectiveLocation.FIELD,
142
- description: 'Location adjacent to a field.',
143
- },
144
- FRAGMENT_DEFINITION: {
145
- value: DirectiveLocation.FRAGMENT_DEFINITION,
146
- description: 'Location adjacent to a fragment definition.',
147
- },
148
- FRAGMENT_SPREAD: {
149
- value: DirectiveLocation.FRAGMENT_SPREAD,
150
- description: 'Location adjacent to a fragment spread.',
151
- },
152
- INLINE_FRAGMENT: {
153
- value: DirectiveLocation.INLINE_FRAGMENT,
154
- description: 'Location adjacent to an inline fragment.',
155
- },
156
- SCHEMA: {
157
- value: DirectiveLocation.SCHEMA,
158
- description: 'Location adjacent to a schema definition.',
159
- },
160
- SCALAR: {
161
- value: DirectiveLocation.SCALAR,
162
- description: 'Location adjacent to a scalar definition.',
163
- },
164
- OBJECT: {
165
- value: DirectiveLocation.OBJECT,
166
- description: 'Location adjacent to an object type definition.',
167
- },
168
- FIELD_DEFINITION: {
169
- value: DirectiveLocation.FIELD_DEFINITION,
170
- description: 'Location adjacent to a field definition.',
171
- },
172
- ARGUMENT_DEFINITION: {
173
- value: DirectiveLocation.ARGUMENT_DEFINITION,
174
- description: 'Location adjacent to an argument definition.',
175
- },
176
- INTERFACE: {
177
- value: DirectiveLocation.INTERFACE,
178
- description: 'Location adjacent to an interface definition.',
179
- },
180
- UNION: {
181
- value: DirectiveLocation.UNION,
182
- description: 'Location adjacent to a union definition.',
183
- },
184
- ENUM: {
185
- value: DirectiveLocation.ENUM,
186
- description: 'Location adjacent to an enum definition.',
187
- },
188
- ENUM_VALUE: {
189
- value: DirectiveLocation.ENUM_VALUE,
190
- description: 'Location adjacent to an enum value definition.',
191
- },
192
- INPUT_OBJECT: {
193
- value: DirectiveLocation.INPUT_OBJECT,
194
- description: 'Location adjacent to an input object type definition.',
195
- },
196
- INPUT_FIELD_DEFINITION: {
197
- value: DirectiveLocation.INPUT_FIELD_DEFINITION,
198
- description: 'Location adjacent to an input object field definition.',
199
- },
200
- },
201
- });
202
-
203
- export const __Type = new GraphQLObjectType({
204
- name: '__Type',
205
- isIntrospection: true,
206
- description:
207
- 'The fundamental unit of any GraphQL Schema is the type. There are ' +
208
- 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' +
209
- '\n\nDepending on the kind of a type, certain fields describe ' +
210
- 'information about that type. Scalar types provide no information ' +
211
- 'beyond a name and description, while Enum types provide their values. ' +
212
- 'Object and Interface types provide the fields they describe. Abstract ' +
213
- 'types, Union and Interface, provide the Object types possible ' +
214
- 'at runtime. List and NonNull types compose other types.',
215
- fields: () => ({
216
- kind: {
217
- type: GraphQLNonNull(__TypeKind),
218
- resolve(type) {
219
- if (isScalarType(type)) {
220
- return TypeKind.SCALAR;
221
- } else if (isObjectType(type)) {
222
- return TypeKind.OBJECT;
223
- } else if (isInterfaceType(type)) {
224
- return TypeKind.INTERFACE;
225
- } else if (isUnionType(type)) {
226
- return TypeKind.UNION;
227
- } else if (isEnumType(type)) {
228
- return TypeKind.ENUM;
229
- } else if (isInputObjectType(type)) {
230
- return TypeKind.INPUT_OBJECT;
231
- } else if (isListType(type)) {
232
- return TypeKind.LIST;
233
- } else if (isNonNullType(type)) {
234
- return TypeKind.NON_NULL;
235
- }
236
- throw new Error('Unknown kind of type: ' + type);
237
- },
238
- },
239
- name: { type: GraphQLString },
240
- description: { type: GraphQLString },
241
- fields: {
242
- type: GraphQLList(GraphQLNonNull(__Field)),
243
- args: {
244
- includeDeprecated: { type: GraphQLBoolean, defaultValue: false },
245
- },
246
- resolve(type, { includeDeprecated }) {
247
- if (isObjectType(type) || isInterfaceType(type)) {
248
- const fieldMap = type.getFields();
249
- let fields = Object.keys(fieldMap).map(
250
- fieldName => fieldMap[fieldName],
251
- );
252
- if (!includeDeprecated) {
253
- fields = fields.filter(field => !field.deprecationReason);
254
- }
255
- return fields;
256
- }
257
- return null;
258
- },
259
- },
260
- interfaces: {
261
- type: GraphQLList(GraphQLNonNull(__Type)),
262
- resolve(type) {
263
- if (isObjectType(type)) {
264
- return type.getInterfaces();
265
- }
266
- },
267
- },
268
- possibleTypes: {
269
- type: GraphQLList(GraphQLNonNull(__Type)),
270
- resolve(type, args, context, { schema }) {
271
- if (isAbstractType(type)) {
272
- return schema.getPossibleTypes(type);
273
- }
274
- },
275
- },
276
- enumValues: {
277
- type: GraphQLList(GraphQLNonNull(__EnumValue)),
278
- args: {
279
- includeDeprecated: { type: GraphQLBoolean, defaultValue: false },
280
- },
281
- resolve(type, { includeDeprecated }) {
282
- if (isEnumType(type)) {
283
- let values = type.getValues();
284
- if (!includeDeprecated) {
285
- values = values.filter(value => !value.deprecationReason);
286
- }
287
- return values;
288
- }
289
- },
290
- },
291
- inputFields: {
292
- type: GraphQLList(GraphQLNonNull(__InputValue)),
293
- resolve(type) {
294
- if (isInputObjectType(type)) {
295
- const fieldMap = type.getFields();
296
- return Object.keys(fieldMap).map(fieldName => fieldMap[fieldName]);
297
- }
298
- },
299
- },
300
- ofType: { type: __Type },
301
- }),
302
- });
303
-
304
- export const __Field = new GraphQLObjectType({
305
- name: '__Field',
306
- isIntrospection: true,
307
- description:
308
- 'Object and Interface types are described by a list of Fields, each of ' +
309
- 'which has a name, potentially a list of arguments, and a return type.',
310
- fields: () => ({
311
- name: { type: GraphQLNonNull(GraphQLString) },
312
- description: { type: GraphQLString },
313
- args: {
314
- type: GraphQLNonNull(GraphQLList(GraphQLNonNull(__InputValue))),
315
- resolve: field => field.args || [],
316
- },
317
- type: { type: GraphQLNonNull(__Type) },
318
- isDeprecated: { type: GraphQLNonNull(GraphQLBoolean) },
319
- deprecationReason: {
320
- type: GraphQLString,
321
- },
322
- }),
323
- });
324
-
325
- export const __InputValue = new GraphQLObjectType({
326
- name: '__InputValue',
327
- isIntrospection: true,
328
- description:
329
- 'Arguments provided to Fields or Directives and the input fields of an ' +
330
- 'InputObject are represented as Input Values which describe their type ' +
331
- 'and optionally a default value.',
332
- fields: () => ({
333
- name: { type: GraphQLNonNull(GraphQLString) },
334
- description: { type: GraphQLString },
335
- type: { type: GraphQLNonNull(__Type) },
336
- defaultValue: {
337
- type: GraphQLString,
338
- description:
339
- 'A GraphQL-formatted string representing the default value for this ' +
340
- 'input value.',
341
- resolve: inputVal =>
342
- isInvalid(inputVal.defaultValue)
343
- ? null
344
- : print(astFromValue(inputVal.defaultValue, inputVal.type)),
345
- },
346
- }),
347
- });
348
-
349
- export const __EnumValue = new GraphQLObjectType({
350
- name: '__EnumValue',
351
- isIntrospection: true,
352
- description:
353
- 'One possible value for a given Enum. Enum values are unique values, not ' +
354
- 'a placeholder for a string or numeric value. However an Enum value is ' +
355
- 'returned in a JSON response as a string.',
356
- fields: () => ({
357
- name: { type: GraphQLNonNull(GraphQLString) },
358
- description: { type: GraphQLString },
359
- isDeprecated: { type: GraphQLNonNull(GraphQLBoolean) },
360
- deprecationReason: {
361
- type: GraphQLString,
362
- },
363
- }),
364
- });
365
-
366
- export const TypeKind = {
367
- SCALAR: 'SCALAR',
368
- OBJECT: 'OBJECT',
369
- INTERFACE: 'INTERFACE',
370
- UNION: 'UNION',
371
- ENUM: 'ENUM',
372
- INPUT_OBJECT: 'INPUT_OBJECT',
373
- LIST: 'LIST',
374
- NON_NULL: 'NON_NULL',
375
- };
376
-
377
- export const __TypeKind = new GraphQLEnumType({
378
- name: '__TypeKind',
379
- isIntrospection: true,
380
- description: 'An enum describing what kind of type a given `__Type` is.',
381
- values: {
382
- SCALAR: {
383
- value: TypeKind.SCALAR,
384
- description: 'Indicates this type is a scalar.',
385
- },
386
- OBJECT: {
387
- value: TypeKind.OBJECT,
388
- description:
389
- 'Indicates this type is an object. ' +
390
- '`fields` and `interfaces` are valid fields.',
391
- },
392
- INTERFACE: {
393
- value: TypeKind.INTERFACE,
394
- description:
395
- 'Indicates this type is an interface. ' +
396
- '`fields` and `possibleTypes` are valid fields.',
397
- },
398
- UNION: {
399
- value: TypeKind.UNION,
400
- description:
401
- 'Indicates this type is a union. ' +
402
- '`possibleTypes` is a valid field.',
403
- },
404
- ENUM: {
405
- value: TypeKind.ENUM,
406
- description:
407
- 'Indicates this type is an enum. ' + '`enumValues` is a valid field.',
408
- },
409
- INPUT_OBJECT: {
410
- value: TypeKind.INPUT_OBJECT,
411
- description:
412
- 'Indicates this type is an input object. ' +
413
- '`inputFields` is a valid field.',
414
- },
415
- LIST: {
416
- value: TypeKind.LIST,
417
- description:
418
- 'Indicates this type is a list. ' + '`ofType` is a valid field.',
419
- },
420
- NON_NULL: {
421
- value: TypeKind.NON_NULL,
422
- description:
423
- 'Indicates this type is a non-null. ' + '`ofType` is a valid field.',
424
- },
425
- },
426
- });
427
-
428
- /**
429
- * Note that these are GraphQLField and not GraphQLFieldConfig,
430
- * so the format for args is different.
431
- */
432
-
433
- export const SchemaMetaFieldDef: GraphQLField<*, *> = {
434
- name: '__schema',
435
- type: GraphQLNonNull(__Schema),
436
- description: 'Access the current type schema of this server.',
437
- args: [],
438
- resolve: (source, args, context, { schema }) => schema,
439
- };
440
-
441
- export const TypeMetaFieldDef: GraphQLField<*, *> = {
442
- name: '__type',
443
- type: __Type,
444
- description: 'Request the type information of a single type.',
445
- args: [{ name: 'name', type: GraphQLNonNull(GraphQLString) }],
446
- resolve: (source, { name }, context, { schema }) => schema.getType(name),
447
- };
448
-
449
- export const TypeNameMetaFieldDef: GraphQLField<*, *> = {
450
- name: '__typename',
451
- type: GraphQLNonNull(GraphQLString),
452
- description: 'The name of the current Object type at runtime.',
453
- args: [],
454
- resolve: (source, args, context, { parentType }) => parentType.name,
455
- };
456
-
457
- export const introspectionTypes: $ReadOnlyArray<*> = [
458
- __Schema,
459
- __Directive,
460
- __DirectiveLocation,
461
- __Type,
462
- __Field,
463
- __InputValue,
464
- __EnumValue,
465
- __TypeKind,
466
- ];
467
-
468
- export function isIntrospectionType(type: mixed): boolean %checks {
469
- return (
470
- isNamedType(type) &&
471
- // Would prefer to use introspectionTypes.some(), however %checks needs
472
- // a simple expression.
473
- (type.name === __Schema.name ||
474
- type.name === __Directive.name ||
475
- type.name === __DirectiveLocation.name ||
476
- type.name === __Type.name ||
477
- type.name === __Field.name ||
478
- type.name === __InputValue.name ||
479
- type.name === __EnumValue.name ||
480
- type.name === __TypeKind.name)
481
- );
482
- }
@@ -1,158 +0,0 @@
1
- /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow
8
- */
9
-
10
- import { GraphQLScalarType, isNamedType } from './definition';
11
- import * as Kind from '../language/kinds';
12
-
13
- // As per the GraphQL Spec, Integers are only treated as valid when a valid
14
- // 32-bit signed integer, providing the broadest support across platforms.
15
- //
16
- // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
17
- // they are internally represented as IEEE 754 doubles.
18
- const MAX_INT = 2147483647;
19
- const MIN_INT = -2147483648;
20
-
21
- function coerceInt(value: mixed): ?number {
22
- if (value === '') {
23
- throw new TypeError(
24
- 'Int cannot represent non 32-bit signed integer value: (empty string)',
25
- );
26
- }
27
- const num = Number(value);
28
- if (num !== num || num > MAX_INT || num < MIN_INT) {
29
- throw new TypeError(
30
- 'Int cannot represent non 32-bit signed integer value: ' + String(value),
31
- );
32
- }
33
- const int = Math.floor(num);
34
- if (int !== num) {
35
- throw new TypeError(
36
- 'Int cannot represent non-integer value: ' + String(value),
37
- );
38
- }
39
- return int;
40
- }
41
-
42
- export const GraphQLInt = new GraphQLScalarType({
43
- name: 'Int',
44
- description:
45
- 'The `Int` scalar type represents non-fractional signed whole numeric ' +
46
- 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
47
- serialize: coerceInt,
48
- parseValue: coerceInt,
49
- parseLiteral(ast) {
50
- if (ast.kind === Kind.INT) {
51
- const num = parseInt(ast.value, 10);
52
- if (num <= MAX_INT && num >= MIN_INT) {
53
- return num;
54
- }
55
- }
56
- return undefined;
57
- },
58
- });
59
-
60
- function coerceFloat(value: mixed): ?number {
61
- if (value === '') {
62
- throw new TypeError(
63
- 'Float cannot represent non numeric value: (empty string)',
64
- );
65
- }
66
- const num = Number(value);
67
- if (num === num) {
68
- return num;
69
- }
70
- throw new TypeError(
71
- 'Float cannot represent non numeric value: ' + String(value),
72
- );
73
- }
74
-
75
- export const GraphQLFloat = new GraphQLScalarType({
76
- name: 'Float',
77
- description:
78
- 'The `Float` scalar type represents signed double-precision fractional ' +
79
- 'values as specified by ' +
80
- '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ',
81
- serialize: coerceFloat,
82
- parseValue: coerceFloat,
83
- parseLiteral(ast) {
84
- return ast.kind === Kind.FLOAT || ast.kind === Kind.INT
85
- ? parseFloat(ast.value)
86
- : undefined;
87
- },
88
- });
89
-
90
- function coerceString(value: mixed): ?string {
91
- if (Array.isArray(value)) {
92
- throw new TypeError(
93
- `String cannot represent an array value: [${String(value)}]`,
94
- );
95
- }
96
- return String(value);
97
- }
98
-
99
- export const GraphQLString = new GraphQLScalarType({
100
- name: 'String',
101
- description:
102
- 'The `String` scalar type represents textual data, represented as UTF-8 ' +
103
- 'character sequences. The String type is most often used by GraphQL to ' +
104
- 'represent free-form human-readable text.',
105
- serialize: coerceString,
106
- parseValue: coerceString,
107
- parseLiteral(ast) {
108
- return ast.kind === Kind.STRING ? ast.value : undefined;
109
- },
110
- });
111
-
112
- export const GraphQLBoolean = new GraphQLScalarType({
113
- name: 'Boolean',
114
- description: 'The `Boolean` scalar type represents `true` or `false`.',
115
- serialize: Boolean,
116
- parseValue: Boolean,
117
- parseLiteral(ast) {
118
- return ast.kind === Kind.BOOLEAN ? ast.value : undefined;
119
- },
120
- });
121
-
122
- export const GraphQLID = new GraphQLScalarType({
123
- name: 'ID',
124
- description:
125
- 'The `ID` scalar type represents a unique identifier, often used to ' +
126
- 'refetch an object or as key for a cache. The ID type appears in a JSON ' +
127
- 'response as a String; however, it is not intended to be human-readable. ' +
128
- 'When expected as an input type, any string (such as `"4"`) or integer ' +
129
- '(such as `4`) input value will be accepted as an ID.',
130
- serialize: String,
131
- parseValue: String,
132
- parseLiteral(ast) {
133
- return ast.kind === Kind.STRING || ast.kind === Kind.INT
134
- ? ast.value
135
- : undefined;
136
- },
137
- });
138
-
139
- export const specifiedScalarTypes: $ReadOnlyArray<*> = [
140
- GraphQLString,
141
- GraphQLInt,
142
- GraphQLFloat,
143
- GraphQLBoolean,
144
- GraphQLID,
145
- ];
146
-
147
- export function isSpecifiedScalarType(type: mixed): boolean %checks {
148
- return (
149
- isNamedType(type) &&
150
- // Would prefer to use specifiedScalarTypes.some(), however %checks needs
151
- // a simple expression.
152
- (type.name === GraphQLString.name ||
153
- type.name === GraphQLInt.name ||
154
- type.name === GraphQLFloat.name ||
155
- type.name === GraphQLBoolean.name ||
156
- type.name === GraphQLID.name)
157
- );
158
- }