Skip to content

Conversation

rdonigian
Copy link
Contributor

Added a new GraphQL resolver field primaryOrganization to the User type that returns the user's primary organization as a Partner object.

Fixed a bug in the organization assignment logic where setting a new primary organization wouldn't properly override the existing one.

Updated the assignOrganizationToUser mutation to use readOnePartnerByOrgId and return the related Partner.

Updated the removeOrganizationFromUser mutation to use readOnePartnerByOrgId and return the related Partner.

@rdonigian rdonigian requested a review from CarsonF as a code owner July 17, 2025 20:31
@rdonigian rdonigian changed the title Org user assignment User Organization Clean up Jul 17, 2025
Copy link

coderabbitai bot commented Jul 17, 2025

📝 Walkthrough

Walkthrough

The changes update the process of assigning and removing organizations from users by renaming input properties, restructuring output types to include partner details, and adding new methods to retrieve a user's primary organization. The resolver and service layers are enhanced to support these updates, including new dependencies and resolve fields.

Changes

Files/Paths Change Summary
User DTOs
src/components/user/dto/assign-organization-to-user.dto.ts,
src/components/user/dto/remove-organization-from-user.dto.ts
Renamed input property request to assignment; output classes now include a partner field of type Partner instead of extending MutationPlaceholderOutput.
User Repository
src/components/user/user.repository.ts
Updated Cypher query alias in assignOrganizationToUser; added getPrimaryOrganizationId method to fetch a user's primary organization ID.
User Service
src/components/user/user.service.ts
Added getPrimaryOrganizationId method to retrieve a user's primary organization ID from the repository.
User Resolver
src/components/user/user.resolver.ts
Injected PartnerService; added primaryOrganization resolve field; updated mutations to return Partner entity and use assignment property.
User GEL Repository
src/components/user/user.gel.repository.ts
Added getPrimaryOrganizationId method throwing NotImplementedException.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch org-user-assignment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jul 17, 2025

🗞 GraphQL Summary

View schema changes
@@ -28,13 +28,13 @@
   userId: ID!
 }
 
 input AssignOrganizationToUserInput {
-  request: AssignOrganizationToUser!
+  assignment: AssignOrganizationToUser!
 }
 
 type AssignOrganizationToUserOutput {
-  success: Boolean! @deprecated(reason: "This operation will not return if there is a failure.\nCheck the errors instead of using this field.\nIf you need to reference a field in the output use `__typename` instead.\nThis field will go away at any point in time without warning.")
+  partner: Partner!
 }
 
 type Audio implements Media & TemporalMedia {
   """
@@ -5454,13 +5454,13 @@
   userId: ID!
 }
 
 input RemoveOrganizationFromUserInput {
-  request: RemoveOrganizationFromUser!
+  assignment: RemoveOrganizationFromUser!
 }
 
 type RemoveOrganizationFromUserOutput {
-  success: Boolean! @deprecated(reason: "This operation will not return if there is a failure.\nCheck the errors instead of using this field.\nIf you need to reference a field in the output use `__typename` instead.\nThis field will go away at any point in time without warning.")
+  partner: Partner!
 }
 
 input RenameFileInput {
   """The file node's ID"""
@@ -8014,8 +8014,9 @@
   phone: SecuredStringNullable!
 
   """Does the requesting user have this pinned?"""
   pinned: Boolean!
+  primaryOrganization: Partner
   projects(input: ProjectListInput = {count: 25, order: ASC, page: 1, sort: "name"}): SecuredProjectList!
   realFirstName: SecuredString!
   realLastName: SecuredString!
   roles: SecuredRoles!

🚨 Breaking Changes

  • A required field assignment on input type AssignOrganizationToUserInput was added.
  • AssignOrganizationToUserInput.request was removed.
  • AssignOrganizationToUserOutput.success was removed.
  • A required field assignment on input type RemoveOrganizationFromUserInput was added.
  • RemoveOrganizationFromUserInput.request was removed.
  • RemoveOrganizationFromUserOutput.success was removed.

@rdonigian rdonigian force-pushed the org-user-assignment branch from f4bc19a to 41532b3 Compare July 28, 2025 13:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/user/user.gel.repository.ts (1)

88-90: LGTM! Placeholder method maintains interface consistency.

The addition of getPrimaryOrganizationId correctly maintains interface consistency with UserRepository by implementing the PublicOf<UserRepository> contract. The NotImplementedException with userId context is appropriate for the GEL repository placeholder implementation.

Consider adding a TODO comment to track that this functionality needs implementation:

+  // TODO: Implement getPrimaryOrganizationId for GEL repository
   getPrimaryOrganizationId(userId: ID): Promise<ID | null> {
     throw new NotImplementedException().with({ userId });
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4bc19a and 41532b3.

📒 Files selected for processing (6)
  • src/components/user/dto/assign-organization-to-user.dto.ts (2 hunks)
  • src/components/user/dto/remove-organization-from-user.dto.ts (2 hunks)
  • src/components/user/user.gel.repository.ts (1 hunks)
  • src/components/user/user.repository.ts (2 hunks)
  • src/components/user/user.resolver.ts (5 hunks)
  • src/components/user/user.service.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/components/user/user.resolver.ts
  • src/components/user/user.service.ts
  • src/components/user/dto/assign-organization-to-user.dto.ts
  • src/components/user/dto/remove-organization-from-user.dto.ts
  • src/components/user/user.repository.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CarsonF
PR: SeedCompany/cord-api-v3#3377
File: src/components/partner/partner.repository.ts:184-191
Timestamp: 2025-04-03T15:07:44.087Z
Learning: In the Partner repository, when updating a departmentIdBlock, null is intentionally passed to departmentIdBlockUtils.set() to clear the current value. The condition should remain departmentIdBlock !== undefined to allow null to be passed through.
🧬 Code Graph Analysis (1)
src/components/user/user.gel.repository.ts (1)
src/common/id-field.ts (1)
  • ID (24-25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant