diff --git a/core/src/main/scala-3/caliban/parsing/Parser.scala b/core/src/main/scala-3/caliban/parsing/Parser.scala index 663e2b61f..77787a021 100644 --- a/core/src/main/scala-3/caliban/parsing/Parser.scala +++ b/core/src/main/scala-3/caliban/parsing/Parser.scala @@ -286,7 +286,7 @@ object Parser { private val fragmentName: P[String] = name.filter(_ != "on") private val fragmentSpread: P[FragmentSpread] = - ((P.string("...").soft *> fragmentName <* whitespaceWithComment) ~ directives.?).map { case (name, dirs) => + ((P.string("...").soft *> fragmentName <* whitespaceWithComment).backtrack ~ directives.?).map { case (name, dirs) => FragmentSpread(name, dirs.getOrElse(Nil)) } diff --git a/core/src/test/scala/caliban/parsing/ParserSpec.scala b/core/src/test/scala/caliban/parsing/ParserSpec.scala index c30653883..402a9fe80 100644 --- a/core/src/test/scala/caliban/parsing/ParserSpec.scala +++ b/core/src/test/scala/caliban/parsing/ParserSpec.scala @@ -324,7 +324,7 @@ object ParserSpec extends DefaultRunnableSpec { val query = """query inlineFragmentTyping { | profiles(handles: ["zuck", "cocacola"]) { | handle - | ... on User { + | ...on User { | friends { | count | } @@ -350,13 +350,13 @@ object ParserSpec extends DefaultRunnableSpec { Some(NamedType("User", nonNull = false)), Nil, List( - simpleField("friends", selectionSet = List(simpleField("count", index = 126)), index = 108) + simpleField("friends", selectionSet = List(simpleField("count", index = 125)), index = 107) ) ), InlineFragment( Some(NamedType("Page", nonNull = false)), Nil, - List(simpleField("likers", selectionSet = List(simpleField("count", index = 187)), index = 170)) + List(simpleField("likers", selectionSet = List(simpleField("count", index = 186)), index = 169)) ) ), index = 31