Skip to content

Commit a343179

Browse files
Copilotxperiandri
andcommitted
Fix escaped-string documentId test to execute valid argument path
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/1b4b4e4f-e994-4b23-92e4-8f31ed38a207 Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 09e6f86 commit a343179

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

tests/FSharp.Data.GraphQL.Tests/ExecutionTests.fs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,24 @@ let ``Execution when querying the same field twice will return it`` () : Task =
465465
[<Fact>]
466466
let ``Execution documentId handles escaped string values correctly`` () : Task =
467467
let schema =
468-
Schema (Define.Object<TwiceTest> ("Type", [ Define.Field ("a", StringType, fun _ x -> x.A); Define.Field ("b", IntType, fun _ x -> x.B) ]))
468+
Schema (
469+
Define.Object<TwiceTest> (
470+
"Type",
471+
[
472+
Define.Field (
473+
"a",
474+
StringType,
475+
"",
476+
[ Define.Input ("arg", StringType) ],
477+
fun ctx x ->
478+
match ctx.TryArg ("arg") with
479+
| ValueSome arg -> arg
480+
| ValueNone -> x.A
481+
)
482+
Define.Field ("b", IntType, fun _ x -> x.B)
483+
]
484+
)
485+
)
469486
// Query with string containing special characters that need escaping
470487
let query = """query Example { a(arg: "test\"quote\nline\ttab\\backslash") }"""
471488
task {
@@ -482,7 +499,7 @@ let ``Execution documentId is different for different queries`` () : Task =
482499
let query1 = "query Example1 { a }"
483500
let query2 = "query Example2 { b }"
484501
task {
485-
let executor = Executor(schema)
502+
let executor = Executor (schema)
486503
let! result1 = executor.AsyncExecute (query1, getMockInputContext, { A = "aa"; B = 2 })
487504
let! result2 = executor.AsyncExecute (query2, getMockInputContext, { A = "aa"; B = 2 })
488505
result1.DocumentId |> notEquals result2.DocumentId
@@ -497,7 +514,7 @@ let ``Execution documentId is same for semantically identical queries`` () : Tas
497514
let query2 = "query Example{a b}"
498515
let query3 = "query Example { a, b }"
499516
task {
500-
let executor = Executor(schema)
517+
let executor = Executor (schema)
501518
let! result1 = executor.AsyncExecute (query1, getMockInputContext, { A = "aa"; B = 2 })
502519
let! result2 = executor.AsyncExecute (query2, getMockInputContext, { A = "aa"; B = 2 })
503520
let! result3 = executor.AsyncExecute (query3, getMockInputContext, { A = "aa"; B = 2 })

0 commit comments

Comments
 (0)