UNPKG

graphql-paper

Version:

A flexible in-memory store based on a GraphQL Schema

20 lines (19 loc) 735 B
import { validate } from './validate.mjs'; import { TypeDoesNotExist } from './errors/type-does-not-exist.mjs'; function validateStore(graphqlSchema, store, validators) { for (var typename in store) { if (!graphqlSchema.getType(typename)) { throw new TypeDoesNotExist({ typename }); } for (var document of store[typename]) { if (document.__typename !== typename) { throw new Error("Document typename \"".concat(document.__typename, "\" does not match the typename of the key \"").concat(typename, "\" in the store where it is stored")); } validate(graphqlSchema, document, store, validators); } } } export { validateStore }; //# sourceMappingURL=validate-store.mjs.map