You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue with that approach is that we will now have conflicting constants in our unions in graphql.
Describe the solution you'd like
I would like one of the following solutions
Discriminated items should be tagged with some kind of directive in graphql schema. They should still be a String, but TS codegen should use the directive to resolve the types correctly.
A flag to tell the schema generator to threat enums as strings (not as clean as first one, but based on the current workaround we use)
Describe alternatives you've considered
We currently use the enum solution, but then we do some post-processing in the schemas and replace all constants with strings so we dont face the problem with conflicting types. Thats not a nice solution tho as we are manipulating generated code and if we want to use constants at some point, we wont be able to.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Typescript codegen does not apply open api discriminator as string constant in related objects.
For example, in the following open api file
Output is
Which is correct, but then, when generating types, the discriminator is completely ignored
This way we lost the ability to narrow Pet down to Cat or Dog using its petType property.
One alternative that fixes the issue is to declare the properties as constants like the following:
Then, we get something like the following in schema
And types are correct
The issue with that approach is that we will now have conflicting constants in our unions in graphql.
Describe the solution you'd like
I would like one of the following solutions
Describe alternatives you've considered
We currently use the enum solution, but then we do some post-processing in the schemas and replace all constants with strings so we dont face the problem with conflicting types. Thats not a nice solution tho as we are manipulating generated code and if we want to use constants at some point, we wont be able to.
The text was updated successfully, but these errors were encountered: