No custom enums as types in schema
See original GitHub issueI’d like to create and register a custom enum, for example:
enum AllowedColor {
RED
GREEN
BLUE
}
and in my schema, to use it as a type:
color: {
label: 'Color',
type: AllowedColor,
input: 'select',
options: function() {
// options for the select form control
return [
{ value: 'RED', label: 'Red' },
{ value: 'GREEN', label: 'Green' },
{ value: 'BLUE', label: 'Blue' },
];
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Swagger schema not showing custom value of enum
But the swagger.json is showing DOG and CAT in place of dog and cat . I don't want the user to see the...
Read more >[Question] How to define a custom enum property and show it ...
Background: There is a way to define enum fields in json-schema and there is a way to define enums in api-platform. Questions:.
Read more >Enums - Swagger
Reusable enums In OpenAPI 3.0, both operation parameters and data models use a schema , making it easy to reuse the data types....
Read more >Use the new Enum type in Ecto 3.5 | Dennis Beatty
Enum which allows you to store enums in your database without any other ... EctoEnum library has been the best way to set...
Read more >MySQL 8.0 Reference Manual :: 11.3.5 The ENUM Type
An enumeration value can also be the empty string ( '' ) or NULL under certain circumstances: If you insert an invalid value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
We’ve discussed it with @Apollinaire and it actually seems to be a counter-productive idea, especially when taking values from
allowedValues
.The biggest issue is that enums need to have a very specific format, the “Name” format in the GraphQL spec, which disallows most chars excepts letters, while allowedValues can be rich strings.
So the current solution to this issue specifying a custom GraphQL type for a field (not sure if we can do that yet? if not we will add this feature soon) + use the
addGraphQLSchema
function to define a new type.We could support an additional field in the schema to directly specify enums but I am not sure the use case is worth it.
I confirm we will add the possibility to provide your own graphQL type in the future.
The current solution should be (not tested):
In the future we will add a simpler way to specify a custom GraphQL type, we did not agree on an intuitive field name/syntax yet. I keep the issue open for reference but technically it is solved.