juniper icon indicating copy to clipboard operation
juniper copied to clipboard

Enums doc is wrong

Open RDruon opened this issue 3 years ago • 2 comments

Describe the bug Enums docs states that corresponding string values for the enum variants are all in uppercase. This is not the case

To Reproduce Declare an enum like

#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "graphql", derive(juniper::GraphQLEnum))]
pub enum ConfigType {
    New,
    AlreadyExisting,
}

When querying the GraphQL enum I got the following output

[root@node1 ~]# curl -k https://localhost/graphql_schema 2> /dev/null | grep "enum ConfigType" -A 4
enum ConfigType {
  NEW
  ALREADY_EXISTING
}

Expected behavior Following the docs I was expecting:

[root@node1 ~]# curl -k https://localhost/graphql_schema 2> /dev/null | grep "enum ConfigType" -A 4
enum ConfigType {
  NEW
  ALREADYEXISTING
}

RDruon avatar Feb 24 '22 14:02 RDruon

I think it originated from https://github.com/graphql-rust/juniper/pull/765 and the docs weren't updated

RDruon avatar Feb 24 '22 15:02 RDruon

@RDruon thanks!

I've haven't found anything about what variant is right in GraphQL spec.

But Apollo docs say:

  • Enum values should use ALL_CAPS, because they are similar to constants.

@ilslv so the current behavior is preferred, and we need to updated the relevant docs only.

tyranron avatar Feb 24 '22 15:02 tyranron