variable values to graphql query | Community
Skip to main content
September 20, 2023
Solved

variable values to graphql query

  • September 20, 2023
  • 3 replies
  • 1594 views

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) 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mahedi_Sabuj

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... 

3 replies

ManviSharma
Adobe Employee
Adobe Employee
September 20, 2023

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
    }
    }
September 20, 2023

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 

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
September 20, 2023

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... 

Mahedi Sabuj
kautuk_sahni
Community Manager
Community Manager
September 21, 2023

@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