Skip to content
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

chore: Move more integration GraphQL types to SDL #10015

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

Dschoordsch
Copy link
Contributor

@Dschoordsch Dschoordsch commented Jul 23, 2024

There were some type resolver issues caused by #10000 and converting more types to SDL was the easiest way to fix the issues caused by not being able to resolve some interface types.

Description

Fixes/Partially Fixes #[issue number]
[Please include a summary of the changes and the related issue]

Demo

[If possible, please include a screenshot or gif/video, it'll make it easier for reviewers to understand the scope of the changes and how the change is supposed to work. If you're introducing something new or changing the existing patterns, please share a Loom and explain what decisions you've made and under what circumstances]

Testing scenarios

[Please list all the testing scenarios a reviewer has to check before approving the PR]

  • Scenario A

    • Step 1
    • Step 2...
  • Scenario B

    • Step 1
    • Step 2....

Final checklist

  • I checked the code review guidelines
  • I have added Metrics Representative as reviewer(s) if my PR invovles metrics/data/analytics related changes
  • I have performed a self-review of my code, the same way I'd do it for any other team member
  • I have tested all cases I listed in the testing scenarios and I haven't found any issues or regressions
  • Whenever I took a non-obvious choice I added a comment explaining why I did it this way
  • I added the label Skip Maintainer Review Indicating the PR only requires reviewer review and can be merged right after it's approved if the PR introduces only minor changes, does not contain any architectural changes or does not introduce any new patterns and I think one review is sufficient'
  • PR title is human readable and could be used in changelog

Summary by CodeRabbit

  • New Features

    • Introduced new GraphQL mutations for adding and removing team member integration authentications.
    • Added new type definitions for handling Jira projects and various authentication methods.
    • Enhanced the API to manage OAuth1 and OAuth2 tokens effectively, along with webhook-based authorisations.
    • Improved the handling of project avatars in the UI, allowing for greater flexibility with missing avatar data.
  • Bug Fixes

    • Corrected path references for existing entries in the integration authentication framework.
  • Documentation

    • Updated type definitions and interfaces to reflect new functionalities related to team member integration and authentication.

There were some type resolver issues caused by #10000 and converting
more types to SDL was the easiest way to fix the issues caused by not
being able to resolve some interface types.
Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

The recent changes enhance the application by introducing new GraphQL mutations for managing team member integration authentication, specifically for adding and removing integrations. This includes updated type definitions for both Jira projects and the handling of integration credentials. The modifications streamline the authentication process and improve the GraphQL API's overall structure, facilitating better integration with various services and ensuring greater type safety.

Changes

Files Change Summary
packages/server/graphql/public/mutations/addTeamMemberIntegrationAuth.ts
packages/server/graphql/public/mutations/removeTeamMemberIntegrationAuth.ts
New GraphQL mutation resolvers for adding and removing team member integration authentication, supporting OAuth1 and OAuth2 strategies.
packages/server/graphql/public/typeDefs/JiraRemoteProject.graphql
packages/server/graphql/public/typeDefs/JiraServerRemoteProject.graphql
packages/server/graphql/public/typeDefs/RepoIntegration.graphql
New GraphQL type definitions for Jira projects and a RepoIntegration interface for repository management, enhancing the schema for querying projects.
packages/server/graphql/public/typeDefs/TeamMemberIntegrationAuth.graphql
packages/server/graphql/public/typeDefs/TeamMemberIntegrationAuthOAuth1.graphql
packages/server/graphql/public/typeDefs/TeamMemberIntegrationAuthOAuth2.graphql
New structures for managing team member authentication credentials and OAuth tokens within the GraphQL schema.
packages/server/graphql/public/typeDefs/addTeamMemberIntegrationAuth.graphql
packages/server/graphql/public/typeDefs/removeTeamMemberIntegrationAuth.graphql
Extensions for mutations related to adding and removing team member integration authentication, including success and error payload types.
packages/server/graphql/public/types/* (various files) New TypeScript resolver implementations for handling success responses for both adding and removing integration authentication.
packages/server/graphql/rootMutation.ts Removal of old mutation imports related to team member integration authentication, indicating a shift in functionality.
packages/client/components/JiraScopingSearchFilterMenu.tsx Updated Project type to allow avatar property to be null, improving type safety and handling of avatar data in the UI.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a1f483c and 6665ddb.

Files selected for processing (1)
  • packages/client/components/JiraScopingSearchFilterMenu.tsx (2 hunks)
Additional comments not posted (2)
packages/client/components/JiraScopingSearchFilterMenu.tsx (2)

54-54: LGTM!

The change to allow avatar to be null improves type safety.


160-160: LGTM!

Using the nullish coalescing operator ensures that undefined is passed instead of null to the src prop of the img element.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

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: 4

Outside diff range, codebase verification and nitpick comments (10)
packages/server/graphql/public/mutations/removeTeamMemberIntegrationAuth.ts (3)

1-6: Consider consolidating imports for better readability.

Grouping similar imports together can enhance readability and maintainability.

import {IntegrationProviderServiceEnum} from '../../../postgres/queries/generated/removeTeamMemberIntegrationAuthQuery'
import removeTeamMemberIntegrationAuthQuery from '../../../postgres/queries/removeTeamMemberIntegrationAuth'
import {analytics} from '../../../utils/analytics/analytics'
import {getUserId, isTeamMember} from '../../../utils/authorization'
import standardError from '../../../utils/standardError'
import updateRepoIntegrationsCacheByPerms from '../../queries/helpers/updateRepoIntegrationsCacheByPerms'

15-16: Enhance error message for clarity.

The error message could be more descriptive to help with debugging and user feedback.

- return standardError(new Error('permission denied; must be team member'))
+ return standardError(new Error('Permission denied: User must be a team member to remove integration authentication.'))

30-31: Consider returning more detailed data.

Returning more detailed data can be beneficial for debugging and client-side handling.

const data = {userId: viewerId, teamId, service}
return data
packages/server/graphql/public/mutations/addTeamMemberIntegrationAuth.ts (5)

1-13: Consider consolidating imports for better readability.

Grouping similar imports together can enhance readability and maintainability.

import IntegrationProviderId from '~/shared/gqlIds/IntegrationProviderId'
import GcalOAuth2Manager from '../../../integrations/gcal/GcalOAuth2Manager'
import GitLabOAuth2Manager from '../../../integrations/gitlab/GitLabOAuth2Manager'
import JiraServerOAuth1Manager, {OAuth1Auth} from '../../../integrations/jiraServer/JiraServerOAuth1Manager'
import {IntegrationProviderAzureDevOps} from '../../../postgres/queries/getIntegrationProvidersByIds'
import upsertTeamMemberIntegrationAuth from '../../../postgres/queries/upsertTeamMemberIntegrationAuth'
import AzureDevOpsServerManager from '../../../utils/AzureDevOpsServerManager'
import {analytics} from '../../../utils/analytics/analytics'
import {getUserId, isTeamMember} from '../../../utils/authorization'
import standardError from '../../../utils/standardError'
import updateRepoIntegrationsCacheByPerms from '../../queries/helpers/updateRepoIntegrationsCacheByPerms'
import {MutationResolvers} from '../resolverTypes'

32-34: Enhance error message for clarity.

The error message could be more descriptive to help with debugging and user feedback.

- return standardError(new Error('Attempted teamId spoof'), {userId: viewerId})
+ return standardError(new Error('Permission denied: User is not a team member of the specified team.'), {userId: viewerId})

41-47: Ensure proper error handling for missing integration provider.

Consider adding more context to the error message for better debugging.

return standardError(
  new Error(`Unable to find appropriate integration provider for providerId ${providerId}`),
  {
    userId: viewerId,
    providerId
  }
)

127-131: Ensure proper error handling for token metadata.

Consider adding more context to the error message for better debugging.

return standardError(tokenMetadata, {
  userId: viewerId,
  providerId
})

145-146: Consider returning more detailed data.

Returning more detailed data can be beneficial for debugging and client-side handling.

const data = {userId: viewerId, teamId, service}
return data
codegen.json (2)

126-126: The path for RemoveTeamMemberIntegrationAuthSuccess is incorrect.

The correct path should be ./types/RemoveTeamMemberIntegrationAuthSuccess#RemoveTeamMemberIntegrationAuthSuccessSource.

  • Current path: ./types/RemoveTeamMemberIntegrationAuthPayload#RemoveTeamMemberIntegrationAuthSuccessSource
  • Correct path: ./types/RemoveTeamMemberIntegrationAuthSuccess#RemoveTeamMemberIntegrationAuthSuccessSource

Please update the configuration accordingly.

Analysis chain

Verify the path and type mapping for RemoveTeamMemberIntegrationAuthSuccess.

Ensure that the path and type mapping are correct and the type exists at the specified path.


Verify the path and type mapping for RemoveTeamMemberIntegrationAuthSuccess.

Ensure that the file RemoveTeamMemberIntegrationAuthPayload.ts exists and contains the type definition RemoveTeamMemberIntegrationAuthSuccessSource.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the path and type mapping for `RemoveTeamMemberIntegrationAuthSuccess`.

# Test: Search for the type definition. Expect: Correct path and type definition.
rg --type ts 'RemoveTeamMemberIntegrationAuthSuccessSource' ./types/RemoveTeamMemberIntegrationAuthPayload.ts

Length of output: 199


Script:

#!/bin/bash
# Description: Verify the path and type mapping for `RemoveTeamMemberIntegrationAuthSuccess`.

# Search for the file `RemoveTeamMemberIntegrationAuthPayload.ts` in the repository
fd 'RemoveTeamMemberIntegrationAuthPayload.ts'

# Search for the type definition `RemoveTeamMemberIntegrationAuthSuccessSource` across the repository
rg 'RemoveTeamMemberIntegrationAuthSuccessSource' --type ts

Length of output: 246


67-67: Incorrect path for AddTeamMemberIntegrationAuthSuccess type mapping.

The path specified for AddTeamMemberIntegrationAuthSuccess is incorrect. It should be updated to packages/server/graphql/public/types/AddTeamMemberIntegrationAuthSuccess.ts#AddTeamMemberIntegrationAuthSuccessSource.

  • Current path: ./types/AddTeamMemberIntegrationAuthPayload#AddTeamMemberIntegrationAuthSuccessSource
  • Correct path: packages/server/graphql/public/types/AddTeamMemberIntegrationAuthSuccess.ts#AddTeamMemberIntegrationAuthSuccessSource
Analysis chain

Verify the path and type mapping for AddTeamMemberIntegrationAuthSuccess.

Ensure that the path and type mapping are correct and the type exists at the specified path.


Verify the existence and correct path of AddTeamMemberIntegrationAuthPayload.ts and the type AddTeamMemberIntegrationAuthSuccessSource.

Ensure that the file and type exist in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the path and type mapping for `AddTeamMemberIntegrationAuthSuccess`.

# Test: Search for the type definition. Expect: Correct path and type definition.
rg --type ts 'AddTeamMemberIntegrationAuthSuccessSource' ./types/AddTeamMemberIntegrationAuthPayload.ts

Length of output: 190


Script:

#!/bin/bash
# Description: Verify the existence and correct path of `AddTeamMemberIntegrationAuthPayload.ts` and the type `AddTeamMemberIntegrationAuthSuccessSource`.

# Search for the file `AddTeamMemberIntegrationAuthPayload.ts` in the entire codebase.
fd AddTeamMemberIntegrationAuthPayload.ts

# Search for the type definition `AddTeamMemberIntegrationAuthSuccessSource` in the entire codebase.
rg 'AddTeamMemberIntegrationAuthSuccessSource'

Length of output: 375

Copy link
Contributor

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR will be delayed and might be rejected due to its size.

@Dschoordsch Dschoordsch mentioned this pull request Jul 23, 2024
24 tasks
@Dschoordsch Dschoordsch merged commit 1279971 into master Jul 23, 2024
7 checks passed
@Dschoordsch Dschoordsch deleted the chore/convertMoreIntegrationsToSDL branch July 23, 2024 15:56
@github-actions github-actions bot mentioned this pull request Jul 23, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant