graphql / graphql/graphql-spec
Enum as scalar type
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes, it's useful for declaring an interface that expect to receive an Enum, but you don't want to specify it on interface level, but in the implementation level.
Consider the example:
```graphql
enum TemperatureUnit {
C
F
}
enum WeightUnit {
G
OZ
}
interface MeasurableValue {
value: Float
unit: Enum
}
type WeightValue implements MeasurableValue {
value: Float
unit: WeightUnit
}
type TemperatureValue implements MeasurableValue {
value: Float
unit: TemperatureUnit
}
type TemperatureTask {
type: TaskType!
value: TemperatureValue
}
```
I tried to replicate this example as minimum as possible, if needed I can provide a more complex one.
But in this case, today if we want to achieve a behavior like this, we need to keep unit out of our interface, because we can't specify a generic type and override it in the implementation of the interface.
Contributor guide
Assessment
This issue has not been assessed yet.