Closed wwmoraes closed 4 years ago
502
Great! Now I can play again with numeric enum values 🥇
@wwmoraes Huh? I was mostly referring to the PR that introduced this issue.
@wwmoraes Huh? I was mostly referring to the PR that introduced this issue.
Oh, my bad. The PR's title is misleading.
Ok so just documenting here before any coding: the PR #502 does state that GraphQL enum types "only support ASCII alphanumeric characters, digits and underscores with leading non-digit" which is right, but it doesn't mention that, in GraphQL, there's no enum value: the name is the value itself.
Naming convention (first/second/latest spec [and all in between]):
Name : */[_A-Za-z][_0-9A-Za-z]/**
Enum values (first/second/latest spec):
EnumValue : Name
EnumValue : Name but not true or false or null
Even though JS doesn't have an enum type, solutions like Object.freeze()
'ing a key-value objects (being the values strings, numbers or even better, Symbol()
) simulate the same enums saw in most languages. Thus, graphql-sequelize should transcript only the enum "name" to GraphQL, making the bridge between the name and value in sequelize queries.
@wwmoraes Mind working on a PR? Then we can discuss the changes and cut it as a major
@mickhansen sure thing!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
As per PR #637, the
function sanitizeEnumValue()
does not comply with the GraphQL documentation:value?: any
)value.trim()
'1'
is sanitized to'_1'
)I didn't found any references on the docs for why number/numeric-started string values need an underscore prefix.