Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
{
"data": {
"sampleCFByPath": {
"item": {
"title": "Sample CF",
"section": [
"{\"field1\":\"value 1\",\"field2\":false}"
]
}
}
}
}
{
"data": {
"sampleCFByPath": {
"item": {
"title": "Sample CF",
"section": [
{
"field1": "value 1",
"field2": false
}
]
}
}
}
}
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
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.
Vistas
Respuestas
Total de me gusta
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
Vistas
Respuestas
Total de me gusta
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?
Vistas
Respuestas
Total de me gusta
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
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
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.
Vistas
Respuestas
Total de me gusta
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}")
Vistas
Respuestas
Total de me gusta
Hi @h_kataria ,
Thanks for your help. How and where could I add that JS code?
Vistas
Respuestas
Total de me gusta
@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
Vistas
Respuestas
Total de me gusta
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.
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas