Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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
);
}
getCount: () => {
const access = this.checkListAccess(context, undefined, 'read', { gqlName });
return this._itemsQuery(mergeWhereClause(args, access), {
meta: true,
context,
info,
from,
}).then(({ count }) => count);
},
};
async listQuery(args, context, gqlName, info, from) {
const access = this.checkListAccess(context, undefined, 'read', { gqlName });
return this._itemsQuery(mergeWhereClause(args, access), { context, info, from });
}