Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getOrSet(typeName: string, typeOrThunk: T | (() => T)): T {
if (this.has(typeName)) {
return (this.get(typeName): any);
}
const gqType: any = isFunction(typeOrThunk) ? typeOrThunk() : typeOrThunk;
if (gqType) {
this.set(typeName, gqType);
}
return gqType;
}
}
`for composeWithConnection in opts.sort.${key}` +
'Ideally this field(s) should be in unique index. ' +
'Connection will work incorrectly, if some records have same values.'
);
}
if (!opts.beforeCursorQuery || !isFunction(opts.beforeCursorQuery)) {
throw new Error(
'You should provide `beforeCursorQuery` function ' +
`for composeWithConnection in opts.sort.${key}. ` +
'Connections should have ability to filter ' +
'backward records started from cursor.'
);
}
if (!opts.afterCursorQuery || !isFunction(opts.afterCursorQuery)) {
throw new Error(
'You should provide `afterCursorQuery` function ' +
`for composeWithConnection in opts.sort.${key}. ` +
'Connections should have ability to filter ' +
'forward records started from cursor.'
);
}
}
'You should provide `value` ' +
`for composeWithConnection in opts.sort.${key}. ` +
'Connections does not work without sorting.'
);
}
if (!opts.cursorFields || !Array.isArray(opts.cursorFields)) {
throw new Error(
'You should provide array of field(s) in `cursorFields` ' +
`for composeWithConnection in opts.sort.${key}` +
'Ideally this field(s) should be in unique index. ' +
'Connection will work incorrectly, if some records have same values.'
);
}
if (!opts.beforeCursorQuery || !isFunction(opts.beforeCursorQuery)) {
throw new Error(
'You should provide `beforeCursorQuery` function ' +
`for composeWithConnection in opts.sort.${key}. ` +
'Connections should have ability to filter ' +
'backward records started from cursor.'
);
}
if (!opts.afterCursorQuery || !isFunction(opts.afterCursorQuery)) {
throw new Error(
'You should provide `afterCursorQuery` function ' +
`for composeWithConnection in opts.sort.${key}. ` +
'Connections should have ability to filter ' +
'forward records started from cursor.'
);
}
return schemaComposer.getOrSet(typeName, () => {
const tc = schemaComposer.createObjectTC(
isFunction(cfgOrThunk) ? (cfgOrThunk: any)() : cfgOrThunk
);
return tc;
});
},