graphql 14.1.1 → 14.3.1

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 (377) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/error/GraphQLError.js +12 -10
  4. package/error/GraphQLError.js.flow +11 -6
  5. package/error/GraphQLError.mjs +20 -3
  6. package/error/formatError.js +2 -2
  7. package/error/formatError.js.flow +3 -3
  8. package/error/formatError.mjs +2 -2
  9. package/error/index.js +1 -1
  10. package/error/index.js.flow +5 -2
  11. package/error/index.mjs +2 -2
  12. package/error/locatedError.js +2 -2
  13. package/error/locatedError.js.flow +2 -2
  14. package/error/locatedError.mjs +2 -2
  15. package/error/printError.js +2 -2
  16. package/error/printError.js.flow +4 -5
  17. package/error/printError.mjs +2 -2
  18. package/error/syntaxError.js +2 -2
  19. package/error/syntaxError.js.flow +2 -2
  20. package/error/syntaxError.mjs +2 -2
  21. package/execution/execute.js +52 -37
  22. package/execution/execute.js.flow +66 -51
  23. package/execution/execute.mjs +50 -38
  24. package/execution/index.js +7 -1
  25. package/execution/index.js.flow +9 -4
  26. package/execution/index.mjs +3 -3
  27. package/execution/values.js +11 -11
  28. package/execution/values.js.flow +23 -19
  29. package/execution/values.mjs +11 -11
  30. package/graphql.js +13 -9
  31. package/graphql.js.flow +28 -10
  32. package/graphql.mjs +10 -9
  33. package/index.js +83 -53
  34. package/index.js.flow +60 -47
  35. package/index.mjs +26 -23
  36. package/jsutils/ObjMap.js +1 -1
  37. package/jsutils/ObjMap.js.flow +1 -1
  38. package/jsutils/ObjMap.mjs +1 -0
  39. package/jsutils/PromiseOrValue.js +1 -0
  40. package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
  41. package/jsutils/PromiseOrValue.mjs +1 -0
  42. package/jsutils/dedent.js +2 -2
  43. package/jsutils/dedent.js.flow +1 -1
  44. package/jsutils/dedent.mjs +2 -2
  45. package/jsutils/defineToJSON.js +2 -2
  46. package/jsutils/defineToJSON.js.flow +1 -1
  47. package/jsutils/defineToJSON.mjs +2 -2
  48. package/jsutils/defineToStringTag.js +2 -2
  49. package/jsutils/defineToStringTag.js.flow +1 -1
  50. package/jsutils/defineToStringTag.mjs +2 -2
  51. package/jsutils/inspect.js +94 -19
  52. package/jsutils/inspect.js.flow +98 -20
  53. package/jsutils/inspect.mjs +94 -20
  54. package/jsutils/instanceOf.js +2 -2
  55. package/jsutils/instanceOf.js.flow +1 -1
  56. package/jsutils/instanceOf.mjs +2 -2
  57. package/jsutils/invariant.js +5 -3
  58. package/jsutils/invariant.js.flow +3 -2
  59. package/jsutils/invariant.mjs +5 -3
  60. package/jsutils/isInvalid.js +2 -2
  61. package/jsutils/isInvalid.js.flow +1 -1
  62. package/jsutils/isInvalid.mjs +2 -2
  63. package/jsutils/isNullish.js +2 -2
  64. package/jsutils/isNullish.js.flow +1 -1
  65. package/jsutils/isNullish.mjs +2 -2
  66. package/jsutils/isPromise.js +2 -2
  67. package/jsutils/isPromise.js.flow +1 -1
  68. package/jsutils/isPromise.mjs +2 -2
  69. package/jsutils/keyMap.js +4 -3
  70. package/jsutils/keyMap.js.flow +6 -6
  71. package/jsutils/keyMap.mjs +4 -3
  72. package/jsutils/keyValMap.js +4 -3
  73. package/jsutils/keyValMap.js.flow +6 -6
  74. package/jsutils/keyValMap.mjs +4 -3
  75. package/jsutils/mapValue.js +2 -2
  76. package/jsutils/mapValue.js.flow +2 -2
  77. package/jsutils/mapValue.mjs +2 -2
  78. package/jsutils/memoize3.js +3 -3
  79. package/jsutils/memoize3.js.flow +2 -2
  80. package/jsutils/memoize3.mjs +3 -3
  81. package/jsutils/nodejsCustomInspectSymbol.js +2 -2
  82. package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
  83. package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
  84. package/jsutils/orList.js +2 -2
  85. package/jsutils/orList.js.flow +1 -1
  86. package/jsutils/orList.mjs +2 -2
  87. package/jsutils/promiseForObject.js +2 -2
  88. package/jsutils/promiseForObject.js.flow +2 -2
  89. package/jsutils/promiseForObject.mjs +2 -2
  90. package/jsutils/promiseReduce.js +2 -2
  91. package/jsutils/promiseReduce.js.flow +5 -5
  92. package/jsutils/promiseReduce.mjs +2 -2
  93. package/jsutils/quotedOrList.js +2 -2
  94. package/jsutils/quotedOrList.js.flow +1 -1
  95. package/jsutils/quotedOrList.mjs +2 -2
  96. package/jsutils/suggestionList.js +2 -2
  97. package/jsutils/suggestionList.js.flow +1 -1
  98. package/jsutils/suggestionList.mjs +2 -2
  99. package/language/ast.js +1 -1
  100. package/language/ast.js.flow +3 -3
  101. package/language/ast.mjs +1 -0
  102. package/language/blockString.js +114 -0
  103. package/language/blockString.js.flow +102 -0
  104. package/language/blockString.mjs +104 -0
  105. package/language/directiveLocation.js +2 -2
  106. package/language/directiveLocation.js.flow +1 -1
  107. package/language/directiveLocation.mjs +2 -2
  108. package/language/index.js +9 -9
  109. package/language/index.js.flow +10 -5
  110. package/language/index.mjs +3 -3
  111. package/language/kinds.js +2 -2
  112. package/language/kinds.js.flow +1 -1
  113. package/language/kinds.mjs +2 -2
  114. package/language/lexer.js +52 -44
  115. package/language/lexer.js.flow +65 -54
  116. package/language/lexer.mjs +49 -43
  117. package/language/location.js +2 -2
  118. package/language/location.js.flow +2 -2
  119. package/language/location.mjs +2 -2
  120. package/language/parser.js +75 -67
  121. package/language/parser.js.flow +138 -127
  122. package/language/parser.mjs +76 -68
  123. package/language/predicates.js +2 -2
  124. package/language/predicates.js.flow +2 -2
  125. package/language/predicates.mjs +2 -2
  126. package/language/printer.js +6 -14
  127. package/language/printer.js.flow +8 -17
  128. package/language/printer.mjs +5 -14
  129. package/language/source.js +2 -2
  130. package/language/source.js.flow +1 -1
  131. package/language/source.mjs +2 -2
  132. package/language/visitor.js +4 -6
  133. package/language/visitor.js.flow +3 -3
  134. package/language/visitor.mjs +4 -6
  135. package/package.json +1 -1
  136. package/polyfills/find.js +2 -2
  137. package/polyfills/find.js.flow +1 -1
  138. package/polyfills/find.mjs +2 -2
  139. package/polyfills/flatMap.js +38 -0
  140. package/polyfills/flatMap.js.flow +34 -0
  141. package/polyfills/flatMap.mjs +30 -0
  142. package/polyfills/isFinite.js +2 -2
  143. package/polyfills/isFinite.js.flow +1 -1
  144. package/polyfills/isFinite.mjs +2 -2
  145. package/polyfills/isInteger.js +2 -2
  146. package/polyfills/isInteger.js.flow +1 -1
  147. package/polyfills/isInteger.mjs +2 -2
  148. package/polyfills/objectEntries.js +2 -2
  149. package/polyfills/objectEntries.js.flow +2 -2
  150. package/polyfills/objectEntries.mjs +2 -2
  151. package/polyfills/objectValues.js +2 -2
  152. package/polyfills/objectValues.js.flow +2 -2
  153. package/polyfills/objectValues.mjs +2 -2
  154. package/subscription/asyncIteratorReject.js +1 -1
  155. package/subscription/asyncIteratorReject.js.flow +1 -1
  156. package/subscription/asyncIteratorReject.mjs +2 -2
  157. package/subscription/index.js +1 -1
  158. package/subscription/index.js.flow +1 -1
  159. package/subscription/index.mjs +2 -2
  160. package/subscription/mapAsyncIterator.js +1 -1
  161. package/subscription/mapAsyncIterator.js.flow +5 -5
  162. package/subscription/mapAsyncIterator.mjs +2 -2
  163. package/subscription/subscribe.js +2 -2
  164. package/subscription/subscribe.js.flow +6 -6
  165. package/subscription/subscribe.mjs +2 -2
  166. package/type/definition.js +138 -22
  167. package/type/definition.js.flow +184 -36
  168. package/type/definition.mjs +136 -23
  169. package/type/directives.js +14 -3
  170. package/type/directives.js.flow +24 -11
  171. package/type/directives.mjs +16 -5
  172. package/type/index.js +7 -7
  173. package/type/index.js.flow +8 -4
  174. package/type/index.mjs +10 -6
  175. package/type/introspection.js +14 -9
  176. package/type/introspection.js.flow +12 -18
  177. package/type/introspection.mjs +14 -9
  178. package/type/scalars.js +5 -4
  179. package/type/scalars.js.flow +4 -10
  180. package/type/scalars.mjs +7 -6
  181. package/type/schema.js +55 -3
  182. package/type/schema.js.flow +73 -17
  183. package/type/schema.mjs +56 -4
  184. package/type/validate.js +19 -47
  185. package/type/validate.js.flow +17 -29
  186. package/type/validate.mjs +18 -47
  187. package/utilities/TypeInfo.js +93 -73
  188. package/utilities/TypeInfo.js.flow +30 -23
  189. package/utilities/TypeInfo.mjs +93 -73
  190. package/utilities/assertValidName.js +2 -2
  191. package/utilities/assertValidName.js.flow +2 -2
  192. package/utilities/assertValidName.mjs +2 -2
  193. package/utilities/astFromValue.js +5 -4
  194. package/utilities/astFromValue.js.flow +8 -7
  195. package/utilities/astFromValue.mjs +7 -6
  196. package/utilities/buildASTSchema.js +63 -62
  197. package/utilities/buildASTSchema.js.flow +92 -108
  198. package/utilities/buildASTSchema.mjs +61 -62
  199. package/utilities/buildClientSchema.js +38 -45
  200. package/utilities/buildClientSchema.js.flow +66 -79
  201. package/utilities/buildClientSchema.mjs +37 -44
  202. package/utilities/coerceValue.js +6 -7
  203. package/utilities/coerceValue.js.flow +5 -4
  204. package/utilities/coerceValue.mjs +7 -8
  205. package/utilities/concatAST.js +9 -13
  206. package/utilities/concatAST.js.flow +4 -10
  207. package/utilities/concatAST.mjs +6 -13
  208. package/utilities/extendSchema.js +219 -511
  209. package/utilities/extendSchema.js.flow +195 -304
  210. package/utilities/extendSchema.mjs +218 -512
  211. package/utilities/findBreakingChanges.js +54 -95
  212. package/utilities/findBreakingChanges.js.flow +49 -47
  213. package/utilities/findBreakingChanges.mjs +80 -95
  214. package/utilities/findDeprecatedUsages.js +4 -4
  215. package/utilities/findDeprecatedUsages.js.flow +5 -5
  216. package/utilities/findDeprecatedUsages.mjs +4 -4
  217. package/utilities/getOperationAST.js +2 -2
  218. package/utilities/getOperationAST.js.flow +5 -2
  219. package/utilities/getOperationAST.mjs +2 -2
  220. package/utilities/getOperationRootType.js +24 -24
  221. package/utilities/getOperationRootType.js.flow +40 -35
  222. package/utilities/getOperationRootType.mjs +24 -24
  223. package/utilities/index.js +9 -1
  224. package/utilities/index.js.flow +13 -6
  225. package/utilities/index.mjs +13 -8
  226. package/utilities/introspectionFromSchema.js +6 -4
  227. package/utilities/introspectionFromSchema.js.flow +8 -7
  228. package/utilities/introspectionFromSchema.mjs +6 -5
  229. package/utilities/introspectionQuery.js +2 -2
  230. package/utilities/introspectionQuery.js.flow +2 -2
  231. package/utilities/introspectionQuery.mjs +2 -2
  232. package/utilities/isValidJSValue.js +4 -2
  233. package/utilities/isValidJSValue.js.flow +3 -2
  234. package/utilities/isValidJSValue.mjs +4 -2
  235. package/utilities/isValidLiteralValue.js +2 -2
  236. package/utilities/isValidLiteralValue.js.flow +4 -4
  237. package/utilities/isValidLiteralValue.mjs +2 -2
  238. package/utilities/lexicographicSortSchema.js +84 -123
  239. package/utilities/lexicographicSortSchema.js.flow +68 -96
  240. package/utilities/lexicographicSortSchema.mjs +84 -123
  241. package/utilities/schemaPrinter.js +47 -73
  242. package/utilities/schemaPrinter.js.flow +69 -120
  243. package/utilities/schemaPrinter.mjs +45 -72
  244. package/utilities/separateOperations.js +8 -12
  245. package/utilities/separateOperations.js.flow +6 -3
  246. package/utilities/separateOperations.mjs +8 -12
  247. package/utilities/stripIgnoredCharacters.js +140 -0
  248. package/utilities/stripIgnoredCharacters.js.flow +129 -0
  249. package/utilities/stripIgnoredCharacters.mjs +127 -0
  250. package/utilities/typeComparators.js +2 -2
  251. package/utilities/typeComparators.js.flow +4 -3
  252. package/utilities/typeComparators.mjs +2 -2
  253. package/utilities/typeFromAST.js +9 -4
  254. package/utilities/typeFromAST.js.flow +15 -9
  255. package/utilities/typeFromAST.mjs +6 -4
  256. package/utilities/valueFromAST.js +7 -4
  257. package/utilities/valueFromAST.js.flow +7 -5
  258. package/utilities/valueFromAST.mjs +6 -4
  259. package/utilities/valueFromASTUntyped.js +11 -6
  260. package/utilities/valueFromASTUntyped.js.flow +9 -5
  261. package/utilities/valueFromASTUntyped.mjs +10 -6
  262. package/validation/ValidationContext.js +1 -1
  263. package/validation/ValidationContext.js.flow +19 -20
  264. package/validation/ValidationContext.mjs +2 -2
  265. package/validation/index.js +1 -1
  266. package/validation/index.js.flow +2 -1
  267. package/validation/index.mjs +3 -2
  268. package/validation/rules/ExecutableDefinitions.js +3 -3
  269. package/validation/rules/ExecutableDefinitions.js.flow +4 -4
  270. package/validation/rules/ExecutableDefinitions.mjs +3 -3
  271. package/validation/rules/FieldsOnCorrectType.js +3 -3
  272. package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
  273. package/validation/rules/FieldsOnCorrectType.mjs +3 -3
  274. package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
  275. package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
  276. package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
  277. package/validation/rules/KnownArgumentNames.js +1 -1
  278. package/validation/rules/KnownArgumentNames.js.flow +5 -5
  279. package/validation/rules/KnownArgumentNames.mjs +2 -2
  280. package/validation/rules/KnownDirectives.js +8 -6
  281. package/validation/rules/KnownDirectives.js.flow +11 -9
  282. package/validation/rules/KnownDirectives.mjs +8 -6
  283. package/validation/rules/KnownFragmentNames.js +3 -3
  284. package/validation/rules/KnownFragmentNames.js.flow +4 -4
  285. package/validation/rules/KnownFragmentNames.mjs +3 -3
  286. package/validation/rules/KnownTypeNames.js +2 -2
  287. package/validation/rules/KnownTypeNames.js.flow +6 -6
  288. package/validation/rules/KnownTypeNames.mjs +2 -2
  289. package/validation/rules/LoneAnonymousOperation.js +3 -3
  290. package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
  291. package/validation/rules/LoneAnonymousOperation.mjs +3 -3
  292. package/validation/rules/LoneSchemaDefinition.js +2 -2
  293. package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
  294. package/validation/rules/LoneSchemaDefinition.mjs +2 -2
  295. package/validation/rules/NoFragmentCycles.js +2 -2
  296. package/validation/rules/NoFragmentCycles.js.flow +4 -4
  297. package/validation/rules/NoFragmentCycles.mjs +2 -2
  298. package/validation/rules/NoUndefinedVariables.js +2 -2
  299. package/validation/rules/NoUndefinedVariables.js.flow +3 -3
  300. package/validation/rules/NoUndefinedVariables.mjs +2 -2
  301. package/validation/rules/NoUnusedFragments.js +7 -7
  302. package/validation/rules/NoUnusedFragments.js.flow +4 -4
  303. package/validation/rules/NoUnusedFragments.mjs +7 -7
  304. package/validation/rules/NoUnusedVariables.js +5 -5
  305. package/validation/rules/NoUnusedVariables.js.flow +6 -5
  306. package/validation/rules/NoUnusedVariables.mjs +5 -5
  307. package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
  308. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
  309. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
  310. package/validation/rules/PossibleFragmentSpreads.js +4 -4
  311. package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
  312. package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
  313. package/validation/rules/PossibleTypeExtensions.js +3 -3
  314. package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
  315. package/validation/rules/PossibleTypeExtensions.mjs +4 -4
  316. package/validation/rules/ProvidedRequiredArguments.js +6 -8
  317. package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
  318. package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
  319. package/validation/rules/ScalarLeafs.js +4 -4
  320. package/validation/rules/ScalarLeafs.js.flow +6 -6
  321. package/validation/rules/ScalarLeafs.mjs +4 -4
  322. package/validation/rules/SingleFieldSubscriptions.js +2 -2
  323. package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
  324. package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
  325. package/validation/rules/UniqueArgumentNames.js +2 -2
  326. package/validation/rules/UniqueArgumentNames.js.flow +3 -3
  327. package/validation/rules/UniqueArgumentNames.mjs +2 -2
  328. package/validation/rules/UniqueDirectiveNames.js +2 -2
  329. package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
  330. package/validation/rules/UniqueDirectiveNames.mjs +2 -2
  331. package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
  332. package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
  333. package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
  334. package/validation/rules/UniqueEnumValueNames.js +4 -8
  335. package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
  336. package/validation/rules/UniqueEnumValueNames.mjs +4 -8
  337. package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
  338. package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
  339. package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
  340. package/validation/rules/UniqueFragmentNames.js +2 -2
  341. package/validation/rules/UniqueFragmentNames.js.flow +3 -3
  342. package/validation/rules/UniqueFragmentNames.mjs +2 -2
  343. package/validation/rules/UniqueInputFieldNames.js +2 -4
  344. package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
  345. package/validation/rules/UniqueInputFieldNames.mjs +2 -4
  346. package/validation/rules/UniqueOperationNames.js +2 -2
  347. package/validation/rules/UniqueOperationNames.js.flow +3 -3
  348. package/validation/rules/UniqueOperationNames.mjs +2 -2
  349. package/validation/rules/UniqueOperationTypes.js +2 -2
  350. package/validation/rules/UniqueOperationTypes.js.flow +3 -3
  351. package/validation/rules/UniqueOperationTypes.mjs +2 -2
  352. package/validation/rules/UniqueTypeNames.js +2 -2
  353. package/validation/rules/UniqueTypeNames.js.flow +4 -4
  354. package/validation/rules/UniqueTypeNames.mjs +2 -2
  355. package/validation/rules/UniqueVariableNames.js +2 -2
  356. package/validation/rules/UniqueVariableNames.js.flow +4 -4
  357. package/validation/rules/UniqueVariableNames.mjs +2 -2
  358. package/validation/rules/ValuesOfCorrectType.js +2 -2
  359. package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
  360. package/validation/rules/ValuesOfCorrectType.mjs +2 -2
  361. package/validation/rules/VariablesAreInputTypes.js +3 -3
  362. package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
  363. package/validation/rules/VariablesAreInputTypes.mjs +3 -3
  364. package/validation/rules/VariablesInAllowedPosition.js +3 -3
  365. package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
  366. package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
  367. package/validation/specifiedRules.js +2 -2
  368. package/validation/specifiedRules.js.flow +13 -6
  369. package/validation/specifiedRules.mjs +7 -7
  370. package/validation/validate.js +2 -2
  371. package/validation/validate.js.flow +10 -6
  372. package/validation/validate.mjs +2 -2
  373. package/jsutils/MaybePromise.js +0 -1
  374. package/jsutils/MaybePromise.mjs +0 -0
  375. package/language/blockStringValue.js +0 -73
  376. package/language/blockStringValue.js.flow +0 -64
  377. package/language/blockStringValue.mjs +0 -66
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  /**
8
- * Copyright (c) 2015-present, Facebook, Inc.
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
9
  *
10
10
  * This source code is licensed under the MIT license found in the
11
11
  * LICENSE file in the root directory of this source tree.
@@ -19,6 +19,7 @@ import instanceOf from '../jsutils/instanceOf';
19
19
  import inspect from '../jsutils/inspect';
20
20
  import invariant from '../jsutils/invariant';
21
21
  import keyMap from '../jsutils/keyMap';
22
+ import keyValMap from '../jsutils/keyValMap';
22
23
  import mapValue from '../jsutils/mapValue';
23
24
  import { Kind } from '../language/kinds';
24
25
  import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped';
@@ -182,8 +183,10 @@ export function GraphQLList(ofType) {
182
183
 
183
184
  GraphQLList.prototype.toString = function toString() {
184
185
  return '[' + String(this.ofType) + ']';
185
- };
186
+ }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
186
187
 
188
+
189
+ defineToStringTag(GraphQLList);
187
190
  defineToJSON(GraphQLList);
188
191
  /**
189
192
  * Non-Null Type Wrapper
@@ -217,8 +220,10 @@ export function GraphQLNonNull(ofType) {
217
220
 
218
221
  GraphQLNonNull.prototype.toString = function toString() {
219
222
  return String(this.ofType) + '!';
220
- };
223
+ }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
224
+
221
225
 
226
+ defineToStringTag(GraphQLNonNull);
222
227
  defineToJSON(GraphQLNonNull);
223
228
  /**
224
229
  * These types wrap and modify other types
@@ -284,6 +289,10 @@ function resolveThunk(thunk) {
284
289
  // $FlowFixMe(>=0.90.0)
285
290
  return typeof thunk === 'function' ? thunk() : thunk;
286
291
  }
292
+
293
+ function undefineIfEmpty(arr) {
294
+ return arr && arr.length > 0 ? arr : undefined;
295
+ }
287
296
  /**
288
297
  * Scalar Type Definition
289
298
  *
@@ -324,7 +333,7 @@ function () {
324
333
 
325
334
  this.parseLiteral = config.parseLiteral || valueFromASTUntyped;
326
335
  this.astNode = config.astNode;
327
- this.extensionASTNodes = config.extensionASTNodes;
336
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
328
337
  !(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
329
338
  !(typeof config.serialize === 'function') ? invariant(0, "".concat(this.name, " must provide \"serialize\" function. If this custom Scalar ") + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.') : void 0;
330
339
 
@@ -335,6 +344,18 @@ function () {
335
344
 
336
345
  var _proto = GraphQLScalarType.prototype;
337
346
 
347
+ _proto.toConfig = function toConfig() {
348
+ return {
349
+ name: this.name,
350
+ description: this.description,
351
+ serialize: this.serialize,
352
+ parseValue: this.parseValue,
353
+ parseLiteral: this.parseLiteral,
354
+ astNode: this.astNode,
355
+ extensionASTNodes: this.extensionASTNodes || []
356
+ };
357
+ };
358
+
338
359
  _proto.toString = function toString() {
339
360
  return this.name;
340
361
  };
@@ -389,7 +410,7 @@ function () {
389
410
  this.name = config.name;
390
411
  this.description = config.description;
391
412
  this.astNode = config.astNode;
392
- this.extensionASTNodes = config.extensionASTNodes;
413
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
393
414
  this.isTypeOf = config.isTypeOf;
394
415
  this._fields = defineFieldMap.bind(undefined, config);
395
416
  this._interfaces = defineInterfaces.bind(undefined, config);
@@ -415,6 +436,18 @@ function () {
415
436
  return this._interfaces;
416
437
  };
417
438
 
439
+ _proto2.toConfig = function toConfig() {
440
+ return {
441
+ name: this.name,
442
+ description: this.description,
443
+ isTypeOf: this.isTypeOf,
444
+ interfaces: this.getInterfaces(),
445
+ fields: fieldsToFieldsConfig(this.getFields()),
446
+ astNode: this.astNode,
447
+ extensionASTNodes: this.extensionASTNodes || []
448
+ };
449
+ };
450
+
418
451
  _proto2.toString = function toString() {
419
452
  return this.name;
420
453
  };
@@ -436,7 +469,7 @@ function defineFieldMap(config) {
436
469
  !isPlainObj(fieldMap) ? invariant(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
437
470
  return mapValue(fieldMap, function (fieldConfig, fieldName) {
438
471
  !isPlainObj(fieldConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field config must be an object")) : void 0;
439
- !!fieldConfig.hasOwnProperty('isDeprecated') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " should provide \"deprecationReason\" ") + 'instead of "isDeprecated".') : void 0;
472
+ !!('isDeprecated' in fieldConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " should provide \"deprecationReason\" ") + 'instead of "isDeprecated".') : void 0;
440
473
  !(fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field resolver must be a function if ") + "provided, but got: ".concat(inspect(fieldConfig.resolve), ".")) : void 0;
441
474
  var argsConfig = fieldConfig.args || {};
442
475
  !isPlainObj(argsConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " args must be an object with argument ") + 'names as keys.') : void 0;
@@ -463,6 +496,32 @@ function isPlainObj(obj) {
463
496
  return obj && _typeof(obj) === 'object' && !Array.isArray(obj);
464
497
  }
465
498
 
499
+ function fieldsToFieldsConfig(fields) {
500
+ return mapValue(fields, function (field) {
501
+ return {
502
+ type: field.type,
503
+ args: argsToArgsConfig(field.args),
504
+ resolve: field.resolve,
505
+ subscribe: field.subscribe,
506
+ deprecationReason: field.deprecationReason,
507
+ description: field.description,
508
+ astNode: field.astNode
509
+ };
510
+ });
511
+ }
512
+
513
+ export function argsToArgsConfig(args) {
514
+ return keyValMap(args, function (arg) {
515
+ return arg.name;
516
+ }, function (arg) {
517
+ return {
518
+ type: arg.type,
519
+ defaultValue: arg.defaultValue,
520
+ description: arg.description,
521
+ astNode: arg.astNode
522
+ };
523
+ });
524
+ }
466
525
  export function isRequiredArgument(arg) {
467
526
  return isNonNullType(arg.type) && arg.defaultValue === undefined;
468
527
  }
@@ -492,7 +551,7 @@ function () {
492
551
  this.name = config.name;
493
552
  this.description = config.description;
494
553
  this.astNode = config.astNode;
495
- this.extensionASTNodes = config.extensionASTNodes;
554
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
496
555
  this.resolveType = config.resolveType;
497
556
  this._fields = defineFieldMap.bind(undefined, config);
498
557
  !(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
@@ -509,6 +568,17 @@ function () {
509
568
  return this._fields;
510
569
  };
511
570
 
571
+ _proto3.toConfig = function toConfig() {
572
+ return {
573
+ name: this.name,
574
+ description: this.description,
575
+ resolveType: this.resolveType,
576
+ fields: fieldsToFieldsConfig(this.getFields()),
577
+ astNode: this.astNode,
578
+ extensionASTNodes: this.extensionASTNodes || []
579
+ };
580
+ };
581
+
512
582
  _proto3.toString = function toString() {
513
583
  return this.name;
514
584
  };
@@ -549,7 +619,7 @@ function () {
549
619
  this.name = config.name;
550
620
  this.description = config.description;
551
621
  this.astNode = config.astNode;
552
- this.extensionASTNodes = config.extensionASTNodes;
622
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
553
623
  this.resolveType = config.resolveType;
554
624
  this._types = defineTypes.bind(undefined, config);
555
625
  !(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
@@ -566,6 +636,17 @@ function () {
566
636
  return this._types;
567
637
  };
568
638
 
639
+ _proto4.toConfig = function toConfig() {
640
+ return {
641
+ name: this.name,
642
+ description: this.description,
643
+ resolveType: this.resolveType,
644
+ types: this.getTypes(),
645
+ astNode: this.astNode,
646
+ extensionASTNodes: this.extensionASTNodes || []
647
+ };
648
+ };
649
+
569
650
  _proto4.toString = function toString() {
570
651
  return this.name;
571
652
  };
@@ -608,13 +689,11 @@ export var GraphQLEnumType
608
689
  =
609
690
  /*#__PURE__*/
610
691
  function () {
611
- function GraphQLEnumType(config
612
- /* <T> */
613
- ) {
692
+ function GraphQLEnumType(config) {
614
693
  this.name = config.name;
615
694
  this.description = config.description;
616
695
  this.astNode = config.astNode;
617
- this.extensionASTNodes = config.extensionASTNodes;
696
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
618
697
  this._values = defineEnumValues(this, config.values);
619
698
  this._valueLookup = new Map(this._values.map(function (enumValue) {
620
699
  return [enumValue.value, enumValue];
@@ -635,9 +714,7 @@ function () {
635
714
  return this._nameLookup[name];
636
715
  };
637
716
 
638
- _proto5.serialize = function serialize(value
639
- /* T */
640
- ) {
717
+ _proto5.serialize = function serialize(value) {
641
718
  var enumValue = this._valueLookup.get(value);
642
719
 
643
720
  if (enumValue) {
@@ -670,6 +747,26 @@ function () {
670
747
  }
671
748
  };
672
749
 
750
+ _proto5.toConfig = function toConfig() {
751
+ var values = keyValMap(this.getValues(), function (value) {
752
+ return value.name;
753
+ }, function (value) {
754
+ return {
755
+ description: value.description,
756
+ value: value.value,
757
+ deprecationReason: value.deprecationReason,
758
+ astNode: value.astNode
759
+ };
760
+ });
761
+ return {
762
+ name: this.name,
763
+ description: this.description,
764
+ values: values,
765
+ astNode: this.astNode,
766
+ extensionASTNodes: this.extensionASTNodes || []
767
+ };
768
+ };
769
+
673
770
  _proto5.toString = function toString() {
674
771
  return this.name;
675
772
  };
@@ -680,22 +777,20 @@ function () {
680
777
  defineToStringTag(GraphQLEnumType);
681
778
  defineToJSON(GraphQLEnumType);
682
779
 
683
- function defineEnumValues(type, valueMap
684
- /* <T> */
685
- ) {
780
+ function defineEnumValues(type, valueMap) {
686
781
  !isPlainObj(valueMap) ? invariant(0, "".concat(type.name, " values must be an object with value names as keys.")) : void 0;
687
782
  return objectEntries(valueMap).map(function (_ref2) {
688
783
  var valueName = _ref2[0],
689
784
  value = _ref2[1];
690
785
  !isPlainObj(value) ? invariant(0, "".concat(type.name, ".").concat(valueName, " must refer to an object with a \"value\" key ") + "representing an internal value but got: ".concat(inspect(value), ".")) : void 0;
691
- !!value.hasOwnProperty('isDeprecated') ? invariant(0, "".concat(type.name, ".").concat(valueName, " should provide \"deprecationReason\" instead ") + 'of "isDeprecated".') : void 0;
786
+ !!('isDeprecated' in value) ? invariant(0, "".concat(type.name, ".").concat(valueName, " should provide \"deprecationReason\" instead ") + 'of "isDeprecated".') : void 0;
692
787
  return {
693
788
  name: valueName,
694
789
  description: value.description,
695
790
  isDeprecated: Boolean(value.deprecationReason),
696
791
  deprecationReason: value.deprecationReason,
697
792
  astNode: value.astNode,
698
- value: value.hasOwnProperty('value') ? value.value : valueName
793
+ value: 'value' in value ? value.value : valueName
699
794
  };
700
795
  });
701
796
  }
@@ -727,7 +822,7 @@ function () {
727
822
  this.name = config.name;
728
823
  this.description = config.description;
729
824
  this.astNode = config.astNode;
730
- this.extensionASTNodes = config.extensionASTNodes;
825
+ this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
731
826
  this._fields = defineInputFieldMap.bind(undefined, config);
732
827
  !(typeof config.name === 'string') ? invariant(0, 'Must provide name.') : void 0;
733
828
  }
@@ -742,6 +837,24 @@ function () {
742
837
  return this._fields;
743
838
  };
744
839
 
840
+ _proto6.toConfig = function toConfig() {
841
+ var fields = mapValue(this.getFields(), function (field) {
842
+ return {
843
+ description: field.description,
844
+ type: field.type,
845
+ defaultValue: field.defaultValue,
846
+ astNode: field.astNode
847
+ };
848
+ });
849
+ return {
850
+ name: this.name,
851
+ description: this.description,
852
+ fields: fields,
853
+ astNode: this.astNode,
854
+ extensionASTNodes: this.extensionASTNodes || []
855
+ };
856
+ };
857
+
745
858
  _proto6.toString = function toString() {
746
859
  return this.name;
747
860
  };
@@ -756,7 +869,7 @@ function defineInputFieldMap(config) {
756
869
  var fieldMap = resolveThunk(config.fields) || {};
757
870
  !isPlainObj(fieldMap) ? invariant(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
758
871
  return mapValue(fieldMap, function (fieldConfig, fieldName) {
759
- !!fieldConfig.hasOwnProperty('resolve') ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
872
+ !!('resolve' in fieldConfig) ? invariant(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
760
873
  return _objectSpread({}, fieldConfig, {
761
874
  name: fieldName
762
875
  });
@@ -765,4 +878,4 @@ function defineInputFieldMap(config) {
765
878
 
766
879
  export function isRequiredInputField(field) {
767
880
  return isNonNullType(field.type) && field.defaultValue === undefined;
768
- }
881
+ }
@@ -76,6 +76,16 @@ function () {
76
76
  return '@' + this.name;
77
77
  };
78
78
 
79
+ _proto.toConfig = function toConfig() {
80
+ return {
81
+ name: this.name,
82
+ description: this.description,
83
+ locations: this.locations,
84
+ args: (0, _definition.argsToArgsConfig)(this.args),
85
+ astNode: this.astNode
86
+ };
87
+ };
88
+
79
89
  return GraphQLDirective;
80
90
  }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
81
91
 
@@ -146,7 +156,8 @@ var specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQ
146
156
  exports.specifiedDirectives = specifiedDirectives;
147
157
 
148
158
  function isSpecifiedDirective(directive) {
149
- return specifiedDirectives.some(function (specifiedDirective) {
150
- return specifiedDirective.name === directive.name;
159
+ return isDirective(directive) && specifiedDirectives.some(function (_ref2) {
160
+ var name = _ref2.name;
161
+ return name === directive.name;
151
162
  });
152
- }
163
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -8,18 +8,19 @@
8
8
  */
9
9
 
10
10
  import objectEntries from '../polyfills/objectEntries';
11
- import type {
12
- GraphQLFieldConfigArgumentMap,
13
- GraphQLArgument,
11
+ import {
12
+ type GraphQLFieldConfigArgumentMap,
13
+ type GraphQLArgument,
14
+ argsToArgsConfig,
15
+ GraphQLNonNull,
14
16
  } from './definition';
15
- import { GraphQLNonNull } from './definition';
16
17
  import { GraphQLString, GraphQLBoolean } from './scalars';
17
18
  import defineToStringTag from '../jsutils/defineToStringTag';
18
19
  import defineToJSON from '../jsutils/defineToJSON';
19
20
  import instanceOf from '../jsutils/instanceOf';
20
21
  import invariant from '../jsutils/invariant';
21
22
  import inspect from '../jsutils/inspect';
22
- import type { DirectiveDefinitionNode } from '../language/ast';
23
+ import { type DirectiveDefinitionNode } from '../language/ast';
23
24
  import {
24
25
  DirectiveLocation,
25
26
  type DirectiveLocationEnum,
@@ -84,6 +85,19 @@ export class GraphQLDirective {
84
85
  toString(): string {
85
86
  return '@' + this.name;
86
87
  }
88
+
89
+ toConfig(): {|
90
+ ...GraphQLDirectiveConfig,
91
+ args: GraphQLFieldConfigArgumentMap,
92
+ |} {
93
+ return {
94
+ name: this.name,
95
+ description: this.description,
96
+ locations: this.locations,
97
+ args: argsToArgsConfig(this.args),
98
+ astNode: this.astNode,
99
+ };
100
+ }
87
101
  }
88
102
 
89
103
  // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
@@ -173,10 +187,9 @@ export const specifiedDirectives: $ReadOnlyArray<*> = [
173
187
  GraphQLDeprecatedDirective,
174
188
  ];
175
189
 
176
- export function isSpecifiedDirective(
177
- directive: GraphQLDirective,
178
- ): boolean %checks {
179
- return specifiedDirectives.some(
180
- specifiedDirective => specifiedDirective.name === directive.name,
190
+ export function isSpecifiedDirective(directive: mixed): boolean %checks {
191
+ return (
192
+ isDirective(directive) &&
193
+ specifiedDirectives.some(({ name }) => name === directive.name)
181
194
  );
182
195
  }
@@ -1,7 +1,7 @@
1
1
  function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
3
  /**
4
- * Copyright (c) 2015-present, Facebook, Inc.
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -9,7 +9,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
9
9
  *
10
10
  */
11
11
  import objectEntries from '../polyfills/objectEntries';
12
- import { GraphQLNonNull } from './definition';
12
+ import { argsToArgsConfig, GraphQLNonNull } from './definition';
13
13
  import { GraphQLString, GraphQLBoolean } from './scalars';
14
14
  import defineToStringTag from '../jsutils/defineToStringTag';
15
15
  import defineToJSON from '../jsutils/defineToJSON';
@@ -65,6 +65,16 @@ function () {
65
65
  return '@' + this.name;
66
66
  };
67
67
 
68
+ _proto.toConfig = function toConfig() {
69
+ return {
70
+ name: this.name,
71
+ description: this.description,
72
+ locations: this.locations,
73
+ args: argsToArgsConfig(this.args),
74
+ astNode: this.astNode
75
+ };
76
+ };
77
+
68
78
  return GraphQLDirective;
69
79
  }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
70
80
 
@@ -127,7 +137,8 @@ export var GraphQLDeprecatedDirective = new GraphQLDirective({
127
137
 
128
138
  export var specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
129
139
  export function isSpecifiedDirective(directive) {
130
- return specifiedDirectives.some(function (specifiedDirective) {
131
- return specifiedDirective.name === directive.name;
140
+ return isDirective(directive) && specifiedDirectives.some(function (_ref2) {
141
+ var name = _ref2.name;
142
+ return name === directive.name;
132
143
  });
133
- }
144
+ }
package/type/index.js CHANGED
@@ -393,12 +393,6 @@ Object.defineProperty(exports, "GraphQLID", {
393
393
  return _scalars.GraphQLID;
394
394
  }
395
395
  });
396
- Object.defineProperty(exports, "TypeKind", {
397
- enumerable: true,
398
- get: function get() {
399
- return _introspection.TypeKind;
400
- }
401
- });
402
396
  Object.defineProperty(exports, "isIntrospectionType", {
403
397
  enumerable: true,
404
398
  get: function get() {
@@ -459,6 +453,12 @@ Object.defineProperty(exports, "__TypeKind", {
459
453
  return _introspection.__TypeKind;
460
454
  }
461
455
  });
456
+ Object.defineProperty(exports, "TypeKind", {
457
+ enumerable: true,
458
+ get: function get() {
459
+ return _introspection.TypeKind;
460
+ }
461
+ });
462
462
  Object.defineProperty(exports, "SchemaMetaFieldDef", {
463
463
  enumerable: true,
464
464
  get: function get() {
@@ -500,4 +500,4 @@ var _scalars = require("./scalars");
500
500
 
501
501
  var _introspection = require("./introspection");
502
502
 
503
- var _validate = require("./validate");
503
+ var _validate = require("./validate");
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -93,7 +93,9 @@ export type { GraphQLDirectiveConfig } from './directives';
93
93
 
94
94
  // Common built-in scalar instances.
95
95
  export {
96
+ // Predicate
96
97
  isSpecifiedScalarType,
98
+ // Standard GraphQL Scalars
97
99
  specifiedScalarTypes,
98
100
  GraphQLInt,
99
101
  GraphQLFloat,
@@ -103,10 +105,9 @@ export {
103
105
  } from './scalars';
104
106
 
105
107
  export {
106
- // "Enum" of Type Kinds
107
- TypeKind,
108
- // GraphQL Types for introspection.
108
+ // Predicate
109
109
  isIntrospectionType,
110
+ // GraphQL Types for introspection.
110
111
  introspectionTypes,
111
112
  __Schema,
112
113
  __Directive,
@@ -116,6 +117,8 @@ export {
116
117
  __InputValue,
117
118
  __EnumValue,
118
119
  __TypeKind,
120
+ // "Enum" of Type Kinds
121
+ TypeKind,
119
122
  // Meta-field definitions.
120
123
  SchemaMetaFieldDef,
121
124
  TypeMetaFieldDef,
@@ -163,4 +166,5 @@ export type {
163
166
  GraphQLScalarLiteralParser,
164
167
  } from './definition';
165
168
 
169
+ // Validate GraphQL schema.
166
170
  export { validateSchema, assertValidSchema } from './validate';
package/type/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -23,9 +23,13 @@ GraphQLDirective, // Built-in Directives defined by the Spec
23
23
  isSpecifiedDirective, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, // Constant Deprecation Reason
24
24
  DEFAULT_DEPRECATION_REASON } from './directives';
25
25
  // Common built-in scalar instances.
26
- export { isSpecifiedScalarType, specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID } from './scalars';
27
- export { // "Enum" of Type Kinds
28
- TypeKind, // GraphQL Types for introspection.
29
- isIntrospectionType, introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, // Meta-field definitions.
26
+ export { // Predicate
27
+ isSpecifiedScalarType, // Standard GraphQL Scalars
28
+ specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID } from './scalars';
29
+ export { // Predicate
30
+ isIntrospectionType, // GraphQL Types for introspection.
31
+ introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind, // "Enum" of Type Kinds
32
+ TypeKind, // Meta-field definitions.
30
33
  SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from './introspection';
31
- export { validateSchema, assertValidSchema } from './validate';
34
+ // Validate GraphQL schema.
35
+ export { validateSchema, assertValidSchema } from './validate';
@@ -8,7 +8,7 @@ exports.introspectionTypes = exports.TypeNameMetaFieldDef = exports.TypeMetaFiel
8
8
 
9
9
  var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
10
10
 
11
- var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
11
+ var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
12
12
 
13
13
  var _astFromValue = require("../utilities/astFromValue");
14
14
 
@@ -23,7 +23,7 @@ var _directiveLocation = require("../language/directiveLocation");
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
24
 
25
25
  /**
26
- * Copyright (c) 2015-present, Facebook, Inc.
26
+ * Copyright (c) Facebook, Inc. and its affiliates.
27
27
  *
28
28
  * This source code is licensed under the MIT license found in the
29
29
  * LICENSE file in the root directory of this source tree.
@@ -220,9 +220,12 @@ var __Type = new _definition.GraphQLObjectType({
220
220
  return TypeKind.LIST;
221
221
  } else if ((0, _definition.isNonNullType)(type)) {
222
222
  return TypeKind.NON_NULL;
223
- }
223
+ } // Not reachable. All possible types have been considered.
224
+
225
+ /* istanbul ignore next */
226
+
224
227
 
225
- throw new Error('Unknown kind of type: ' + type);
228
+ throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
226
229
  }
227
230
  },
228
231
  name: {
@@ -399,7 +402,8 @@ var __InputValue = new _definition.GraphQLObjectType({
399
402
  type: _scalars.GraphQLString,
400
403
  description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
401
404
  resolve: function resolve(inputVal) {
402
- return (0, _isInvalid.default)(inputVal.defaultValue) ? null : (0, _printer.print)((0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type));
405
+ var valueAST = (0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type);
406
+ return valueAST ? (0, _printer.print)(valueAST) : null;
403
407
  }
404
408
  }
405
409
  };
@@ -540,7 +544,8 @@ var introspectionTypes = [__Schema, __Directive, __DirectiveLocation, __Type, __
540
544
  exports.introspectionTypes = introspectionTypes;
541
545
 
542
546
  function isIntrospectionType(type) {
543
- return (0, _definition.isNamedType)(type) && ( // Would prefer to use introspectionTypes.some(), however %checks needs
544
- // a simple expression.
545
- type.name === __Schema.name || type.name === __Directive.name || type.name === __DirectiveLocation.name || type.name === __Type.name || type.name === __Field.name || type.name === __InputValue.name || type.name === __EnumValue.name || type.name === __TypeKind.name);
546
- }
547
+ return (0, _definition.isNamedType)(type) && introspectionTypes.some(function (_ref8) {
548
+ var name = _ref8.name;
549
+ return type.name === name;
550
+ });
551
+ }