{
"data": {
"sampleCFByPath": {
"item": {
"title": "Sample CF",
"section": [
"{\"field1\":\"value 1\",\"field2\":false}"
]
}
}
}
}
{
"data": {
"sampleCFByPath": {
"item": {
"title": "Sample CF",
"section": [
{
"field1": "value 1",
"field2": false
}
]
}
}
}
}
Solved! Go to Solution.
Views
Replies
Total Likes
Based on the sample which you shared it does not look like a standard cf multifield but rather some customized version of it, hence it might be easier to process the graphql response on front end.
The js code which I shared will be used by the application consuming your graphql query. So, you can check the place where the graphql query is being invoked (For e.g in some headless app or within AEM) and then can easily process the response as per your requirements.
Hope this helps.
Hi @ElkinTo
Is your fragment property is multifield like below ?
Please try below in graphQL query editor for multifield property. It should give desired output like you're expecting
multifieldName {
name // name property
multi // string[] property
}
Hope this helps
Hi @PRATHYUSHA_VP ,
Thanks for your help. I tried your suggestion but didn't work. I'm getting this error:
Validation error (SubselectionNotAllowed@[staticLandingByPath/item/contentSection]) : Subselection not allowed on leaf type '[String]' of field 'contentSection'
Field is defined like this:
My GraphQL query is:
query getStaticLandingByPath($fragmentPath: String!) {
staticLandingByPath(_path: $fragmentPath) {
item {
pageTitle
...
contentSection
}
}
}
Any other ideas? Some way of customizing GraphQL API response?
Views
Replies
Total Likes
Hi @ElkinTo
You're trying to access object directly, hence the error -
Please check below -
https://graphql.org/learn/queries/#inline-fragments
If still facing issue, please share your content fragment model
Thanks
Views
Replies
Total Likes
Thanks @PRATHYUSHA_VP ,
I tried that as well but no luck, I think your suggestion works well for RTE - multieditor fields, but ours is a customized one that has mulitple internal fields, some even are multifields with more nested fields. We'll have to create an intermediate servlet that captures GraphQL response and do the required transformations or ask clients to do the transformation in their side.
Could you share how does your model look like ?
And not sure about the possibility, but I think this can be easily handled on Front end rather than going for any customization.
JSON.parse("{\"field1\":\"value 1\",\"field2\":false}")
Hi @h_kataria ,
Thanks for your help. How and where could I add that JS code?
Views
Replies
Total Likes
@ElkinTo Regarding - would like to transform some fields before responding:
Suggest performing JSON operation at fronted, not at the backed schema level change as it seems like string transformation use case
Based on the sample which you shared it does not look like a standard cf multifield but rather some customized version of it, hence it might be easier to process the graphql response on front end.
The js code which I shared will be used by the application consuming your graphql query. So, you can check the place where the graphql query is being invoked (For e.g in some headless app or within AEM) and then can easily process the response as per your requirements.
Hope this helps.
Views
Likes
Replies
Views
Likes
Replies