Is it possible to use “space” in enum?
My use case is
enum CountryName{ "United States" Italy ect... }
Is it possible to use “space” in enum?
My use case is
enum CountryName{ "United States" Italy ect... }
Spaces aren’t allowed in enum values. That’s defined in the GraphQL spec:
Name but not
true
orfalse
ornull
Enum values are represented as unquoted names (ex.
MOBILE_WEB
). It is recommended that Enum values be “all caps”. Enum values are only used in contexts where the precise enumeration type is known. Therefore it’s not necessary to supply an enumeration type name in the literal.
[Update] I found a solution to solve this problem.
Add a “Description” to ENUM.
http://spec.graphql.org/October2021/#sec-Descriptions
So I am schema
> enum USERTYPE{
>
> "users account"
>
> USER
>
> "admin account"
>
> ADMINISTRATOR
>
> "supperadmin account"
>
> SUPERADMINISTRATOR
> }
In query,
> query {
> # previous queries
> __type(name: "USERTYPE") {
> states: enumValues {
> name
> description
> }
> }
> }
not working
Create a product with a connection field.
type product {
id: ID!
name: String!
connection: connection
}
enum connection {
"USB-A"
USB_A
"USB-B"
USB_B
}
In query i use __type as below which is working fine.
{
queryproduct {
id
name
connection
}
__type(name: "connection") {
connection: enumValues {
name
description
}
}
}
But in product return data connection return USB_A and USB_B can i show original value instead of that?