import { Plugin } from "@webiny/plugins" ; export interface Object { __typename ? : string ; [ key ] : any ; } interface Callable < T > { ( data ) : any ; } export class ApolloCacheObjectIdPlugin < T extends Object = Object > extends Plugin { public static readonly type = "cache-get-object-id" ; private _getObjectId : Callable < T > ; constructor ( getObjectId ? ) { super ( ) ; this . _getObjectId = getObjectId ; } getObjectId ( data ) { if ( typeof this . _getObjectId !== "function" ) { throw Error ( `You must provide a "getObjectId" callable to the plugin constructor or extend the ApolloCacheObjectIdPlugin.` ) ; } return this . _getObjectId ( data ) ; } }