Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runPersistedQuery is not being able to handle multiple variables - missing semicolon after last param #61

Open
colinscz opened this issue Mar 6, 2024 · 1 comment

Comments

@colinscz
Copy link

colinscz commented Mar 6, 2024

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

@colinscz
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant