-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
Refactor: Replace Query with Correct Query to Fetch All and Joined Organizations #3795
base: develop-postgres
Are you sure you want to change the base?
Refactor: Replace Query with Correct Query to Fetch All and Joined Organizations #3795
Conversation
Warning Rate limit exceeded@gkbishnoi07 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughThe changes update several GraphQL queries and associated component logic for handling organization data. The primary update replaces the old queries with new ones: the Changes
Sequence Diagram(s)sequenceDiagram
participant UI as UI Component
participant AC as Apollo Client
participant GS as GraphQL Server
UI->>AC: Request ORGANIZATION_LIST data
AC->>GS: Send updated ORGANIZATION_LIST query (new fields & pagination)
GS-->>AC: Return organization data with id, name, addressLine1, description, avatarURL, paginated members
AC-->>UI: Deliver data for rendering
UI->>AC: Request USER_JOINED_ORGANIZATIONS_PG (with required 'first')
AC->>GS: Query user membership details with pagination
GS-->>AC: Return paginated user organization data
AC-->>UI: Update UI with membership info
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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
🔭 Outside diff range comments (3)
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx (1)
109-118
:⚠️ Potential issueAdd error handling to withdrawMembershipRequest function.
The function is missing error handling for the case where
membershipRequest
is undefined. This could happen if the user's membership request is not found in the array.async function withdrawMembershipRequest(): Promise<void> { const membershipRequest = props.membershipRequests.find( (request) => request.user._id === userId, ); + if (!membershipRequest) { + toast.error(t('MembershipRequestNotFound') as string); + return; + } + await cancelMembershipRequest({ variables: { membershipRequestId: membershipRequest?._id, }, }); + toast.success(t('MembershipRequestWithdrawn') as string); }src/screens/UserPortal/Organizations/Organizations.tsx (2)
72-94
:⚠️ Potential issueUpdate InterfaceOrganization to also use consistent field names.
While
InterfaceOrganizationCardProps
has been updated to useid
instead of_id
, theInterfaceOrganization
interface still uses the old field names. This inconsistency could lead to bugs.interface InterfaceOrganization { isJoined: boolean; - _id: string; + id: string; name: string; image: string; description: string; admins: []; members: []; address: { city: string; countryCode: string; line1: string; postalCode: string; state: string; }; membershipRequestStatus: string; userRegistrationRequired: boolean; membershipRequests: { - _id: string; + id: string; user: { - _id: string; + id: string; }; }[]; }
262-285
:⚠️ Potential issueFix field name inconsistencies in organization mapping.
The mapping function is still referencing
_id
fields, but the new GraphQL schema usesid
. This mismatch will cause the membership status check to fail. Additionally, the type annotation also needs to be updated.- (organization: { members: { _id: string; }[]; membershipRequests: { _id: string; user: { _id: string; }; }[]; }) => { + (organization: { members: { id: string; }[]; membershipRequests: { id: string; user: { id: string; }; }[]; }) => { let membershipRequestStatus = ''; if ( Array.isArray(organization.members) && organization.members.some( - (member: { _id: string }) => member._id === userId, + (member: { id: string }) => member.id === userId, ) ) membershipRequestStatus = 'accepted'; else if ( organization.membershipRequests?.some( - (request: { _id: string; user: { _id: string } }) => - request.user._id === userId, + (request: { id: string; user: { id: string } }) => + request.user.id === userId, ) ) membershipRequestStatus = 'pending';🧰 Tools
🪛 ESLint
[error] 262-262: Replace
·members:·{·_id:·string;·}[];·membershipRequests:·{·_id:·string;·user:·{·_id:·string;·};·}[];
with⏎············members:·{·_id:·string·}[];⏎············membershipRequests:·{·_id:·string;·user:·{·_id:·string·}·}[];⏎·········
(prettier/prettier)
🧹 Nitpick comments (5)
src/components/OrganizationCard/OrganizationCard.tsx (2)
13-14
: Consolidate duplicate imports.You're importing from 'GraphQl/Queries/Queries' twice which can cause confusion and is flagged by ESLint. Consider merging these imports into a single statement.
-import { ORGANIZATION_LIST } from 'GraphQl/Queries/Queries'; -import { USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries'; +import { ORGANIZATION_LIST, USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries';🧰 Tools
🪛 ESLint
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
70-70
: Consistent formatting for refetchQueries arrays.The refetchQueries arrays have inconsistent formatting, which is flagged by the linter. Consider standardizing the formatting to improve readability.
const [sendMembershipRequest] = useMutation(SEND_MEMBERSHIP_REQUEST, { refetchQueries: [ - { query: ORGANIZATION_LIST, variables: { id } }, + { query: ORGANIZATION_LIST, variables: { id } } ], });Also applies to: 75-75, 80-80
src/GraphQl/Queries/Queries.ts (1)
41-60
: Improve query structure and formatting.The GraphQL query structure has inconsistent indentation and spacing which impacts readability. The organization members query now includes pagination, which is a good practice, but the formatting should be improved.
query { organizations { id - name - addressLine1 - description - avatarURL - members(first: 32) { - edges { - node { - id - } - } - pageInfo { - hasNextPage - } - + name + addressLine1 + description + avatarURL + members(first: 32) { + edges { + node { + id + } + } + pageInfo { + hasNextPage + } } } }🧰 Tools
🪛 ESLint
[error] 44-44: Delete
·
(prettier/prettier)
[error] 45-45: Delete
·
(prettier/prettier)
[error] 46-46: Delete
·
(prettier/prettier)
[error] 47-47: Delete
·
(prettier/prettier)
[error] 48-48: Delete
·
(prettier/prettier)
[error] 49-49: Insert
·
(prettier/prettier)
[error] 50-50: Insert
··
(prettier/prettier)
[error] 51-52: Replace
id···⏎
with·id⏎··
(prettier/prettier)
[error] 53-53: Insert
·
(prettier/prettier)
[error] 56-57: Delete
⏎······
(prettier/prettier)
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx (1)
13-14
: Consolidate duplicate imports.You're importing from 'GraphQl/Queries/Queries' twice which can cause confusion and is flagged by ESLint. Consider merging these imports into a single statement.
-import { ORGANIZATION_LIST } from 'GraphQl/Queries/Queries'; -import { USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries'; +import { ORGANIZATION_LIST, USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries';🧰 Tools
🪛 ESLint
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
src/screens/UserPortal/Organizations/Organizations.tsx (1)
146-146
: Remove debugging console.log statement.There's a console.log statement that was likely added for debugging purposes. This should be removed before merging to production.
- console.log(data);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/GraphQl/Queries/Queries.ts
(1 hunks)src/components/OrganizationCard/OrganizationCard.tsx
(2 hunks)src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
(2 hunks)src/screens/UserPortal/Organizations/Organizations.tsx
(6 hunks)
🧰 Additional context used
🪛 ESLint
src/components/OrganizationCard/OrganizationCard.tsx
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 74-76: Replace ⏎······{·query:·ORGANIZATION_LIST,·variables:·{·id·}·},⏎····
with {·query:·ORGANIZATION_LIST,·variables:·{·id·}·}
(prettier/prettier)
[error] 79-81: Replace ⏎······{·query:·ORGANIZATION_LIST,·variables:·{·id·}·},⏎····
with {·query:·ORGANIZATION_LIST,·variables:·{·id·}·}
(prettier/prettier)
src/GraphQl/Queries/Queries.ts
[error] 44-44: Delete ·
(prettier/prettier)
[error] 45-45: Delete ·
(prettier/prettier)
[error] 46-46: Delete ·
(prettier/prettier)
[error] 47-47: Delete ·
(prettier/prettier)
[error] 48-48: Delete ·
(prettier/prettier)
[error] 49-49: Insert ·
(prettier/prettier)
[error] 50-50: Insert ··
(prettier/prettier)
[error] 51-52: Replace id···⏎
with ·id⏎··
(prettier/prettier)
[error] 53-53: Insert ·
(prettier/prettier)
[error] 56-57: Delete ⏎······
(prettier/prettier)
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 59-61: Replace ⏎······{·query:·ORGANIZATION_LIST,·variables:·{·id:·props.id·}·},⏎····
with {·query:·ORGANIZATION_LIST,·variables:·{·id:·props.id·}·}
(prettier/prettier)
[error] 64-66: Replace ⏎······{·query:·ORGANIZATION_LIST,·variables:·{·id:·props.id·}·},⏎····
with {·query:·ORGANIZATION_LIST,·variables:·{·id:·props.id·}·}
(prettier/prettier)
src/screens/UserPortal/Organizations/Organizations.tsx
[error] 258-259: Delete ⏎···
(prettier/prettier)
[error] 262-262: Replace ·members:·{·_id:·string;·}[];·membershipRequests:·{·_id:·string;·user:·{·_id:·string;·};·}[];
with ⏎············members:·{·_id:·string·}[];⏎············membershipRequests:·{·_id:·string;·user:·{·_id:·string·}·}[];⏎·········
(prettier/prettier)
[error] 474-474: Insert ⏎
(prettier/prettier)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (5)
src/GraphQl/Queries/Queries.ts (1)
63-65
:❓ Verification inconclusive
Verify the updated query parameter requirement.
The
first
parameter inUSER_JOINED_ORGANIZATIONS_PG
has been changed from optional to required (Int!
). This is a breaking change that will affect all components using this query. Ensure that all consumers of this query are updated to provide this parameter.Let's check if all usages of this query in the codebase provide the required
first
parameter:
🏁 Script executed:
#!/bin/bash # Find all files that import and use USER_JOINED_ORGANIZATIONS_PG echo "Searching for files that import USER_JOINED_ORGANIZATIONS_PG..." rg "import.*USER_JOINED_ORGANIZATIONS_PG" --type ts --type tsx echo "\nChecking query usage patterns..." rg "useQuery\(USER_JOINED_ORGANIZATIONS_PG" -A 5 --type ts --type tsxLength of output: 408
Below is an updated review comment that calls out the need to verify the query’s usage—and that manual or re-run verification is required due to the initial script’s file type issues:
Action Required: Verify the updated query parameter usage
The
first
parameter forUSER_JOINED_ORGANIZATIONS_PG
is now required (Int!
), which is a breaking change for all consumers of this query. Since our initial search script failed to process TSX files (due to the “unrecognized file type: tsx” error), please verify (manually or by re-running an updated search) that all call sites—across both TS and TSX files—provide thefirst
parameter when using this query.For additional verification, consider re-running this improved shell script:
#!/bin/bash # Add TSX file type support rg --type-add 'tsx:*.tsx' --type ts --type tsx "import.*USER_JOINED_ORGANIZATIONS_PG" -n echo -e "\nSearching for query usage in calls to useQuery..." rg --type-add 'tsx:*.tsx' --type ts --type tsx "useQuery\(USER_JOINED_ORGANIZATIONS_PG" -n -A 5Please confirm that no query consumers were missed and that they all correctly supply the
first
parameter.src/components/UserPortal/OrganizationCard/OrganizationCard.tsx (1)
68-70
: Good implementation with required parameter.This is a good implementation that properly includes the now required
first
parameter in theUSER_JOINED_ORGANIZATIONS_PG
query.src/screens/UserPortal/Organizations/Organizations.tsx (3)
61-65
: Update interface to use consistent field names.The interface has been updated to use
id
instead of_id
for membership requests, which is good for consistency with the new GraphQL schema.
431-432
: Good field name update.The property assignment correctly uses the new
id
field, which matches the updated schema.
259-260
:✅ Verification successful
Verify the data structure in the updated query.
The code now accesses
data.organizations
directly, which assumes a specific structure from theORGANIZATION_LIST
query. Ensure that this structure matches what's defined in the GraphQL schema.Let's verify the query structure by examining the schema definition:
🏁 Script executed:
#!/bin/bash # Find where the organizations query is defined in the GraphQL schema fd -e graphql -e gql "type Query" | xargs cat | grep -A 10 "organizations" # Also check the structure of the actual query rg -A 10 "ORGANIZATION_LIST = gql\`" --type tsLength of output: 1200
GraphQL Query Structure Verified
- The
ORGANIZATION_LIST
query returns anorganizations
field with the expected fields (id, name, addressLine1, description, avatarURL, and members with edges and node), which aligns with the code's access ofdata.organizations
.- No discrepancies were found between the query response structure and the code usage in
src/screens/UserPortal/Organizations/Organizations.tsx
.
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: 3
🔭 Outside diff range comments (3)
src/screens/UserPortal/Organizations/Organizations.tsx (3)
89-94
: 🛠️ Refactor suggestionUpdate interface to use consistent property names.
The
membershipRequests
field inInterfaceOrganization
uses_id
while the same field inInterfaceOrganizationCardProps
usesid
. They should be consistent.membershipRequests: { - _id: string; + id: string; user: { - _id: string; + id: string; }; }[];
229-252
:⚠️ Potential issueUpdate property references in this useEffect.
This useEffect still uses
_id
to access organization and member properties, but it should be updated to useid
to be consistent with the GraphQL schema changes.useEffect(() => { if (data) { const organizations = data?.UserJoinedOrganizations?.map( (organization: InterfaceOrganization) => { let membershipRequestStatus = ''; if ( organization.members.find( - (member: { _id: string }) => member._id === userId, + (member: { id: string }) => member.id === userId, ) ) membershipRequestStatus = 'accepted'; else if ( organization.membershipRequests.find( - (request: { user: { _id: string } }) => - request.user._id === userId, + (request: { user: { id: string } }) => + request.user.id === userId, ) ) membershipRequestStatus = 'pending'; return { ...organization, membershipRequestStatus }; }, ); setOrganizations(organizations); } }, [data]);
265-279
:⚠️ Potential issueUpdate property references in the mapping function.
This code still references
_id
but should useid
to be consistent with the GraphQL schema changes.if ( Array.isArray(organization.members) && organization.members.some( - (member: { _id: string }) => member._id === userId, + (member: { id: string }) => member.id === userId, ) ) membershipRequestStatus = 'accepted'; else if ( organization.membershipRequests?.some( - (request: { _id: string; user: { _id: string } }) => - request.user._id === userId, + (request: { id: string; user: { id: string } }) => + request.user.id === userId, ) )
🧹 Nitpick comments (2)
src/components/OrganizationCard/OrganizationCard.tsx (1)
13-14
: Combine duplicate imports from the same module.These imports are coming from the same module and should be combined into a single import statement to follow best practices and resolve the ESLint warning.
-import { ORGANIZATION_LIST } from 'GraphQl/Queries/Queries'; -import { USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries'; +import { ORGANIZATION_LIST, USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries';🧰 Tools
🪛 ESLint
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx (1)
13-14
: Combine duplicate imports from the same module.These imports are coming from the same module and should be combined into a single import statement to follow best practices and resolve the ESLint warning.
-import { ORGANIZATION_LIST } from 'GraphQl/Queries/Queries'; -import { USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries'; +import { ORGANIZATION_LIST, USER_JOINED_ORGANIZATIONS_PG } from 'GraphQl/Queries/Queries';🧰 Tools
🪛 ESLint
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/GraphQl/Queries/Queries.ts
(1 hunks)src/components/OrganizationCard/OrganizationCard.tsx
(2 hunks)src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
(2 hunks)src/screens/UserPortal/Organizations/Organizations.tsx
(5 hunks)
🧰 Additional context used
🪛 ESLint
src/components/OrganizationCard/OrganizationCard.tsx
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
[error] 13-13: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
[error] 14-14: 'GraphQl/Queries/Queries' imported multiple times.
(import/no-duplicates)
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/screens/UserPortal/Organizations/Organizations.tsx
[failure] 433-433:
Property 'id' does not exist on type 'InterfaceOrganization'.
🪛 GitHub Actions: PR Workflow
src/screens/UserPortal/Organizations/Organizations.tsx
[error] 433-433: error TS2339: Property 'id' does not exist on type 'InterfaceOrganization'.
🔇 Additional comments (4)
src/GraphQl/Queries/Queries.ts (2)
43-57
: Well-structured query with pagination support.The updated query correctly implements pagination for members using the edges/node pattern and includes pageInfo with hasNextPage. This is a good approach for handling potentially large member lists.
63-63
:✅ Verification successful
Verify all query usages with the required parameter.
The
first
parameter has been changed from optional (Int
) to required (Int!
). Make sure all usages of this query across the application include this parameter.
🏁 Script executed:
#!/bin/bash # Check all usages of USER_JOINED_ORGANIZATIONS_PG to ensure they include the first parameter rg "USER_JOINED_ORGANIZATIONS_PG" -A 10 | grep -B 5 -A 5 "variables:"Length of output: 9294
Verification Successful: All Query Usages Include the Required Parameter
The executed script confirms that every call to
USER_JOINED_ORGANIZATIONS_PG
in the codebase now correctly supplies thefirst
parameter. For instance:
- In
src/components/OrganizationCard/OrganizationCard.tsx
andsrc/components/UserPortal/OrganizationCard/OrganizationCard.tsx
, the query call uses:variables: { id: userId, first: 5 },- In
src/screens/OrgList/OrgListMocks.ts
, the query is invoked withfirst: 8
(along with the relevant parameters).- In
src/screens/OrgList/OrgList.tsx
andsrc/screens/UserPortal/Organizations/Organizations.tsx
, similar usage patterns with the requiredfirst
parameter are present.No instances were found where the parameter was omitted.
src/components/UserPortal/OrganizationCard/OrganizationCard.tsx (1)
62-64
: Correctly implemented required parameter.You've properly included the required
first
parameter in the query after the schema change. This is good practice to ensure the query works as expected.src/screens/UserPortal/Organizations/Organizations.tsx (1)
259-288
: Updated data structure handling.The implementation now correctly handles the new query structure by checking for
data?.organizations
and mapping over it. This aligns with the changes made to the GraphQL query.
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: 0
🔭 Outside diff range comments (3)
src/screens/UserPortal/Organizations/Organizations.tsx (3)
258-288
:⚠️ Potential issueUpdated organization data mapping to match new query structure
The organization data mapping has been updated to work with the new
data.organizations
structure returned by theORGANIZATION_LIST
query. However, there's a mismatch between the property names used in the code and the interface definition.(organization: { - members: { _id: string }[]; - membershipRequests: { _id: string; user: { _id: string } }[]; + members: { id: string }[]; + membershipRequests: { id: string; user: { id: string } }[]; }) => {And similarly the member check should use
id
instead of_id
:if ( Array.isArray(organization.members) && organization.members.some( - (member: { _id: string }) => member._id === userId, + (member: { id: string }) => member.id === userId, ) )And for the membership requests:
else if ( organization.membershipRequests?.some( - (request: { _id: string; user: { _id: string } }) => - request.user._id === userId, + (request: { id: string; user: { id: string } }) => + request.user.id === userId, ) as boolean )
433-433
:⚠️ Potential issueFix type error with organization ID
The code is accessing
organization._id
, but if the new query returnsid
instead of_id
, this will cause a TypeScript error.- id: organization._id, + id: organization.id,You should also update the
InterfaceOrganization
interface (lines 72-95) to useid
instead of_id
:interface InterfaceOrganization { isJoined: boolean; - _id: string; + id: string; name: string; image: string; description: string; // ... rest of the interface }And similarly update the membershipRequests interface property:
membershipRequests: { - _id: string; - user: { - _id: string; - }; + id: string; + user: { + id: string; + }; }[];The same update should be applied to
InterfaceOrganizationCardProps
(lines 44-67).
259-287
: 💡 Verification agent🧩 Analysis chain
Verify data consistency between old and new query responses
Ensure that all fields necessary for the component's functionality are present in the new query response. The query structure has changed from accessing nested data in
UserJoinedOrganizations
to directly accessingorganizations
.
🏁 Script executed:
#!/bin/bash # Check both old and new queries to ensure all required fields are present # Look for the definition of ORGANIZATION_LIST echo "Checking ORGANIZATION_LIST query definition:" rg -A 20 "const ORGANIZATION_LIST =" src/ # Look for the old query definition (likely USER_JOINED_ORGANIZATIONS) echo "Checking previous query definition:" rg -A 20 "const USER_JOINED_ORGANIZATIONS =" src/ # Verify organization structure references in OrganizationCard component echo "Checking OrganizationCard component references:" rg "_id|\.id" src/components/UserPortal/OrganizationCard/Length of output: 5591
Data Consistency Issue – Update Query Fields and Transformations
The new
ORGANIZATION_LIST
query is missing themembershipRequests
field, and itsmembers
field is structured as a connection (withedges
containing nodes with anid
) rather than a direct array of members with a_id
. This mismatch can cause the membership status checks insrc/screens/UserPortal/Organizations/Organizations.tsx
(lines 259–287) to fail.Action Items:
- Membership Requests: Ensure that the new query (or its subsequent data transformation) provides the
membershipRequests
field, which is required for determining the pending membership status.- Members Field Transformation: Adjust the transformation logic so that the members list is converted into an array with the expected
_id
property (or change the membership check accordingly), since the GraphQL response returns member IDs asid
within a connection.Please verify and update the query definition or the data mapping in the component to maintain consistency with the component's functionality.
🧹 Nitpick comments (1)
src/screens/UserPortal/Organizations/Organizations.tsx (1)
277-277
: Unnecessary boolean type assertionThe explicit boolean type assertion is redundant as the
some()
method already returns a boolean value.- ) as boolean + )
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/screens/UserPortal/Organizations/Organizations.tsx
(4 hunks)
🔇 Additional comments (4)
src/screens/UserPortal/Organizations/Organizations.tsx (4)
7-7
: Appropriate query import for retrieving all organizationsAdding the
ORGANIZATION_LIST
import aligns with the PR objective to replace the existing query with one that can fetch all organizations, not just those where the user is a member.
143-145
: Query updated to fetch all organizationsThe change from the previous query to
ORGANIZATION_LIST
implements the PR's primary objective of fetching all organizations rather than only those where the user is a member.
146-146
: Remove debug console.log statementThis debug statement should be removed before merging to production.
- console.log(data);
149-152
: Proper parameter passing for paginated queryThe update correctly specifies the required
first
parameter for the paginated organizations query, which is necessary for proper pagination functionality.
Please fix the failing tests. Our test code coverage system will fail if any of these conditions occur:
|
Working on failed test |
What kind of change does this PR introduce?
This PR replaces the previous query that only fetched joined organizations with a correct query to retrieve all organizations. Previously, we used organizationWhereMember to fetch All organizations, but it only returned those where the user was a member. Now, the updated query correctly fetches all organizations.
Now,
We correctly fetch all organizations using the organizations query.
We fetch joined organizations separately using the organizationsWhereMember query.
Issue Number:
Fixes #3565
Snapshots/Videos:
replace joinedOrganization query with organizationsWheremember to fetch only joined organization

Summary
Does this PR introduce a breaking change?
No
Checklist
CodeRabbit AI Review
Test Coverage
Other information
Have you read the contributing guide?
Summary by CodeRabbit
Summary by CodeRabbit
Refactor
New Features