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

Using variables in runQuery #37

Closed
yousiftouma opened this issue Oct 13, 2022 · 3 comments · Fixed by #41
Closed

Using variables in runQuery #37

yousiftouma opened this issue Oct 13, 2022 · 3 comments · Fixed by #41

Comments

@yousiftouma
Copy link

Expected Behaviour

I can send variables property in a GQL query that has parameters

Actual Behaviour

I can not use variables in GQL queries

Reproduce Scenario (including but not limited to)

Try to use runQuery with variables

Steps to Reproduce

Try to use runQuery with variables

Platform and Version

Sample Code that illustrates the problem

Pseudo code in the context of AdobeIO

let body;
if (params.variables) {
 body = { query: params.query, variables: params.variables };
} else {
 body = params.query
}
... runQuery(body);

Logs taken while reproducing problem

I'm not sure if it is possible, if it is how would one use variables in a query?

@yousiftouma
Copy link
Author

Corresponding feature is explicitly available in the java client:
https://github.com/adobe/aem-headless-client-java/blob/main/README.md#running-queries

Any input?
@easingthemes @bdelacretaz (sorry for pings, but don't know if this repo is watched)

easingthemes added a commit that referenced this issue Dec 13, 2022
easingthemes added a commit that referenced this issue Dec 13, 2022
@easingthemes
Copy link
Collaborator

PR opened,

@param {string} query - the query string

Changed to

@param {string|object} body - the query string or an object with query (and optionally variables) as a property

in

runQuery (body,  ...)

This way it's backward compatible.

Usage

# new
runQuery({
  query: queryString
  variables: {
    var1: val1,
    ...
  }
})
# or old
runQuery(queryString);

easingthemes added a commit that referenced this issue Dec 13, 2022
@yousiftouma
Copy link
Author

Cool, thanks! Hope to see it merged soon @easingthemes

easingthemes added a commit that referenced this issue Mar 5, 2023
* #37 add support for variables

* #37 fix backward compatibility

* #37 simplify post body
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

Successfully merging a pull request may close this issue.

2 participants