UNPKG

graphql-paper

Version:

A flexible in-memory store based on a GraphQL Schema

22 lines (20 loc) 764 B
'use strict'; var validate = require('./validate.js'); var typeDoesNotExist = require('./errors/type-does-not-exist.js'); function validateStore(graphqlSchema, store, validators) { for (const typename in store) { if (!graphqlSchema.getType(typename)) { throw new typeDoesNotExist.TypeDoesNotExist({ typename }); } for (const document of store[typename]) { if (document.__typename !== typename) { throw new Error(`Document typename "${document.__typename}" does not match the typename of the key "${typename}" in the store where it is stored`); } validate.validate(graphqlSchema, document, store, validators); } } } exports.validateStore = validateStore; //# sourceMappingURL=validate-store.js.map