Uh oh!
There was an error while loading. Please reload this page.
Remove JsonValue.fs from client and migrate to System.Text.Json - #576
Remove JsonValue.fs from client and migrate to System.Text.Json#576xperiandri with Copilot wants to merge 4 commits into
Conversation
xperiandri
left a comment
There was a problem hiding this comment.
What is the sense of having so much custom logic?
Cannще we pass JsonSerializerOptions into context and use JsonSerialzer to serialize and JsonSerialzer or JsonDocument/JsonElement to deserialize? Anyway we have already built the output types in the type provider
Good point. Implemented in commit 9f7f617:
The result is that the bulk of the variable serialization is now done by |
73fdc42 to
933ec05CompareAgent-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>
…r 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>
…nSerializer.Serialize for variables Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/63700bd7-a033-4fb4-a394-21e09ca3943e Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/63700bd7-a033-4fb4-a394-21e09ca3943e Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
933ec05 to
4d4799fCompare
The custom
JsonValue.fsdeserializer inferred numeric types from JSON structure rather than the GraphQL schema, causing schema-declaredFloatfields returning0.0to be deserialized asint optioninstead offloat option.Core fix
JsonValueHelper.getFieldValueinBaseTypes.fsnow resolves the CLR type from the schemaIntrospectionTypeRefwhen handlingJsonValueKind.Number, ensuringFloat 0→float,Int 0→int, etc.Removed
JsonValue.fsandTextConversions.fsremoved from bothFSharp.Data.GraphQL.ClientandFSharp.Data.GraphQL.Client.DesignTimeproject filesReplaced with System.Text.Json
Serialization.fs: NewSchemaParsermodule manually traversesJsonElementto parse the introspection schema. ExposesdefaultSerializerOptions(lazy, backed byShared.Json.getSerializerOptions). Request JSON building usesJsonSerializer.Serializevia anormalizeForSerializationpre-processor that handles camelCase key normalization on nestedIDictionary<string,obj>values,System.Uri→ string, andUpload→ form-part name.deserializeMapusesJsonElement.BaseTypes.fs(JsonValueHelper): All pattern matching rewritten fromJsonValueDU cases toJsonElement.ValueKind.OperationResultBase: Now accepts the raw responsestringand parses it internally withJsonDocument(implementsIDisposable); removes theJsonValue.Parsecall fromProvidedTypesHelper.fs.GraphQLClient.fs: Request/multipart construction rewritten; variables serialized viaJsonSerializer.Serializewith the context'sJsonSerializerOptions.GraphQLProviderRuntimeContext: Exposes aJsonSerializerOptionsproperty (defaults todefaultSerializerOptions) so callers can inject custom options (e.g. custom scalar converters).GetContextaccepts an optionaljsonSerializerOptionsparameter.Test updates
OperationErrorTests.fs:JsonValue.Parsecalls replaced with raw JSON strings, matching the newOperationResultBase(string)constructor.