Skip to content

refactor: useFetchEntityInfo uses new getNodeByID endpoint BED-8742#2958

Open
urangel wants to merge 1 commit into
mainfrom
BED-8742
Open

refactor: useFetchEntityInfo uses new getNodeByID endpoint BED-8742#2958
urangel wants to merge 1 commit into
mainfrom
BED-8742

Conversation

@urangel

@urangel urangel commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

The useFetchEntityInfo hook is updated to use the getNodByID endpoint to retrieve entity information instead of the cypher search endpoint.

Motivation and Context

Resolves BED-8742

This refactor will enable OG entity info support by routing through an endpoint that will return info section information derived from extension managed schemas.

How Has This Been Tested?

Unit tests have been updated and the change was verified locally.

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)

Checklist:

Summary by CodeRabbit

  • Bug Fixes
    • Improved entity info loading when a node’s type isn’t in the schema, ensuring the UI shows the correct “unknown kind” details.
    • Updated entity details retrieval to use direct node-by-ID fetching when a database ID is available, improving refresh/re-fetch consistency (including OpenGraph values).
  • Tests
    • Updated entity info and selected details tab tests to mock the node-by-ID API flow instead of the prior graph/Cypher mocks.

@urangel urangel self-assigned this Jul 6, 2026
@urangel urangel added the javascript Pull requests that update javascript code label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 431d55a4-b9c8-4a6c-b2dd-c993a7ce03f5

📥 Commits

Reviewing files that changed from the base of the PR and between e6a480f and 8678bd2.

📒 Files selected for processing (5)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
  • packages/javascript/bh-shared-ui/src/views/PrivilegeZones/Details/SelectedDetailsTabs/SelectedDetailsTabContent.test.tsx
💤 Files with no reviewable changes (1)
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx

📝 Walkthrough

Walkthrough

The hook now fetches database-backed entity data with getNodeByID, keeps schema-based node-type lookups unchanged, removes the Cypher helper, and updates tests and mocks to use /api/v2/nodes/:id.

Changes

Node lookup refactor

Layer / File(s) Summary
Hook query logic and helper removal
packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx, packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
useFetchEntityInfo now branches on databaseId to call apiClient.getNodeByID, falls back to entityInformationEndpoints[validatedKind] for nodeType, or returns empty results otherwise; informationAvailable and the removed Cypher helper/import are updated accordingly.
Test updates for node-by-id fetches
packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx, packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx, packages/javascript/bh-shared-ui/src/views/PrivilegeZones/Details/SelectedDetailsTabs/SelectedDetailsTabContent.test.tsx
Mocks, MSW handlers, spies, and assertions move from Cypher/graph responses to /api/v2/nodes/:id, and the off-schema test description is updated to match the new endpoint.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant useFetchEntityInfo
  participant apiClient
  participant entityInformationEndpoints

  useFetchEntityInfo->>useFetchEntityInfo: validate nodeType and check databaseId
  alt databaseId present
    useFetchEntityInfo->>apiClient: getNodeByID(Number(databaseId), { signal })
    apiClient-->>useFetchEntityInfo: node_id, kinds, properties
  else nodeType validated
    useFetchEntityInfo->>entityInformationEndpoints: fetch validatedKind
    entityInformationEndpoints-->>useFetchEntityInfo: data.data.props
  else neither available
    useFetchEntityInfo-->>useFetchEntityInfo: return empty kinds/properties
  end
Loading

Possibly related PRs

Suggested labels: api, user interface

Suggested reviewers: elikmiller

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main refactor to useFetchEntityInfo and the new getNodeByID endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-8742

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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

@coderabbitai coderabbitai Bot added the user interface A pull request containing changes affecting the UI code. label Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx`:
- Around line 40-46: The `useFetchEntityInfo.test.tsx` setup is double-mocking
`apiClient.getNodeByID`, so `entityNodeByIdRequest` never intercepts anything
and the MSW handler is unused. Update the test to either unmock `apiClient` for
the case that should exercise `/api/v2/nodes/:id`, or remove
`entityNodeByIdRequest` if the test should stay fully mocked; keep the existing
`useFetchEntityInfo` and `getNodeByID` test names aligned with the chosen
approach.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0a4529df-5918-4c34-9ee5-1f598ba43f69

📥 Commits

Reviewing files that changed from the base of the PR and between f78f8d1 and bf07b9b.

📒 Files selected for processing (4)
  • packages/javascript/bh-shared-ui/src/components/EntityInfo/EntityInfoContent.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.test.tsx
  • packages/javascript/bh-shared-ui/src/hooks/useFetchEntityInfo/useFetchEntityInfo.tsx
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts
💤 Files with no reviewable changes (1)
  • packages/javascript/bh-shared-ui/src/utils/entityInfoDisplay.ts

@coderabbitai coderabbitai Bot added the api A pull request containing changes affecting the API code. label Jul 6, 2026
if (validatedKind) {
({ signal }) => {
if (databaseId) {
return apiClient.getNodeByID(Number(databaseId), { signal }).then((res) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it redundant to perform an additional validations on databaseId to ensure a valid ID before reaching backend?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. The type of databaseId is defined as string | undefined so the property may or may not be available depending on the context in which one is trying to load entity information. This may have changed since this code was written originally so I'll double check but that is why the validation is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A pull request containing changes affecting the API code. javascript Pull requests that update javascript code user interface A pull request containing changes affecting the UI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants