Skip to content

C# Plugin: Add configuration for JSON attributes #6341

@seclerp

Description

@seclerp

Is your feature request related to a problem? Please describe.

C# plugin has hardcoded behavior when dealing with JSON attributes. It always uses Newtonsoft.Json. This flow is unacceptable for such scenarios:

  1. Use plugin without generating JSON attributes.
  2. Use JSON attributes of another library (like standardized System.Text.Json).

I would like to use this plugin and library in general to generate POCO classes for my GraphQL schema in the Schema-first HotChocolate project, but I am not using Newtonsoft.Json and don't want to embed it in my project for fixing such a case.

Describe the solution you'd like
Add 2 additional options for configuration:

  • emitJsonAttributes: boolean (default: true, to keep compatibility)
  • jsonAttributesSource: 'Newtonsoft.Json' | 'System.Text.Json' | ... (default: 'Newtonsoft.Json' to keep compatibility)

The second option will be ignored when the first one is undefined or false.

I already have a solution in my fork, will create PR for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementNew feature or requeststage/5-alpha-release-testingThe pull request is merged, an alpha release is available, to be tested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions