Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ class DifferentShape(override val message: String, override val sourceLocation:

class UnusedFragment(override val message: String, override val sourceLocation: SourceLocation?) : GraphQLValidationIssue

/**
* There is a fragment cycle.
*
* See https://spec.graphql.org/September2025/#sec-Fragment-Spreads-Must-Not-Form-Cycles
*/
class FragmentCycle(override val message: String, override val sourceLocation: SourceLocation?) : GraphQLValidationIssue

/**
* Two type definitions have the same name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.apollographql.apollo.ast.Catch
import com.apollographql.apollo.ast.DeprecatedUsage
import com.apollographql.apollo.ast.DifferentShape
import com.apollographql.apollo.ast.ExecutableValidationResult
import com.apollographql.apollo.ast.FragmentCycle
import com.apollographql.apollo.ast.GQLArgument
import com.apollographql.apollo.ast.GQLBooleanValue
import com.apollographql.apollo.ast.GQLDirective
Expand Down Expand Up @@ -117,7 +118,7 @@ internal class ExecutableValidationScope(
val index = path.indexOf("__${name}")
val nextPath = path + "__${fragment.name}"
if (index != -1) {
registerIssue("Fragment '$name' spreads itself, creating a cycle at '${nextPath.subList(index, nextPath.size).joinToString(".")}'", it.sourceLocation)
issues.add(FragmentCycle("Fragment '$name' spreads itself, creating a cycle at '${nextPath.subList(index, nextPath.size).joinToString(".")}'", it.sourceLocation))
cyclicFragments.add(name)
return@forEach
}
Expand Down
Loading