graphql-dotnet / graphql-dotnet/graphql-client

SystemTextJsonSerializer with ReferenceHandler.Preserve in options

Open
#569 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

## Description

trying to use `SystemTextJsonSerializer(new JsonSerializerOptions() { ReferenceHandler = ReferenceHandler.Preserve })`
to ignore cycles in many to many relationships doesn't work because it distorts the json and the server doesn't parse the variables correctly. The first problem is that it loses case insensitivity so it expects all my variables to match the case of my c# variables. The second problem is that when ReferenceHandler.Preserve is set it add id variables to the json and that gets sent over to the graphql server and it doesn't know how to parse it. So I guess my question is does this setting in JsonSerializerOptions just not work?

### Steps to reproduce
Create a small schema that uses standard c# uppercase variables then write a query or a mutation that only uses lower case variables. If you run the queries with the default SystemTextJsonSerializer constructor it works fine and the case insensitivity is applied. If you add the ReferenceHandler.Preserve option it no longer parses your query appropriately and the back end will report an error of not being able to find any of your non-nullable variables because they dont match case.

### Expected result

It works as before and ignores any detected loops

### Actual result

applying the ReferenceHandler = ReferenceHandler.Preserve leads to loss of case insensitivity and json that can't be parsed by the server

### Environment

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.