Guest User

Untitled

a guest
Sep 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // code...
  2.  
  3. export const userTypeDefs = `
  4.  
  5. type User {
  6. id: ID!
  7. # Notice we have 2 new fields, "workspaceId" and "workspace"
  8. # The workspaceId will be the id of the item and workspace will be the actual populated workspace object
  9. workspaceId: String
  10. workspace: Workspace
  11. email: String!
  12. password: String!
  13. firstName: String!
  14. lastName: String
  15. }
  16.  
  17. // code...
  18.  
  19. `;
  20.  
  21. // code...
  22.  
  23. export const userResolvers = {
  24. Query: {
  25. // Query resolvers...
  26. },
  27. Mutation: {
  28. // Mutation resolvers...
  29. },
  30. User: {
  31. async workspace(user: { workspaceId: string }) {
  32. if (user.workspaceId) {
  33. const workspace: any = await Workspace.findById(user.workspaceId);
  34. return workspace.toGraph();
  35. }
  36. return null;
  37. },
  38. },
  39. };
Add Comment
Please, Sign In to add comment