Is it possible to use "space" in enum?

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:

EnumValue:

    Name but not true or false or null

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
>        }
>     }
> }
1 Like

not working