From 465c3eb0fdfd89d054298d33b60032da43d40b3c Mon Sep 17 00:00:00 2001 From: Yann Simon Date: Thu, 27 Jun 2024 16:13:20 +0200 Subject: [PATCH] test unparsable arguments follow-up of https://github.com/sangria-graphql/sangria-federated/pull/327 --- .../sangria/federation/v2/ResolverSpec.scala | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/core/src/test/scala/sangria/federation/v2/ResolverSpec.scala b/core/src/test/scala/sangria/federation/v2/ResolverSpec.scala index 398250d..92d452d 100644 --- a/core/src/test/scala/sangria/federation/v2/ResolverSpec.scala +++ b/core/src/test/scala/sangria/federation/v2/ResolverSpec.scala @@ -204,6 +204,36 @@ class ResolverSpec extends AnyWordSpec with Matchers { | } |}""".stripMargin) } + + "handles non-parsable arguments" in { + val testApp = AppWithResolvers() + + val args: Json = parse(s""" + { + "representations": [ + { "__typename": "State", "id": 1 }, + { "__typename": "State", "id": "bla bla" } + ] + } + """).getOrElse(Json.Null) + + val result = testApp.execute(fetchStateAndReview, args) + + QueryRenderer.renderPretty(result) should be("""{ + | data: null + | errors: [{ + | message: "Internal server error" + | path: ["_entities"] + | locations: [{ + | line: 3 + | column: 8 + | }] + | }] + |}""".stripMargin) + + testApp.testApp.db.stateDbCalled.get() should be(0) + testApp.testApp.db.reviewDbCalled.get() should be(0) + } } }