Skip to content

Serialize sbyte values as JSON numbers in StrawberryShake#9827

Merged
glen-84 merged 3 commits into
mainfrom
gai/sbyte-json-number-serialization
Jun 3, 2026
Merged

Serialize sbyte values as JSON numbers in StrawberryShake#9827
glen-84 merged 3 commits into
mainfrom
gai/sbyte-json-number-serialization

Conversation

@glen-84

@glen-84 glen-84 commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Byte! variables were serialized as JSON strings ("2") instead of numbers (2), causing v16 servers to reject them.
  • Root cause: ByteSerializer became ScalarSerializer<sbyte> in v16, but JsonSerializationHelper.WriteValue had no sbyte case, so values fell through to string serialization.
  • Added the missing sbyte case (placed beside byte, signed-before-unsigned to match the existing 16/32/64-bit pairs).

Test plan

  • Added JsonSerializationHelperTests.WriteSByteAsNumber verifying sbyte serializes as a JSON number.
  • Added the previously-missing SByte entry to the comprehensive Serialize_Request_With_Extensions numeric-matrix snapshot test.
  • Both tests confirmed failing before the fix and passing after; full Json + Serialization test areas pass (154 tests, net8.0/net9.0/net10.0).

Closes #9825

Copilot AI review requested due to automatic review settings June 3, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes StrawberryShake JSON variable/extension serialization for Byte! (runtime sbyte in v16) by ensuring sbyte values are emitted as JSON numbers instead of quoted strings, restoring compatibility with v16 GraphQL servers.

Changes:

  • Add explicit sbyte handling to JsonSerializationHelper.WriteValue so boxed sbyte values serialize as JSON numbers.
  • Add a targeted unit test asserting sbyte serializes to an unquoted JSON number.
  • Extend the existing “extensions numeric matrix” snapshot test to include SByte.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/StrawberryShake/Client/src/Core/Json/JsonSerializationHelper.cs Adds sbyte case to write numeric JSON output instead of falling back to string serialization.
src/StrawberryShake/Client/test/Core.Tests/Json/JsonSerializationHelperTests.cs Adds a focused unit test covering sbyte numeric serialization.
src/StrawberryShake/Client/test/Core.Tests/Json/JsonOperationRequestSerializerTests.cs Extends the extensions serialization test to include an SByte entry.
src/StrawberryShake/Client/test/Core.Tests/Json/__snapshots__/JsonOperationRequestSerializerTests.Serialize_Request_With_Extensions.snap Updates snapshot to reflect SByte being serialized as a JSON number.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glen-84 glen-84 merged commit 548b5f2 into main Jun 3, 2026
144 checks passed
@glen-84 glen-84 deleted the gai/sbyte-json-number-serialization branch June 3, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Byte scalar variable sent as JSON string, server rejects it on v16

2 participants