isValidJSValue.js.flow 477 B

12345678910111213141516171819
  1. // @flow strict
  2. /* istanbul ignore file */
  3. import { type GraphQLInputType } from '../type/definition';
  4. import { coerceValue } from './coerceValue';
  5. /**
  6. * Deprecated. Use coerceInputValue() directly for richer information.
  7. *
  8. * This function will be removed in v15
  9. */
  10. export function isValidJSValue(
  11. value: mixed,
  12. type: GraphQLInputType,
  13. ): Array<string> {
  14. const errors = coerceValue(value, type).errors;
  15. return errors ? errors.map(error => error.message) : [];
  16. }