Password field in GraphQL as custom dgraph type

Why I can not set the GraphQL field “password” to the Dgraph password type that I have defined

password: password .

type User {
  email: String! @dgraph(pred: "email")
  name: String! @dgraph(pred: "name")
  password: String! @dgraph('password')
}

I get this error: Schema change not allowed from PASSWORD to STRING

The Dgraph password type is not query-able as a field. This is settable using the @secret directive on the type itself, where you can set a field and pred for the type. For example, if you set the Dgraph schema as:

password: password .

Then, in your GraphQL schema, you can use this predicate like so:

type User @secret(field: "userPassword", pred: "password") {
  ...
}

See the docs for more info: https://dgraph.io/docs/graphql/schema/types/#password-type

1 Like

Thank you. Cheers

Above is GraphQL way.
Just save some time for future people, the DQL way for echking password is at https://dgraph.io/docs/query-language/schema/#password-type
:grinning:

2 Likes