GraphQL: Require at least one argument in a query
I think the easiest way using resolve function. But why do you think it will be messy?
try {
if(!args.id && !args.email) {
throw new Error('Specify id or email');
}
...
} catch(e) {
return Promise.reject(e);
}
If you want a schema that enforces one and only one of the two, you could add an enum argument to qualify a single string argument. The schema might look like this in graphql:
type query {
getUser(
lookup: String!
lookupType: UserLookupType!
): User
}
enum UserLookupType {
ID
EMAIL
}