Closed blitss closed 5 years ago
Sure, checkout @Context
argument decorator:
https://prismake.github.io/typegql/explore/inject/
If you need more fine control, use raw @Inject
decorator, also described in link above.
import { ObjectType, Field, Context } from 'typegql';
@ObjectType()
class Viewer {
@Field({ type: () => Person })
me(@Context context) {
return db.findUserById(context.currentUser.id);
}
@Field() id: number;
}
As well as I know, I can only get the context in
@Before
decorator. How can I do something like this?It might be useful to specify things that belong to the authenticated user (in the database query, where clause) or get user itself, like
me{}
.