Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

variable values to graphql query

Avatar

Level 1

Hello, I am trying to provide a boolean variable value to graphql request, like http://instance?query;default=true 

what I am seeing is, it treats the true as a string and not boolean, what can I do so that it is interpreted as a boolean in AEM graphql ? (FYI, i am calling AEM from scala code and the query is formed and called in scala) 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Boolean parameters in Persisted Queries is working correctly in AEM 6.5 and AEM as a Cloud Service up to version 2023.7.0. However, issue started from version 2023.8.0 and persists in the latest release.

You can check Release Notes here in Known issues section [SITES-15622: GraphQL - Issue with persisted queries with number & boolean parameters.https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/release-notes/maint... 

You can check an existing community discussion thread as well
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-implement-a-persi... 

View solution in original post

4 Replies

Avatar

Employee Advisor

Hi,

  1. GraphQL Query with Boolean Variable:

    In your GraphQL query, define the variable with the appropriate type, which in this case is Boolean.

    query MyQuery($default: Boolean) {
    yourQueryField(default: $default) {
    # Your query fields here
    }
    }

Avatar

Level 1

yes in the persisted query, the variable is defined with the required field type, the issue is when it reads the parameter passed default = true, it interprets as String, the query expects it to be boolean and thus throws exception that there is a type mismatch, Variable 'default' has an invalid value: Expected a Boolean input, but it was a String 

So my question is how can I force the interpretation from string to boolean 

Avatar

Correct answer by
Community Advisor

Boolean parameters in Persisted Queries is working correctly in AEM 6.5 and AEM as a Cloud Service up to version 2023.7.0. However, issue started from version 2023.8.0 and persists in the latest release.

You can check Release Notes here in Known issues section [SITES-15622: GraphQL - Issue with persisted queries with number & boolean parameters.https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/release-notes/maint... 

You can check an existing community discussion thread as well
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-implement-a-persi... 

Avatar

Administrator

@prachimarathe Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni