Use enum value for an @id field?

Seems strange to me that I can’t use an enum value for an @id field, given that enum s are strings.

enum ISOLanguage {
  en
  ko
}

type Lexicon {
  id: ID!
  language: ISOLanguage! @id
}

{"errors":[{"message":"resolving updateGQLSchema failed because input:241: Type Lexicon; Field language: with @id directive must be of type String!, Int! or Int64!, not ISOLanguage!\n (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}%

Is this something that could change in future?

One option you may want to consider:

@auth(
  add: { rule: """query { 
    queryLexicon(filter:
     { language: { eq: "en" }, 
     or { language: { eq: "ko" }
     ...
) {
  id: ID!
  language: String! @id
}

Of course with the 200+ language codes, might not be the best option…

I’m convinced all mutations really should be custom lambda mutations in the current state of Dgraph, otherwise, at the very least, you can’t properly secure update mutations like you can add mutations, and you can’t do field validations (other than types and null).

J

1 Like

Thanks this is super helpful