Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
network: network, //optional
onComplete: (options: any) => {
//optional
const {id, offlinePayload, snapshot} = options;
console.log('onComplete', options);
return true;
},
onDiscard: (options: any) => {
//optio
const {id, offlinePayload, error} = options;
console.log('onDiscard', options);
return true;
},
};
const recordSource = new RecordSource({
mergeState: () => {
return records;
},
});
const store = new Store(recordSource);
return new Environment(
{
network,
store,
},
offlineOptions,
);
// new
// const offlineOptions = {}
// const store = new Store(new RecordSource(records))
onDiscard: async (options: any) => {
//optio
const { id, offlinePayload, error } = options;
console.log("onDiscard", options);
return true;
}
};
/**
* Store
*/
const options: any = {
errorHandling: (cache: any, error: any) => console.log("error storage", error)
};
export const recourdSource = new RecordSource(options);
export const store = new Store(recourdSource, options);
/**
* Environment
*/
export const environment = new Environment({ network, store });
environment.setOfflineOptions(offlineOptions);
},
body: JSON.stringify({
query: operation.text,
variables,
}),
});
return response.json();
}
const network = Network.create(fetchQuery);
export const manualExecution = false;
//const environment = EnvironmentIDB.create({network}, offlineOptions); //, {ttl: 60 * 1000}
const recordSource = new RecordSource();
const store = new Store(recordSource);
store._cache.set('provainit', 'prova');
const environment = new Environment({network, store});
environment.setOfflineOptions({
manualExecution, //optional
network: network, //optional
start: async mutations => {
//optional
console.log('start offline', mutations);
return mutations;
},
finish: async (mutations, error) => {
//optional
console.log('finish offline', error, mutations);
},
onExecute: async mutation => {