Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // code...
- export const userTypeDefs = `
- type User {
- id: ID!
- # Notice we have 2 new fields, "workspaceId" and "workspace"
- # The workspaceId will be the id of the item and workspace will be the actual populated workspace object
- workspaceId: String
- workspace: Workspace
- email: String!
- password: String!
- firstName: String!
- lastName: String
- }
- // code...
- `;
- // code...
- export const userResolvers = {
- Query: {
- // Query resolvers...
- },
- Mutation: {
- // Mutation resolvers...
- },
- User: {
- async workspace(user: { workspaceId: string }) {
- if (user.workspaceId) {
- const workspace: any = await Workspace.findById(user.workspaceId);
- return workspace.toGraph();
- }
- return null;
- },
- },
- };
Add Comment
Please, Sign In to add comment