UNPKG

graphql-paper

Version:

A flexible in-memory store based on a GraphQL Schema

23 lines (22 loc) 660 B
import { isScalarType } from 'graphql'; import { FieldReturnTypeMismatch } from '../errors/field-return-type-mismatch.mjs'; var scalarFieldValidator = { skipConnectionValue: false, skipNullValue: true, validate(_ref) { var { field, fieldValue } = _ref; var jsScalars = ['boolean', 'number', 'string', 'float']; if (isScalarType(field.type) && !jsScalars.includes(typeof fieldValue)) { throw new FieldReturnTypeMismatch({ field: field, expected: 'boolean, number, string', actual: typeof fieldValue }); } } }; export { scalarFieldValidator }; //# sourceMappingURL=scalar-field.mjs.map