Show the booking details behind an imported element - #70
Merged
Conversation
The API now parses structured details out of an imported booking — flight numbers, reservation codes, seats, where transport leaves from and arrives — and exposes them as element_metadata. The app fetched none of it, so a flight imported from a confirmation email looked like any other pin. Renders them as a Booking section on the element detail screen, ordered and titled the same way the web app does so one booking reads the same in both places: the kind of transport titles the number rather than taking a row of its own, a flight number links out to its status, and the raw address only appears when geocoding failed (otherwise it's already the element's location). Fetching metadata on the import and update mutations too, so an element lands in the cache with its booking details already attached. Fix GraphQL codegen while here, since adding a field required running it. It couldn't run at all: typescript-react-apollo peers at graphql <=16 and crashed on the installed 17, and its Apollo v3-shaped hooks needed ~15 @ts-ignores hand-applied after every regen. Dropped it, along with the typescript plugin whose schema types typescript-operations 6.x now emits itself (running both defined every input twice). Codegen emits a TypedDocumentNode per operation instead, passed to Apollo's own hooks, which infer results and variables from it — so `bun run codegen` is now a clean, idempotent, no-touch-ups command. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Summary
The API now parses structured details out of an imported booking — flight numbers, reservation codes, seats, departure/arrival — and exposes them as
element_metadata. The app fetched none of it, so a flight imported from a confirmation email looked like any other pin.metadatawherever a full element is fetched (detail query, plus the import and update mutations so an element lands in the cache with its booking details attached)src/map/metadataRows.tsturns the metadata into labelled rows, mirroring the web app's presentation so one booking reads the same in both places:typenever gets its own row; it titles the number instead (Flight / Train / Bus / Ferry)IB3216toAmerican Airlines 291addressonly shows when geocoding failed, since otherwise it's already the element's locationMetadata is read-only server-side (
ElementInputhas no metadata field), so the edit screen needed nothing.Fixing GraphQL codegen
Adding a field meant running codegen, which turned out to be broken two ways — both from
@graphql-codegen/typescript-react-apollo:graphql <=16, so it crashed on the installed 17 (Cannot read properties of undefined (reading 'find')— 17 leaves optional AST list fields undefined where 16 gave[])@ts-ignores and import rewrites applied by handDropped it, along with the
typescriptplugin whose schema typestypescript-operations6.x now emits itself (running both defined every input twice →TS2300). Codegen now emits aTypedDocumentNodeper operation, passed to Apollo's own hooks, which infer results and variables from it:bun run codegen ./schema.graphqlnow runs on graphql 17 with the repo's declared deps, output is idempotent, and needs no touch-ups. The generated file dropped from ~1400 lines to 450. README stack/example sections updated to match, and__generated__is excluded from thedocumentsglob — codegen was reading its own output back in as duplicate documents.Three call-site changes worth a look:
labelsMatch: 'ALL'instead ofLabelMatchMode.All. InMapScreenthe literal sat inside auseMemothat widened it tostring, so it's annotated withPick<ElementsQueryVariables, …>to stay checked against the schemaphotoUploadandauthClientlost their explicit generics (mutate<LogoutMutation>), which were looser than inference — they left variables untyped__typename(visitor-plugin-common 7.x only emits it when a selection asks). Apollo still adds it on the wire and keys its cache off it, so normalization is unaffectedTesting
bunx tsc --noEmit,bun run lint, and 51 tests all pass; codegen output verified byte-identical across repeated runs.🤖 Generated with Claude Code