From 989f020e307ac410a823379f72e6e9a0356d3d96 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 29 Feb 2024 21:22:51 -0500 Subject: [PATCH] - Progress Commit Signed-off-by: Dave Richer --- client/src/utils/graphQLmodifier.js | 31 +---------------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/client/src/utils/graphQLmodifier.js b/client/src/utils/graphQLmodifier.js index c74fd9b94..d164382a9 100644 --- a/client/src/utils/graphQLmodifier.js +++ b/client/src/utils/graphQLmodifier.js @@ -122,11 +122,9 @@ export async function generateTemplate(templateQueryToExecute, templateObject, u // Parse the query and apply the filters and sorters const ast = parseQuery(templateQueryToExecute); - let filterFields = []; if (templateObject?.filters && templateObject?.filters?.length) { - applyFilters(ast, templateObject.filters, filterFields); - wrapFiltersInAnd(ast, filterFields); + applyFilters(ast, templateObject.filters); } if (templateObject?.sorters && templateObject?.sorters?.length) { @@ -412,31 +410,4 @@ function getGraphQLKind(value) { } } -/** - * Wrap filters in an 'and' object - * @param ast - * @param filterFields - */ -export function wrapFiltersInAnd(ast, filterFields) { - visit(ast, { - OperationDefinition: { - enter(node) { - node.selectionSet.selections.forEach((selection) => { - let whereArg = selection.arguments.find(arg => arg.name.value === 'where'); - if (filterFields.length > 1) { - const andFilter = { - kind: Kind.OBJECT_FIELD, - name: {kind: Kind.NAME, value: '_and'}, - value: {kind: Kind.LIST, values: filterFields} - }; - whereArg.value.fields.push(andFilter); - } else if (filterFields.length === 1) { - whereArg.value.fields.push(filterFields[0].fields[0]); - } - }); - } - } - }); -} - /* eslint-enable no-loop-func */