Nelson Pecora
08/14/2019, 8:55 PMnexus, where should I put business logic that I want to run when fetching/saving types? i.e. not just field resolvers, but whole typesNelson Pecora
08/14/2019, 8:56 PMupdateTag mutation, but in any mutation where Tags might be saved (e.g. through nested/related updates: updateArticle with { tags: { create: { some tag data }})Nelson Pecora
08/14/2019, 8:58 PMget and patch functions, which are called in mutations, queries, and other types’ get and patch functionsNelson Pecora
08/14/2019, 8:59 PMupdateArticle calls Article.patch() which calls Tag.patch() (checking user auth for tags) and then the returned Article object is sent to photon.articles.update()Nelson Pecora
08/14/2019, 9:00 PMnexus-y way to do similar stuff? middleware? stuff in the definition() method?Nelson Pecora
08/14/2019, 9:24 PMconst MyNode = objectType({
definition(t) {
t.string('foo', () => 'result')
},
resolve(o) {
// business logic
return photon.mynodes.findOne(o.id)
}
}Nelson Pecora
08/14/2019, 9:29 PMt.field() accepts an authorize property, but that would mean I’d have to do all auth and full type resolvers at the edgesNelson Pecora
08/14/2019, 9:30 PM