Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async enqueueOperation(op: T): Promise {
const entry: QueueEntry = {
operation: {
qid: generateClientId(),
op
}
};
// enqueue and persist
this.queue.push(entry);
// notify listeners
this.onOperationEnqueued(entry.operation);
if (this.store) {
try {
await this.store.saveEntry(entry.operation);
} catch (err) {
console.error(err);
}
}
constructor(operation: Operation, offlineId?: number) {
this.query = operation.query;
this.variables = operation.variables;
this.operationName = operation.operationName;
if (offlineId) {
this.id = offlineId.toString();
} else {
this.id = generateClientId();
}
if (typeof operation.getContext === "function") {
const context = operation.getContext();
this.conflictBase = context.conflictBase;
this.returnType = context.returnType;
this.idField = context.idField;
this.optimisticResponse = context.optimisticResponse;
if (context.conflictStrategy) {
this.conflictStrategy = context.conflictStrategy.id;
}
}
}