How to use the @keystonejs/utils.mergeWhereClause 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 / adapter-mongoose / lib / adapter-mongoose.js View on Github external
async _itemsQuery(args, { meta = false, from, include } = {}) {
    if (from && Object.keys(from).length) {
      const ids = await from.fromList.adapter._itemsQuery(
        { where: { id: from.fromId } },
        { include: from.fromField }
      );
      if (ids.length) {
        args = mergeWhereClause(args, { id: { $in: ids[0][from.fromField] || [] } });
      }
    }
    function graphQlQueryToMongoJoinQuery(query) {
      const _query = {
        ...query.where,
        ...mapKeyNames(
          // Grab all the modifiers
          pick(query, ['search', 'orderBy', 'skip', 'first']),
          // and prefix with a dollar symbol so they can be picked out by the
          // query builder tokeniser
          key => `$${key}`
        ),
      };

      return mapKeys(_query, field => {
        if (getType(field) !== 'Object' || !field.where) {
github keystonejs / keystone / packages / keystone / lib / List / index.js View on Github external
authenticatedQuery(context, info) {
    if (info) {
      info.cacheControl.setCacheHint({ scope: 'PRIVATE' });
    }

    if (!context.authedItem || context.authedListKey !== this.key) {
      return null;
    }

    const gqlName = this.gqlNames.authenticatedQueryName;
    const access = this.checkListAccess(context, undefined, 'auth', { gqlName });
    return this.itemQuery(
      mergeWhereClause({ where: { id: context.authedItem.id } }, access),
      context,
      this.gqlNames.authenticatedQueryName
    );
  }
github keystonejs / keystone / packages / keystone / lib / List / index.js View on Github external
getCount: () => {
        const access = this.checkListAccess(context, undefined, 'read', { gqlName });

        return this._itemsQuery(mergeWhereClause(args, access), {
          meta: true,
          context,
          info,
          from,
        }).then(({ count }) => count);
      },
    };
github keystonejs / keystone / packages / keystone / lib / List / index.js View on Github external
async listQuery(args, context, gqlName, info, from) {
    const access = this.checkListAccess(context, undefined, 'read', { gqlName });

    return this._itemsQuery(mergeWhereClause(args, access), { context, info, from });
  }