Skip to content

feat: extend authuser 2#8683

Open
mikeallisonJS wants to merge 9 commits intomainfrom
00-00-MA-feat-extend-authuser-2
Open

feat: extend authuser 2#8683
mikeallisonJS wants to merge 9 commits intomainfrom
00-00-MA-feat-extend-authuser-2

Conversation

@mikeallisonJS
Copy link
Collaborator

@mikeallisonJS mikeallisonJS commented Feb 4, 2026

Summary by CodeRabbit

  • New Features
    • Added a new AuthenticatedUser type to the GraphQL API, providing access to core user information including ID, name, email, profile image, and verification status.

mikeallisonJS and others added 4 commits February 3, 2026 22:26
- Introduced the AuthenticatedUser type in both API schemas, enhancing user data representation.
- Implemented a resolver for AuthenticatedUser to handle user retrieval and fallback for missing first names.
- Updated user object exports to include AuthenticatedUser for better federation support.
- Added the AuthenticatedUser type to the API schemas, including fields for user details.
- Extended the AuthenticatedUser type to support federation with external services.
- Updated generated TypeScript definitions to reflect the new structure of AuthenticatedUser.
- Modified user-related GraphQL operations to incorporate the new AuthenticatedUser type.
- Updated the AuthenticatedUser type in the API schemas to include federation capabilities with the API_JOURNEYS_MODERN graph.
- Introduced a new external reference for AuthenticatedUser in the user schema to facilitate integration.
- Modified TypeScript exports to include the new AuthenticatedUser reference for improved type handling.
@mikeallisonJS mikeallisonJS requested a review from csiyang February 4, 2026 01:06
@mikeallisonJS mikeallisonJS self-assigned this Feb 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Walkthrough

This PR introduces a new AuthenticatedUser GraphQL type across the federated API gateway and subgraphs. The type is defined in the api-users subgraph with fields for id, firstName, lastName, email, imageUrl, superAdmin, and emailVerified. Federation extensions are added to api-journeys and api-journeys-modern to reference this type, and corresponding TypeScript implementations and exports are added to support the federation pattern.

Changes

Cohort / File(s) Summary
GraphQL Schema Definitions
apis/api-gateway/schema.graphql, apis/api-users/schema.graphql, apis/api-journeys-modern/schema.graphql, apis/api-journeys/schema.graphql, apis/api-journeys/src/app/modules/userTeam/userTeam.graphql
Added new AuthenticatedUser type to gateway and api-users schemas with federation key on id; extensions added to api-journeys and api-journeys-modern for federation support. Updated _Entity union in api-journeys to include AuthenticatedUser.
User Schema Implementation
apis/api-users/src/schema/user/objects/user.ts, apis/api-users/src/schema/user/objects/index.ts, apis/api-users/src/schema/user/user.ts
Implemented AuthenticatedUser Prisma object variant with custom field resolvers including firstName fallback and email fallback logic; added entity resolution with id-based lookup; updated module exports to include AuthenticatedUser.
Federation Type References
apis/api-journeys-modern/src/schema/user/user.ts, apis/api-journeys-modern/src/schema/user/index.ts
Added AuthenticatedUserRef federated type reference with id selector for external type extension; updated module exports to include AuthenticatedUserRef.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • tanflem
  • tataihono
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: extend authuser 2' is vague and lacks specificity about what is being extended or why. While it references 'authuser', it provides minimal insight into the actual changes (adding AuthenticatedUser type across multiple federated services). Consider a more descriptive title such as 'feat: add AuthenticatedUser federated type' or 'feat: introduce AuthenticatedUser across API services' to better convey the scope and purpose of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 00-00-MA-feat-extend-authuser-2

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Feb 4, 2026

View your CI Pipeline Execution ↗ for commit 1125224

Command Status Duration Result
nx run watch-e2e:e2e ✅ Succeeded 24s View ↗
nx run resources-e2e:e2e ✅ Succeeded 22s View ↗
nx run journeys-admin-e2e:e2e ✅ Succeeded 31s View ↗
nx run short-links-e2e:e2e ✅ Succeeded 6s View ↗
nx run journeys-e2e:e2e ✅ Succeeded 20s View ↗
nx run player-e2e:e2e ✅ Succeeded 3s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 4s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
Additional runs (20) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-02-04 23:13:28 UTC

@github-actions github-actions bot temporarily deployed to Preview - short-links February 4, 2026 01:08 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 4, 2026 01:08 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 4, 2026 01:08 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 4, 2026 01:08 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 4, 2026 01:08 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
short-links ✅ Ready short-links preview Thu Feb 5 12:08:02 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Thu Feb 5 12:07:36 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Thu Feb 5 12:09:08 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Thu Feb 5 12:09:15 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Thu Feb 5 12:10:14 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Thu Feb 5 12:09:12 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Thu Feb 5 12:08:23 NZDT 2026

Copy link
Contributor

@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: 1

🤖 Fix all issues with AI agents
In `@apis/api-users/src/schema/user/user.ts`:
- Around line 49-82: The error log and duplicated resolver should be fixed by
extracting the shared logic into a helper (e.g., resolveUserReference) that
performs prisma.user.findUnique({ where: { userId: id } }), handles missing
user, applies the firstName fallback ('Unknown User') when null/empty, and
catches/logs errors; update the AuthenticatedUser.builder.asEntity
resolveReference to call this helper and change the catch log to mention
"AuthenticatedUser" (or include the entity name) rather than the generic "User",
and replace the duplicated resolveReference in the User entity to reuse the same
helper so both entities share identical behavior.
🧹 Nitpick comments (1)
apis/api-users/src/schema/user/objects/user.ts (1)

29-57: Extract shared firstName resolver to reduce duplication.

The firstName resolver (lines 33-45) is duplicated from the User object (lines 7-19). Consider extracting this into a shared helper function to maintain consistency and reduce maintenance burden.

Additionally, the email field handling differs between User and AuthenticatedUser:

  • User: throws if email is null (via exposeString with nullable: false)
  • AuthenticatedUser: returns empty string via user.email ?? ''

Returning an empty string may mask data integrity issues. Consider using consistent behavior or documenting the intentional difference.

♻️ Proposed refactor to extract shared resolver
 import { builder } from '../../builder'

+const resolveFirstName = (user: { firstName: string | null; userId: string }) => {
+  if (!user.firstName || user.firstName.trim() === '') {
+    console.warn(
+      `User ${user.userId} has invalid firstName: "${user.firstName}", using fallback`
+    )
+    return 'Unknown User'
+  }
+  return user.firstName
+}
+
 export const User = builder.prismaObject('User', {
   name: 'User',
   fields: (t) => ({
     id: t.exposeID('id', { nullable: false }),
     firstName: t.field({
       type: 'String',
       nullable: false,
-      resolve: (user) => {
-        // Additional safeguard for firstName field
-        if (!user.firstName || user.firstName.trim() === '') {
-          console.warn(
-            `User ${user.userId} has invalid firstName: "${user.firstName}", using fallback`
-          )
-          return 'Unknown User'
-        }
-        return user.firstName
-      }
+      resolve: resolveFirstName
     }),

Apply the same change to AuthenticatedUser.

- Deleted the AuthenticatedUser type definition from the GraphQL schema to streamline user data representation.
- This change simplifies the API by removing unnecessary complexity related to user authentication details.
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 4, 2026 20:12 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 4, 2026 20:12 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 4, 2026 20:12 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 4, 2026 20:12 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 4, 2026 20:12 Inactive
- Updated the branch name validation regex to allow for a broader range of naming conventions.
- Added `createdAt` and `updatedAt` fields to various schema test cases to ensure timestamps are included in mock data for consistency across tests.
- This change improves the accuracy of test data and aligns with the current data model requirements.
@github-actions github-actions bot temporarily deployed to Preview - resources February 4, 2026 23:05 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 4, 2026 23:05 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 4, 2026 23:05 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 4, 2026 23:05 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 4, 2026 23:05 Inactive
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