astFromValue.d.ts 1007 B

12345678910111213141516171819202122232425262728
  1. import type { Maybe } from '../jsutils/Maybe';
  2. import type { ValueNode } from '../language/ast';
  3. import type { GraphQLInputType } from '../type/definition';
  4. /**
  5. * Produces a GraphQL Value AST given a JavaScript object.
  6. * Function will match JavaScript/JSON values to GraphQL AST schema format
  7. * by using suggested GraphQLInputType. For example:
  8. *
  9. * astFromValue("value", GraphQLString)
  10. *
  11. * A GraphQL type must be provided, which will be used to interpret different
  12. * JavaScript values.
  13. *
  14. * | JSON Value | GraphQL Value |
  15. * | ------------- | -------------------- |
  16. * | Object | Input Object |
  17. * | Array | List |
  18. * | Boolean | Boolean |
  19. * | String | String / Enum Value |
  20. * | Number | Int / Float |
  21. * | Unknown | Enum Value |
  22. * | null | NullValue |
  23. *
  24. */
  25. export declare function astFromValue(
  26. value: unknown,
  27. type: GraphQLInputType,
  28. ): Maybe<ValueNode>;