Anyone working with the auth example where you hav...
# prisma-whats-new
w
Anyone working with the auth example where you have the
me
query? It throws an error when the user ins’t logged in - doesn’t seem the best way to handle this because it breaks my app - what should I do instead?
I’m Working in Apollo on the front end and it seems to break the query when this error is throw. I tried just returning an empty object from the API, but since Id and Email are required, it also throws an error on that…
m
@wesbos I had the same issue so I returned null
Copy code
export const user = (parent, args, ctx: Context, info) => {
  const Authorization = ctx.request.get('Authorization')
  if (!Authorization || Authorization==="null") {
    console.log('Authorization is null')
    return null
  } 
  const id = getUserId(ctx)
  return ctx.db.query.user({ where: { id } }, info)
}
w
@max thanks - but how did you handle the user needing to have an ID?
m
@wesbos I dont follow. What's the scenario? I returned null and the graphql-yoga server seems to accept it
w
hm - let me try that - 1 second
m
I think the graphcool framework servers returned null as well
let me know if it works
w
😗 That worked! My problem was that I was getting the user ID first and then that would throw an error. Thank you!
@max
m
@wesbos awesome - glad to hear it 🙂