I am using JSS with Sitecore 10, and using the GraphQL search query, but I got this error after deploying to Sitecore:
ERROR Error: GraphQL error: Query is too complex to execute. The field with the highest complexity is: Field{name='field', alias='link', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=InlineFragment{typeCondition=NamedType{name=LinkField}, directives=GraphQL.Language.AST.Directives, selections=SelectionSet{selections=Field{name='url', alias='', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=}}, Field{name='linkType', alias='', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=}}, Field{name='text', alias='', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=}}, Field{name='__typename', alias='', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=}}}}, Field{name='__typename', alias='', arguments=GraphQL.Language.AST.Arguments, directives=GraphQL.Language.AST.Directives, selectionSet=SelectionSet{selections=}}}}
at new t (main.fbe7d52e54c38205dd22.js:1)
at main.fbe7d52e54c38205dd22.js:1
at main.fbe7d52e54c38205dd22.js:1
at Set.forEach (<anonymous>)
at main.fbe7d52e54c38205dd22.js:1
at Map.forEach (<anonymous>)
at e.broadcastQueries (main.fbe7d52e54c38205dd22.js:1)
at main.fbe7d52e54c38205dd22.js:1
at Object.next (main.fbe7d52e54c38205dd22.js:1)
at y (main.fbe7d52e54c38205dd22.js:1)
Although it was working fine in GraphQL UI, I found the reason of the issue but I do not know how to fix it. The reason is a Multilist field because when I removed it, it is working fine in Sitecore.
This my GraphQL query:
query StaggeredInfoCardsSearch($rootItem:String){
search(fieldsEqual: [{name: "_templatename", value: "detailsPage"}
],
rootItem:$rootItem
) {
results {
items {
item {
displayName
id
name
template {
id
}
title: field(name: "title") {
value
}
description: field(name: "description") {
value
}
shortDescription: field(name: "shortDescription") {
value
}
thumbnailImage: field(name: "thumbnailImage") {
... on ImageField {
src(maxWidth: 352,maxHeight:264)
}
}
date: field(name: "date") {
... on DateField {
formattedDateValue(format:"MMM dd, yyyy, HH:mm")
}
}
link: field(name: "link") {
... on LinkField {
url
linkType
text
}
}
file: field(name: "file") {
... on FileField {
url
title
}
}
category: field(name: "category") {
value
}
location: field(name: "location") {
value
}
socialMediaLinks: field(name: "socialMediaLinks") {
... on MultilistField {
targetItems {
id
name
link: field(name: "link") {
... on LinkField {
url
linkType
text
}
}
image: field(name: "image") {
... on ImageField {
src
}
}
}
}
}
}
}
totalCount
}
}
}
Any idea about this error?