coerceValue.d.ts 607 B

1234567891011121314151617181920212223
  1. import { Path } from '../jsutils/Path';
  2. import { GraphQLError } from '../error/GraphQLError';
  3. import { ASTNode } from '../language/ast';
  4. import { GraphQLInputType } from '../type/definition';
  5. interface CoercedValue {
  6. readonly errors: ReadonlyArray<GraphQLError> | undefined;
  7. readonly value: any;
  8. }
  9. /**
  10. * Coerces a JavaScript value given a GraphQL Type.
  11. *
  12. * Returns either a value which is valid for the provided type or a list of
  13. * encountered coercion errors.
  14. *
  15. */
  16. export function coerceValue(
  17. inputValue: any,
  18. type: GraphQLInputType,
  19. blameNode?: ASTNode,
  20. path?: Path,
  21. ): CoercedValue;