Skip to content

Conversation

jonatsm
Copy link
Member

@jonatsm jonatsm commented Oct 12, 2026

Connect search and list to the backend

The search page now gets its results from the database through GraphQL instead of filtering mock data in the browser.

  • useSightingSearch uses the sightings query. Search and sort still live in the URL, and the 300 ms debounce is kept.
  • Loading, empty and error states (with "Try again"). The header shows "Showing 20 of 80,328 results".
  • "Load more" pagination with an Apollo cache rule that appends pages per search/sort
  • Frontend types now allow null like the schema, with fallbacks such as "Unknown" and "No map location"
  • Removed filter-sightings and its tests; updated AGENTS.md

Tests check which requests are sent: one per search after typing stops, none for a repeated search, and paging/retry.

Known limitations

  • Clicking a result opens "Sighting not found": the detail page still reads mock data. That's a separate issue.
  • The backend's SHAPE_ASC sorts sightings without a shape first. That's for the resolver.

How to test

  1. SSH tunnel to the VM, backend/.env filled in from .env.example
  2. npm run dev:backend and npm run dev
  3. In DevTools → Network: typing gives one request, a repeated search gives none, and "Load more" gives one per click

AI usage

Claude Code helped plan and implement the hook, cache rules, UI states and tests, and debug the local DB setup.

Closes #34

Allow null in every UfoSighting field except id, like the Sighting
type in the schem, and show readable fallbacks when values are
missing. Map the URL sort names to the API's SightingSort enum.

Refs #34
Query one page of sightings with search, sort and cursor variables,
including totalCount and pageInfo for the result count and "load
more". Types so useQuery knows the shape of data and variables.

Refs #34
Replace the in-browswer filtering in useSightingSearch with the
sightings query, so search and sort run on the whole dataset in
the database. Keep the debounce and URL state, and trim the search
so trailing spaces do not send new requests. Tests now check which
requests the page sends instead of how mock data is sorted.

Refs #34
Show a loading message before the first results, keep previous
results visible but dimmed while a new search loads, and show an
error with a retry button if the backend fails.

Refs #34
Fetch the next page with the end cursor and append it in the Apollo
cache, keyed by search, filter and sort so each search keept its own
list. Show "showing X of Y" progress, keep focus on the button
while loading, and offer a retry if a page fails.

Refs #34
Delete filter-sightings and its tests now that search and sort run
in the database. Update comments that described the old filtering,
and bring AGENTS.md's current state and folder notes up to date.

Refs #34
@jonatsm jonatsm added feat New feature frontend refactor Changes made to existing features labels Oct 12, 2026
@jonatsm jonatsm added this to the Partial submission 2 milestone Oct 12, 2026
@jonatsm jonatsm requested a review from a team as a code owner October 12, 2026 10:42
@jonatsm jonatsm linked an issue Oct 12, 2026 that may be closed by this pull request
4 tasks
Copy link
Member

@asgeija asgeija left a comment

Choose a reason for hiding this comment

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

LGTM, works well.

@asgeija asgeija merged commit 7130af9 into main Oct 12, 2026
1 check passed
@asgeija asgeija deleted the 34-connect-search-and-the-list-view-to-the-backend branch October 12, 2026 10:51
Sign in to join this conversation on GitHub.
Labels
feat New feature frontend refactor Changes made to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connect search and the list view to the backend
2 participants