Skip to content

Commit f1bdef9

Browse files
Copilotxperiandri
andcommitted
Address code review: fix typo, inline JsonWriterOptions, improve error message
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/f2373ad8-e1ad-4cd6-8854-dc45f7e71e0c Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 1a04300 commit f1bdef9

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/FSharp.Data.GraphQL.Client/BaseTypes.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,9 @@ module internal JsonValueHelper =
565565
/// The base type for all GraphQLProvider operation result provided types.
566566
type OperationResultBase
567567
(rawResponse : HttpResponseMessage, responseJson : string, operationFields : SchemaFieldInfo[], operationTypeName : string) =
568-
let parsedJson = System.Text.Json.JsonDocument.Parse responseJson
568+
let parsedJson =
569+
try System.Text.Json.JsonDocument.Parse responseJson
570+
with ex -> raise (System.InvalidOperationException ($"Failed to parse GraphQL response JSON: {ex.Message}", ex))
569571
let rootElement = parsedJson.RootElement
570572

571573
let rawData =
@@ -619,7 +621,7 @@ type OperationResultBase
619621
interface IDisposable with
620622
member _.Dispose () = parsedJson.Dispose ()
621623

622-
/// The base type for al GraphQLProvider operation provided types.
624+
/// The base type for all GraphQLProvider operation provided types.
623625
type OperationBase (query : string) =
624626
/// Gets the query string of the operation.
625627
member _.Query = query

src/FSharp.Data.GraphQL.Client/Serialization.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ module Serialization =
283283
let buildRequestJson (operationName : string option) (query : string) (variables : (string * obj) []) =
284284
Tracer.runAndMeasureExecutionTime "Built GraphQL request JSON" (fun _ ->
285285
use stream = new MemoryStream ()
286-
let writerOptions = JsonWriterOptions (Indented = false)
287-
use writer = new Utf8JsonWriter (stream, writerOptions)
286+
use writer = new Utf8JsonWriter (stream, JsonWriterOptions (Indented = false))
288287
let write = writeValue writer
289288
writer.WriteStartObject ()
290289
writer.WritePropertyName "operationName"
@@ -310,8 +309,7 @@ module Serialization =
310309
let buildMapJson (files : (string * Upload) []) =
311310
Tracer.runAndMeasureExecutionTime "Built GraphQL map JSON" (fun _ ->
312311
use stream = new MemoryStream ()
313-
let writerOptions = JsonWriterOptions (Indented = false)
314-
use writer = new Utf8JsonWriter (stream, writerOptions)
312+
use writer = new Utf8JsonWriter (stream, JsonWriterOptions (Indented = false))
315313
writer.WriteStartObject ()
316314
files
317315
|> Array.iteri (fun ix (name, _) ->

0 commit comments

Comments
 (0)