So I have this simple schema:
type User {
_id: String,
username: String,
age: Int,
email: String,
password: String,
}
type Query {
user(_id: String!): User,
}
Resolver:
import User from './User';
export default {
Query: {
user: (_, { _id }) => User.findById(_id),
},
}
how can I get a user by some specified fields like username, email without creating a query function for each one (if the user would have 1000 unique fields it would be pretty painful to create 1000 queries for each type) ?