values.d.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import type { Maybe } from '../jsutils/Maybe';
  2. import type { ObjMap } from '../jsutils/ObjMap';
  3. import { GraphQLError } from '../error/GraphQLError';
  4. import type {
  5. DirectiveNode,
  6. FieldNode,
  7. VariableDefinitionNode,
  8. } from '../language/ast';
  9. import type { GraphQLField } from '../type/definition';
  10. import type { GraphQLDirective } from '../type/directives';
  11. import type { GraphQLSchema } from '../type/schema';
  12. declare type CoercedVariableValues =
  13. | {
  14. errors: ReadonlyArray<GraphQLError>;
  15. coerced?: never;
  16. }
  17. | {
  18. coerced: {
  19. [variable: string]: unknown;
  20. };
  21. errors?: never;
  22. };
  23. /**
  24. * Prepares an object map of variableValues of the correct type based on the
  25. * provided variable definitions and arbitrary input. If the input cannot be
  26. * parsed to match the variable definitions, a GraphQLError will be thrown.
  27. *
  28. * Note: The returned value is a plain Object with a prototype, since it is
  29. * exposed to user code. Care should be taken to not pull values from the
  30. * Object prototype.
  31. */
  32. export declare function getVariableValues(
  33. schema: GraphQLSchema,
  34. varDefNodes: ReadonlyArray<VariableDefinitionNode>,
  35. inputs: {
  36. readonly [variable: string]: unknown;
  37. },
  38. options?: {
  39. maxErrors?: number;
  40. },
  41. ): CoercedVariableValues;
  42. /**
  43. * Prepares an object map of argument values given a list of argument
  44. * definitions and list of argument AST nodes.
  45. *
  46. * Note: The returned value is a plain Object with a prototype, since it is
  47. * exposed to user code. Care should be taken to not pull values from the
  48. * Object prototype.
  49. */
  50. export declare function getArgumentValues(
  51. def: GraphQLField<unknown, unknown> | GraphQLDirective,
  52. node: FieldNode | DirectiveNode,
  53. variableValues?: Maybe<ObjMap<unknown>>,
  54. ): {
  55. [argument: string]: unknown;
  56. };
  57. /**
  58. * Prepares an object map of argument values given a directive definition
  59. * and a AST node which may contain directives. Optionally also accepts a map
  60. * of variable values.
  61. *
  62. * If the directive does not exist on the node, returns undefined.
  63. *
  64. * Note: The returned value is a plain Object with a prototype, since it is
  65. * exposed to user code. Care should be taken to not pull values from the
  66. * Object prototype.
  67. */
  68. export declare function getDirectiveValues(
  69. directiveDef: GraphQLDirective,
  70. node: {
  71. readonly directives?: ReadonlyArray<DirectiveNode>;
  72. },
  73. variableValues?: Maybe<ObjMap<unknown>>,
  74. ):
  75. | undefined
  76. | {
  77. [argument: string]: unknown;
  78. };
  79. export {};