graphql-paper
Version:
A flexible in-memory store based on a GraphQL Schema
23 lines (21 loc) • 605 B
JavaScript
;
var graphql = require('graphql');
var fieldReturnTypeMismatch = require('../errors/field-return-type-mismatch.js');
const objectFieldValidator = {
skipConnectionValue: true,
skipNullValue: true,
validate({
field,
fieldValue
}) {
if (graphql.isObjectType(field.type) && typeof fieldValue !== 'object') {
throw new fieldReturnTypeMismatch.FieldReturnTypeMismatch({
field: field,
expected: 'object',
actual: typeof fieldValue
});
}
}
};
exports.objectFieldValidator = objectFieldValidator;
//# sourceMappingURL=object-field.js.map