UNPKG

graphql-paper

Version:

A flexible in-memory store based on a GraphQL Schema

21 lines (20 loc) 702 B
import { FieldDoesNotExistOnType } from '../errors/field-does-not-exist-on-type.mjs'; var documentPropertyExistsAsFieldOnTypeValidator = { validate(_ref) { var { document, type } = _ref; var documentFieldNames = Object.keys(document); var typeFieldNames = Object.keys(type.getFields()); var nonExistingFieldName = documentFieldNames.find(fieldName => !typeFieldNames.includes(fieldName)); if (nonExistingFieldName) { throw new FieldDoesNotExistOnType({ type, fieldName: nonExistingFieldName }); } } }; export { documentPropertyExistsAsFieldOnTypeValidator }; //# sourceMappingURL=document-property-exists-as-field-on-type.mjs.map