Skip to content

feat(data-weaver): implement generic fetch nodes - #455

Open
nick-nlb wants to merge 2 commits into
datacommonsorg:mainfrom
nick-nlb:dw-generic-fetch-nodes
Open

feat(data-weaver): implement generic fetch nodes#455
nick-nlb wants to merge 2 commits into
datacommonsorg:mainfrom
nick-nlb:dw-generic-fetch-nodes

Conversation

@nick-nlb

Copy link
Copy Markdown
Collaborator

Description

This PR extracts a reusable fetchNodes client helper for querying the Data Commons V2 /v2/node endpoint and add unit test coverage for the dc_api client.

The proximate reason for this refactor and the generic function (rather than a single direct fetchChildPlaces) is that upcoming functionality to fetch GeoJSON for the choropleths will use this. More generally, a fetchNodes function could prove to be useful for other purposes later.

Testing

  • Added unit tests in dc_api.test.ts covering missing API key errors, /v2/node request structure, and child place parsing.
  • Verified test suite.
  • Verified lint and type checks with pnpm lint.
  • Verified build and build runtime

Note: this does not fix formatting, as a separate open PR does this.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the Data Commons API client by extracting a reusable fetchNodes function from fetchChildPlaces and introduces a comprehensive test suite in dc_api.test.ts. The review feedback recommends improving the test setup by using Vitest's built-in vi.stubEnv and vi.unstubAllEnvs utilities instead of manually mutating process.env. Additionally, it is recommended to use vi.spyOn(globalThis, 'fetch') rather than directly overwriting globalThis.fetch to prevent global scope pollution and potential test flakiness.

Comment thread dataweaver/apps/web/src/server/clients/dc_api.test.ts Outdated
Comment thread dataweaver/apps/web/src/server/clients/dc_api.test.ts Outdated
Comment thread dataweaver/apps/web/src/server/clients/dc_api.test.ts Outdated
@nick-nlb
nick-nlb marked this pull request as ready for review August 28, 2026 22:46
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