Remove JsonValue.fs from client and migrate to System.Text.Json#576
Draft
Copilot wants to merge 4 commits into
Draft
Remove JsonValue.fs from client and migrate to System.Text.Json#576Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
[WIP] Remove JsonValue.fs and use System.Text.Json for deserialization
Remove JsonValue.fs from client and migrate to System.Text.Json
May 17, 2026
xperiandri
requested changes
May 17, 2026
Collaborator
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
Contributor
Author
Good point. Implemented in commit 9f7f617:
The result is that the bulk of the variable serialization is now done by |
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>
…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>
73fdc42 to
933ec05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.