Open ScottAgirs opened 4 years ago
using this in my project:
t.field('currentUser', {
type: 'User',
resolve: async (_, args, ctx) => {
const singleUser = await ctx.photon.users.findOne({
where: { id: '1' },
})
return singleUser
},
})
Hello folks,
Cannot seem to find a fitting example in nexus docs or figure out a way myself to solve this.
The goal is to expose a "currentUser" query to GraphQL API, which would retrieve a single user with
.findOne
by accessing thectx.request.currentUserId
.Current workaround I have is this
which uses t.list.field(), but for obvious reasons this is not ideal, because even though only one user is returned, it is still a list and needs to be destructed on the client.