Skip to content

Commit

Permalink
Fix fragment spreads parsing in Scala 3 (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdogpr authored Oct 4, 2021
1 parent 2a43549 commit 95584ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala-3/caliban/parsing/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/test/scala/caliban/parsing/ParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ object ParserSpec extends DefaultRunnableSpec {
val query = """query inlineFragmentTyping {
| profiles(handles: ["zuck", "cocacola"]) {
| handle
| ... on User {
| ...on User {
| friends {
| count
| }
Expand All @@ -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
Expand Down

0 comments on commit 95584ef

Please sign in to comment.