Enonic apollo - query sort from - to date

Enonic version: 7.4.0-SNAPSHOT
OS: Windows 10

Hi,
I am having trouble with creating query with from/to parameters in angular that would get me data only from that period of time. Date is set in DB along with time, title, some text etc.
Request works fine, when dates are set firmly, but when i change it to parameters $parameter, request no longer works.

Is there any solution? Is my request wrong?

Thx,
Martin

Could it be that you try to “use” the variables inside a string? You might need to end the string, reference the variable and then continue the string.

Hi, we found this workaround.
At the beginning we create local variable with the string, replace the dates for our parameters and then we add it to query.
As @tsi pointed out, there probably is problem with variables inside string.

Working example:

Btw, you could make this a bit more readable (get rid of linebreaks and avoid string replacements) if you used template literals.

For example,

const query = `query(....) {
  guillotine {
    query(query: "data.date >= '${from}' AND data.date <= '${to}'")
    ...
`;
1 Like