Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mutationBuilder(relationships, path = []) {
return compose(
Object.entries(relationships).map(([uid, { field, relationships }]) => {
const uniqueField = `${uid}_${field}`;
const postQueryMutations = mutationBuilder(relationships, [...path, uniqueField]);
// NOTE: Order is important. We want depth first, so we perform the related mutators first.
return compose([postQueryMutations, mutation(uid, [...path, uniqueField])]);
})
);
}
createList(key, config, { isAuxList = false } = {}) {
const { getListByKey, adapters } = this;
const adapterName = config.adapterName || this.defaultAdapter;
const isReservedName = !isAuxList && key[0] === '_';
if (isReservedName) {
throw new Error(`Invalid list name "${key}". List names cannot start with an underscore.`);
}
const list = new List(key, compose(config.plugins || [])(config), {
getListByKey,
queryHelper: this._buildQueryHelper.bind(this),
adapter: adapters[adapterName],
defaultAccess: this.defaultAccess,
getAuth: () => this.auth[key] || {},
registerType: type => this.registeredTypes.add(type),
isAuxList,
createAuxList: (auxKey, auxConfig) => {
if (isAuxList) {
throw new Error(
`Aux list "${key}" shouldn't be creating more aux lists ("${auxKey}"). Something's probably not right here.`
);
}
return this.createList(auxKey, auxConfig, { isAuxList: true });
},
schemaNames: this._schemaNames,