I'm struggling with my GraphQL API because I need to take advantage of Enums while keeping their full description in the frontend.
In short:
I have different states for a product: "Has been sent"
, "Not sent yet"
, "Received"
.
So this is the right place to use Enums:
enum ProductState {
HAS_BEEN_SENT
NOT_SENT_YET
RECEIVED
}
But I need to display the proper strings on the frontend ("Has been sent
", and not "HAS_BEEN_SENT
").
I can't use a simple solution as "replace underscores with spaces and lowercase the string" because my API is not in English but in French (so I have accents and special characters).
Can't an Enum return a string? Or an object? I tried with directives but impossible to get it work...
Actually I don't care how it is written in the database (the uppercase or lowercase form) nor in the GraphQL API. I just need my client to access to the different product states in their "French" form.