@tgriesser is implementing a field-level authorize method in the main nexus repo. Is there a way we could include something similar in t.prismaFields @Weakky?
Something like this:
export const User = prismaObjectType({
name: 'User',
definition(t) {
t.prismaFields([{
name: 'posts',
authorize: ()=>{ return true } // auth logic here
}])
},
})
It would be great to have something similar indeed. We'd definitely need to find a way to pass the resolver context into the authorize function though!
We'll look into that once the authorize feature lands on nexus 馃憤
@Weakky actually wouldn't this work?
export const User = prismaObjectType({
name: 'User',
definition(t) {
t.field("posts", {
...t.prismaType.posts,
authorize: ()=>{ return true } // auth logic here
})
},
})
I assume the second argument to t.field gets passed straight through to the underlying nexus library?
PS Thanks for the updates to the README, so much better.
Oh, indeed, that should work, that's the whole point of t.prismaType actually, to be able to mix both nexus-prisma and nexus!
I guess we could probably provide some integration, but for now that should do the work.
Sorry for the poor README so far, more docs are coming as it's only gonna be officially released tonight 馃檹
Great!! Closing 馃憤
And I've been counting the days since the last blog post :) It was a long week.
Yep, that'll work assuming you have the nexus@alpha installed as the peer dependency, still might change around things around it (mainly to add new/better features), so you'll need to keep up with the latest in https://github.com/prisma/nexus/pull/23 and https://github.com/prisma/nexus/pull/32. If you're using TypeScript though, at least the types will keep you informed if the API changes at all!
Most helpful comment
Great!! Closing 馃憤
And I've been counting the days since the last blog post :) It was a long week.