Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
}
// Load "many" entries
const { where = {}, ...rest } = args;
where["id_in"] = refValue || [];
try {
const { entries, meta } = await findEntries({
model: refModel,
args: { where, ...rest },
context,
info
});
return new ListResponse(entries, meta);
} catch (err) {
return new ListErrorResponse({
code: err.code,
error: err.message
});
}
};
}
tags: { $in: tags.map(tag => tag.toLowerCase()) }
});
}
if (Array.isArray(ids) && ids.length > 0) {
$and.push({
id: { $in: ids }
});
}
if ($and.length) {
findArgs.query = { $and };
}
const data = await File.find(findArgs);
return new ListResponse(data, data.getMeta());
};
export default async (root: any, args: Object, context: Object) => {
const data = await listPublishedPages({ args, context });
return new ListResponse(data, data.getMeta());
};
export default async (root: any, args: Object, context: Object) => {
const plugin = context.plugins.byName("forms-resolver-list-forms");
if (!plugin) {
throw Error(`Resolver plugin "forms-resolver-list-forms" is not configured!`);
}
const { forms, totalCount } = await plugin.resolve({ root, args, context });
if (!Array.isArray(forms) || !Number.isInteger(totalCount)) {
throw Error(
`Resolver plugin "forms-resolver-list-forms" must return { forms: [Form], totalCount: Int }!`
);
}
return new ListResponse(
forms,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};
throw Error("Mailchimp API key not set.");
}
const mailchimp = new MailchimpApi({ apiKey: settings.data.apiKey });
try {
const listsResponse = await mailchimp.get({
path: `/lists/`
});
const output = listsResponse.body.lists.map(item => ({
id: item.id,
name: item.name
}));
return new ListResponse(output);
} catch (e) {
return new ListErrorResponse(e);
}
},
getSettings: resolveGetSettings(({ models }) => models.MailchimpSettings)
export default async (root: any, args: Object, context: Object) => {
const plugin = getListPublishedFormsResolver(context);
const { forms, totalCount } = await plugin.resolve({ root, args, context });
if (!Array.isArray(forms) || !Number.isInteger(totalCount)) {
throw Error(
`Resolver plugin "forms-resolver-list-published-forms" must return { forms: [Form], totalCount: Int }!`
);
}
return new ListResponse(
forms,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};
page: args.page,
perPage: args.perPage,
sort: args.sort
};
if (args.search && args.search.query) {
find.search = {
query: args.search.query,
fields: args.search.fields,
operator: args.search.operator || "or"
};
}
const data = await Model.find(find);
return new ListResponse(data, data.getMeta());
};
export default async (root: any, args: Object, context: Object) => {
const plugin = context.plugins.byName("pb-resolver-list-pages");
if (!plugin) {
throw Error(`Resolver plugin "pb-resolver-list-pages" is not configured!`);
}
const { pages, totalCount } = await plugin.resolve({ args, context });
return new ListResponse(
pages,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};