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
Describe the bug
Enums defined in the graphql schema are transpiled into typescript type definitions.
For the purpose of mapping responses from a connected shop into one of those enums the types are not feasible at all.
An example is the MeasurementUnit enum, that will get transpiled to
export type MeasurementUnit =
| 'ACRE'
| 'ARES'
this isn't very usable when hydrating the article.salesUnit.name field from the response of a connected shop, as this will always be a String, which isn't allowed as MeasurementUnit.
Proposal is to either find a way that enums from the graphql schema are transpiled to enums in typescript or always add the String to those enums, which makes them useless.
The text was updated successfully, but these errors were encountered:
Although generating TypeScript enums for GraphQL enums would work with GraphQL Code Generator, the issue is that TypeScript Enums eventually have to be transpiled to JavaScript. They are not "types" like interface or type. The purpose of generating TypeScript definitions for the GraphQL schema is actually meant to help using the schema, but not to force developers to use TypeScript in any way.
If the underlying system already provides values that can be passed through to objects without having to be transformed, one could still provide type hints:
constunitName='...';// from underlying systemconstmyBaseUnit: BaseUnit={id: 'ITEM',name: unitNameasMeasurementUnit,interval: 1,minQuantity: 1,standardQuantity: 1,};
Describe the bug
Enums defined in the graphql schema are transpiled into typescript type definitions.
For the purpose of mapping responses from a connected shop into one of those enums the types are not feasible at all.
An example is the
MeasurementUnit
enum, that will get transpiled tothis isn't very usable when hydrating the
article.salesUnit.name
field from the response of a connected shop, as this will always be a String, which isn't allowed asMeasurementUnit
.Proposal is to either find a way that enums from the graphql schema are transpiled to enums in typescript or always add the
String
to those enums, which makes them useless.The text was updated successfully, but these errors were encountered: