Skip to content

Commit 513aba4

Browse files
Copilotxperiandri
andcommitted
Refine OperationError combination test JSON construction
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/320a28b0-d97e-496d-a15c-3eded764faab Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 2872075 commit 513aba4

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

tests/FSharp.Data.GraphQL.IntegrationTests/OperationErrorTests.fs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ let ``Should parse all combinations of optional operation error fields`` () =
5656
includePath, includeLocations, includeExtensions ]
5757

5858
for includePath, includeLocations, includeExtensions in combinations do
59-
let errorFields = ResizeArray<string>([ "\"message\":\"unit-test combination error\"" ])
60-
61-
if includePath then
62-
errorFields.Add "\"path\":[\"alwaysError\",0]"
63-
64-
if includeLocations then
65-
errorFields.Add "\"locations\":[{\"line\":2,\"column\":13}]"
66-
67-
if includeExtensions then
68-
errorFields.Add "\"extensions\":{\"code\":\"UNIT_TEST\",\"retryable\":false,\"severity\":7}"
69-
70-
let responseJson =
71-
$"""{{"errors":[{{{String.concat "," errorFields}}}]}}"""
59+
let optionalFields =
60+
[ if includePath then
61+
"\"path\":[\"alwaysError\",0]"
62+
if includeLocations then
63+
"\"locations\":[{\"line\":2,\"column\":13}]"
64+
if includeExtensions then
65+
"\"extensions\":{\"code\":\"UNIT_TEST\",\"retryable\":false,\"severity\":7}" ]
66+
67+
let errorObjectJson =
68+
"\"message\":\"unit-test combination error\"" :: optionalFields
69+
|> String.concat ","
70+
71+
let responseJson = $"""{{"errors":[{{{errorObjectJson}}}]}}"""
7272

7373
let result =
7474
OperationResultBase(

0 commit comments

Comments
 (0)