How to use the @keystonejs/utils.compose function in @keystonejs/utils

To help you get started, we’ve selected a few @keystonejs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / packages / mongo-join-builder / lib / join-builder.js View on Github external
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])]);
    })
  );
}
github keystonejs / keystone / packages / keystone / lib / Keystone / index.js View on Github external
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,