Closed colinscz closed 4 months ago
Hi @easingthemes This is a mismatch with what is mentioned in the Adobe docs. We are hitting a wall here and have issues requesting data over this and the nodejs package from our AEM instance.
Could you please have a look at this?
This is a ticket related to #28
Expected Behaviour
runPersistedQuery should be able to handle multiple variables as per API documentation https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/content-fragments.html?lang=en#web-optimized-image-delivery-request-url
Actual Behaviour
When running a persisted query with more the one variable in an HTTP GET method, the resulting variablesString in the actual code causes a ServletError
Reproduce Scenario (including but not limited to)
Use the aem-headless-client-js or the aem-headless-node-js
Root cause seems to be here: https://github.com/adobe/aem-headless-client-js/blob/main/src/index.js#L108 With multiple queries there is no ending semicolon set for the last parameter. As per the documentation this is a must as otherwise any request will fail since AEM will not know where the last param ends.
The warning message in the docs says:
The trailing ; is mandatory to cleanly terminate the list of parameters.
Steps to Reproduce
Run a persisted query which requires multiple query parameters f.e. slug and locale or a search query with multiple filter/search parameters
Platform and Version
NPM Version 3.3.0 of aem-headless-client-js
Sample Code that illustrates the problem
https://github.com/adobe/aem-guides-wknd-graphql/blob/main/advanced-tutorial/src/api/usePersistedQueries.js#L31
There should be in minimum a test that passes more then one parameter, unfortunately I couldn't find one where two or more parameters are being sent. So as of now I cannot definitely verify that multiple parameters work with this package. But they work with the GraphiQL Editor inside AEM.
I suggest to also extend the example project: https://github.com/adobe/aem-guides-wknd-graphql To have at least one use case where two parameters have to be passed in order to thoroughly test this multi-parameter functionality. That way an error for this could not so easily slip.
Logs taken while reproducing problem