mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 09:31:43 -05:00
Make queryOne support any selector
This commit is contained in:
parent
66fd1aedaf
commit
86f919e54a
1 changed files with 3 additions and 2 deletions
|
@ -93,9 +93,10 @@ Meteor.startup(() => {
|
|||
Collections.forEach(collection => {
|
||||
const typeName = collection.options.typeName;
|
||||
|
||||
collection.queryOne = async (documentId, { fragmentName, fragmentText, context }) => {
|
||||
collection.queryOne = async (documentIdOrSelector, { fragmentName, fragmentText, context }) => {
|
||||
const selector = typeof documentIdOrSelector === 'string' ? { documentId: documentIdOrSelector } : documentIdOrSelector;
|
||||
const query = buildQuery(collection, { fragmentName, fragmentText });
|
||||
const result = await runQuery(query, { input: { selector: { documentId } } }, context);
|
||||
const result = await runQuery(query, { input: { selector } }, context);
|
||||
return result.data[Utils.camelCaseify(typeName)].result;
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue