Skip to content

expanding "Census" data resolvers#556

Merged
irees merged 7 commits intomainfrom
ntd-in-census
Jan 20, 2026
Merged

expanding "Census" data resolvers#556
irees merged 7 commits intomainfrom
ntd-in-census

Conversation

@drewda
Copy link
Copy Markdown
Member

@drewda drewda commented Jan 11, 2026

This PR expands the Census data resolvers by adding a new values_relay field to CensusDataset that supports Relay-style cursor pagination for querying census values. This enables efficient pagination through large census datasets, which is particularly useful for querying NTD agency data.

Changes

GraphQL Schema

  • Added values_relay field to CensusDataset type with cursor pagination (first, after)
  • Added CensusDatasetValueFilter input type with filters:
    • table - filter by table name
    • geoid - filter by exact geoid
    • geoid_prefix - filter by geoid prefix (e.g., ntd:00001 to find all values for an NTD agency)
  • Added standard Relay connection types: CensusValueConnection, CensusValueEdge, PageInfo
  • Implemented the previously stubbed Tables resolver for CensusDataset

Implementation

  • Cursor pagination: Uses composite key (geoid, table_id) encoded in base64 for stable cursor-based pagination
  • Efficient SQL: Proper composite key ordering with WHERE (geoid, table_id) > (last_geoid, last_table_id) pattern

Testing

  • Added 13 test cases in TestCensusResolver_DatasetValuesRelay covering:
    • Basic queries and pagination
    • All filter combinations (table, geoid, geoid_prefix)
    • Edge cases (non-existent values, empty results)
    • Pagination behavior (hasNextPage, cursor continuity)
  • Added tests for CensusCursor encode/decode round-trips
  • Added tests for EscapeLike helper function

in support of interline-io/calact-network-analysis-tool#260

Copilot AI review requested due to automatic review settings January 11, 2026 04:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request expands Census data resolvers by adding a new census_values query and implementing the previously stubbed-out Tables resolver for census datasets. These changes support issue #260.

Changes:

  • Added new GraphQL query census_values for querying census data by geoid, dataset, or table name
  • Implemented the Tables resolver for CensusDataset using a dataloader pattern
  • Added filtering capabilities for census values with support for exact and prefix matching on geoids

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
schema/graphql/schema.graphqls Added census_values query and CensusValueFilter input type with filtering options
server/model/models_gen.go Added CensusValueFilter struct definition
server/model/finders.go Added FindCensusValues and CensusTablesByDatasetIDs method signatures to interfaces
server/gql/query_resolver.go Implemented CensusValues query resolver
server/gql/census_resolver.go Implemented Tables resolver using dataloader for efficient batch loading
server/gql/loaders.go Added CensusTablesByDatasetIDs dataloader configuration
server/gql/loader_params.go Added censusTableLoaderParam struct for dataloader parameters
server/finders/dbfinder/census.go Implemented database queries for finding census values and tables by dataset IDs
internal/generated/gqlout/generated.go Auto-generated GraphQL bindings and marshaling code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@irees irees merged commit c8f7528 into main Jan 20, 2026
6 checks passed
@irees irees deleted the ntd-in-census branch January 20, 2026 08:38
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.

3 participants