feat(data-weaver): implement generic fetch nodes - #455
Open
nick-nlb wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.
nick-nlb
marked this pull request as ready for review
August 28, 2026 22:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR extracts a reusable
fetchNodesclient helper for querying the Data Commons V2/v2/nodeendpoint and add unit test coverage for thedc_apiclient.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
dc_api.test.tscovering missing API key errors,/v2/noderequest structure, and child place parsing.pnpm lint.Note: this does not fix formatting, as a separate open PR does this.