ChilliCream / ChilliCream/graphql-platform
Extending enum values set results in breaking changes in StrawberryShake client
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Is there an existing issue for this?
- I have searched the existing issues
Product
Strawberry Shake
Describe the bug
If I extend a given enum with a new value, then the client generated by StrawberryShake treats that value as incorrect and throws an exception. This prevents the server from extending the contract without breaking all clients. Adding a new version of the contract (v2, v3, etc) just because a single enum has been extended imposes huge maintenance costs.
Adding a new enum value should not be treated as breaking changes. There should be a configuration switch to override this behaviour. Ideally, the generated enum should have an extra value like "UKNOWN", and the de-serialised should map all values outside the known set to this special element. This will allow the developer to handle this situation directly in their code.
I'm not sure if this issue should be threatened as a bug, but I use StrawberryShake to generate my clients and now I'm in a very uncomfortable position ;)
Steps to reproduce
- Create a graphql server that returns an enum value
- Generate client using StrawberryShake
- Extend enum values on the server with a new option
- Now the client throws an exception if the returned set contains an entity with the new enum value
The expected generated code should look something like that:
public enum SampleEnumType
{
Unknown, // Extra option to represents all values that client doesn't know about
One,
Two
}
public ContractExecutionType Parse(global::System.String serializedValue)
{
return serializedValue switch
{
"ONE" => SampleEnumType.One,
"TWO" => SampleEnumType.Two,
_ => SampleEnumType.Unknown // Map all new values to `Unknown `
}
}
Relevant log output
No response
Additional Context?
No response
Version
13.8.1.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by reproducing the StrawberryShake generated-client failure, then trace the generated enum Parse entry point shown in the issue and its configuration or code-generation path. Done means newly added server enum values no longer throw and are represented by the proposed unknown value, with coverage for enum deserialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, graphql
- Domain
- api
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100