I have a question with graphQL (actually I have a lot because I just started using it, but this one is punctual)
Let's imagine that I declare a type
, for example Usuarios
.
type Usuario {
username: String!
password: String!
}
And then I have the queryUsuarios
Querys {
getUsuarios: [Usuario]!
}
If I define this query that instead of returning {Users} , I destruct it and hide the password in this way
{ ...Users, password: null }
That's when all the questions come in.
The fact that I Usuario
have defined in the type password: String!
makes the backend, when it wants to return the user created with the password to null, throw me an error saying that it cannot return null from a non-nullable property.
So, what is the correct way to say that a variable must be of a strict type, but at the same time be able to ''nullify'' it in case it is sensitive data?
On the other hand I don't quite understand the difference between returning [User], [User!], [User]! or [User!]!
From already thank you very much