I have a content fragment model having a single-valued field of type Fragment reference, in which 2 Content Fragment models are allowed.
I am looking into the most effective approach to write a Graphql query handling both content fragment models within a single field. Our initial attempt encompassed the inclusion of fields from both content fragment models within the said field; however, this endeavour resulted in query disruptions. Upon execution of Graphql query it throws error:
Validation error of type FieldUndefined: Field 'title' in type 'AllFragmentModels' is undefined @ 'productList/items/flag/title'"
Your insights and recommendations on this matter would be greatly valued. Please share if you have any example queries for reference.
Update:
Find below a screenshot of the field showing the concerned field.
The query used is:
query productList($productID:String,$locale:String)
{productList(filter:{
productID : {_expressions: [{value:$productID}]}},
_locale : $locale
)
{items{
flag{title,backgroundColor,flagColor,saveOffer},
}
}
}
This query work fine if I only allow a single content fragment model in the field. Issue is only with multiple content fragment allowed. Wondering if I'm missing something..
Solved! Go to Solution.
Views
Replies
Total Likes
I think I figure out the issue. To share with everyone correct query is:
query productList($productID:String,$locale:String)
{productList(filter:{
productID : {_expressions: [{value:$productID}]}},
_locale : $locale
)
{items{
flag {
... on ProductFlagModel{title,backgroundColor,flagColor,saveOffer},
}
}
}
}
@Mukesh_Kumar_Co Please share the GraphQl query, resulting in error. Also, the screenshot of the Content Fragment Models, you are encompassing in a single query
Hi @krati_garg , I have updated the question to add the required details.
I think I figure out the issue. To share with everyone correct query is:
query productList($productID:String,$locale:String)
{productList(filter:{
productID : {_expressions: [{value:$productID}]}},
_locale : $locale
)
{items{
flag {
... on ProductFlagModel{title,backgroundColor,flagColor,saveOffer},
}
}
}
}
Views
Likes
Replies
Views
Likes
Replies