graphql-paper
Version:
A flexible in-memory store based on a GraphQL Schema
23 lines (22 loc) • 675 B
JavaScript
import { getDocumentKey } from '../document/get-document-key.mjs';
function removeOperation(context, keyOrDocument) {
var {
store
} = context;
var key = getDocumentKey(keyOrDocument);
var document;
Object.entries(store).forEach(_ref => {
var [type, documents] = _ref;
var found = documents.find(document => getDocumentKey(document) === key);
if (found) {
store[type] = documents.filter(document => document !== found);
document = found;
}
});
if (!document) {
throw new Error("Could not find document with ".concat(key, " to remove"));
}
return document;
}
export { removeOperation };
//# sourceMappingURL=remove.mjs.map