Implement fallback User.email resolver

This commit is contained in:
Robert Schäfer 2019-07-14 11:57:38 +02:00
parent 46589362fa
commit dacc3bb557

View File

@ -104,6 +104,14 @@ export default {
},
},
User: {
email: async (parent, params, context, resolveInfo) => {
if (typeof parent.email !== 'undefined') return parent.email
const { id } = parent
const statement = `MATCH(u:User {id: {id}})-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e`
const result = await instance.cypher(statement, { id })
let [{email}]= result.records.map(r => r.get('e').properties)
return email
},
...undefinedToNull([
'actorId',
'avatar',