-
Notifications
You must be signed in to change notification settings - Fork 14
feat: handle google stale oauth #8617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Added mutation for updating Google integration settings, including handling OAuth redirects and displaying success/error notifications. Enhanced UI with a reconnect button and improved state management for loading and error handling.
…ect functionality Added `oauthStale` field to the GraphQL schema and updated related components to manage OAuth token expiration. Implemented reconnect URL in email templates and service logic, along with UI alerts for stale OAuth status in the integration details view. Updated mocks and types to reflect these changes.
WalkthroughThis PR introduces Google OAuth staleness detection and reconnection workflow across multiple layers. It adds an Changes
Sequence DiagramsequenceDiagram
participant Client as Client (Admin UI)
participant Backend as Backend (Google Auth)
participant Database as Database
participant EmailWorker as Email Worker
participant User as User (Email)
Backend->>Backend: Token refresh fails
Backend->>Database: Mark integration.oauthStale = true
Backend->>Backend: handleStaleOAuth()
Backend->>Backend: Queue google-reconnect email job
EmailWorker->>Database: Fetch user by ID
EmailWorker->>Database: Check email preferences (accountNotifications, unsubscribeAll)
EmailWorker->>Backend: Build reconnect URL (teamId, integrationId)
EmailWorker->>EmailWorker: Render GoogleReconnectEmail template (HTML + plain text)
EmailWorker->>User: Send reconnection email
Client->>Database: Query integration (fetch oauthStale)
Client->>Client: Display stale OAuth warning alert
Client->>Client: Show "Reconnect with Google" button
User->>Client: Click Reconnect button
Client->>Backend: INTEGRATION_GOOGLE_UPDATE mutation
Backend->>Database: Update integration with new OAuth token
Backend->>Database: Mark integration.oauthStale = false
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
|
View your CI Pipeline Execution ↗ for commit f829bf0
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit a2ee020
☁️ Nx Cloud last updated this comment at |
This comment has been minimized.
This comment has been minimized.
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
Enhanced Google integration tests by including the teamId field in mock data and added oauthStale field to the integration update mutation. Updated related components to reflect these changes, ensuring better handling of OAuth token states and integration details.
There was a problem hiding this 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-gateway/schema.graphql`:
- Around line 1769-1771: The gateway schema declares the oauthStale field with
`@join__field`(graph: API_JOURNEYS) and `@join__field`(graph: API_JOURNEYS_MODERN)
which will route queries to the legacy subgraph incorrectly; update the
oauthStale field declaration so it is routed to the modern subgraph only by
keeping the `@join__field`(graph: API_JOURNEYS_MODERN) and add `@override`(from:
"api-journeys") to indicate the modern subgraph owns the field (locate the
oauthStale field declaration in the schema and replace the dual join__field
directives with the single modern join__field plus the `@override`(from:
"api-journeys") directive).
| accountEmail: String | ||
| oauthStale: Boolean! @join__field(graph: API_JOURNEYS) @join__field(graph: API_JOURNEYS_MODERN) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for oauthStale in legacy and modern schemas
echo "=== Searching in api-journeys schema ==="
rg -n "oauthStale" apis/api-journeys/schema.graphql
echo ""
echo "=== Searching in api-journeys-modern schema ==="
rg -n "oauthStale" apis/api-journeys-modern/schema.graphql
echo ""
echo "=== Searching in api-journeys resolvers ==="
fd -e ts -e js . apis/api-journeys --type f | head -20 | xargs -I {} rg -l "oauthStale" {}
echo ""
echo "=== Searching in api-journeys-modern resolvers ==="
fd -e ts -e js . apis/api-journeys-modern --type f | head -20 | xargs -I {} rg -l "oauthStale" {}Repository: JesusFilm/core
Length of output: 425
🏁 Script executed:
#!/bin/bash
# Get context around oauthStale in modern schema
echo "=== Context around oauthStale in api-journeys-modern ==="
sed -n '695,705p' apis/api-journeys-modern/schema.graphql
echo ""
echo "=== Check if this is in a type that appears in both schemas ==="
sed -n '690,705p' apis/api-journeys-modern/schema.graphql
echo ""
echo "=== Look for override directive examples in gateway schema ==="
rg -n "@override" apis/api-gateway/schema.graphql | head -10
echo ""
echo "=== Check what type oauthStale is part of in gateway ==="
sed -n '1760,1775p' apis/api-gateway/schema.graphqlRepository: JesusFilm/core
Length of output: 1486
Add @override directive to route oauthStale to the modern subgraph.
The oauthStale field exists only in api-journeys-modern but is declared in the gateway with @join__field(graph: API_JOURNEYS) @join__field(graph: API_JOURNEYS_MODERN). This will cause supergraph composition or runtime failures when querying the field through the legacy subgraph. Route it to the modern service using:
oauthStale: Boolean! `@join__field`(graph: API_JOURNEYS_MODERN) `@override`(from: "api-journeys")🤖 Prompt for AI Agents
In `@apis/api-gateway/schema.graphql` around lines 1769 - 1771, The gateway schema
declares the oauthStale field with `@join__field`(graph: API_JOURNEYS) and
`@join__field`(graph: API_JOURNEYS_MODERN) which will route queries to the legacy
subgraph incorrectly; update the oauthStale field declaration so it is routed to
the modern subgraph only by keeping the `@join__field`(graph: API_JOURNEYS_MODERN)
and add `@override`(from: "api-journeys") to indicate the modern subgraph owns the
field (locate the oauthStale field declaration in the schema and replace the
dual join__field directives with the single modern join__field plus the
`@override`(from: "api-journeys") directive).
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.