Skip to content

Conversation

thortve
Copy link
Member

@thortve thortve commented Oct 8, 2026 •

Add createSighting(input: CreateSightingInput!): Sighting! for #37. Input is validated on the server: required fields, text lengths that match the VARCHAR columns, latitude -90..90, longitude -180..180, duration 1 s to 1 year, and a real local datetime from 1900 that is not in the future. All invalid fields are reported at once as a BAD_USER_INPUT error with fieldErrors in the extensions.

Add IS_USER_SUBMITTED to UFO_SIGHTINGS, exposed as Sighting.userSubmitted, so user rows can be told apart from NUFORC rows without a login. Add a backend test script (node --test) with unit tests for the validation.

TODO:

  • Store the sighting. insertSighting in src/db/sightings.ts is a stub that throws NOT_IMPLEMENTED until the MySQL layer exists (Build the GraphQL backend #28 ). It should find or create the LOCATIONS and SHAPES rows and insert with DATE_POSTED = NOW() and IS_USER_SUBMITTED = TRUE in one transaction.
  • Migrate the existing VM database. CREATE TABLE IF NOT EXISTS does not add the new column to a table that already exists, so run ALTER TABLE UFO_SIGHTINGS ADD COLUMN IS_USER_SUBMITTED BOOLEAN NOT NULL DEFAULT FALSE once.
  • Map IS_USER_SUBMITTED to userSubmitted in the sighting and sightings resolvers when they are written (the field is non-null).
  • Get group agreement on the schema change: the mutation, the input fields and limits, userSubmitted and the error format.
  • Connect SubmitSightingPage to the mutation instead of the local mock store.

Add createSighting(input: CreateSightingInput!): Sighting! for #37.
Input is validated on the server: required fields, text lengths that
match the VARCHAR columns, latitude -90..90, longitude -180..180,
duration 1 s to 1 year, and a real local datetime from 1900 that is
not in the future. All invalid fields are reported at once as a
BAD_USER_INPUT error with fieldErrors in the extensions.

Add IS_USER_SUBMITTED to UFO_SIGHTINGS, exposed as
Sighting.userSubmitted, so user rows can be told apart from NUFORC
rows without a login. Add a backend test script (node --test) with
unit tests for the validation.

TODO:
- Store the sighting. insertSighting in src/db/sightings.ts is a stub
  that throws NOT_IMPLEMENTED until the MySQL layer exists (#31). It
  should find or create the LOCATIONS and SHAPES rows and insert with
  DATE_POSTED = NOW() and IS_USER_SUBMITTED = TRUE in one transaction.
- Migrate the existing VM database. CREATE TABLE IF NOT EXISTS does
  not add the new column to a table that already exists, so run
  ALTER TABLE UFO_SIGHTINGS ADD COLUMN IS_USER_SUBMITTED BOOLEAN
  NOT NULL DEFAULT FALSE once.
- Map IS_USER_SUBMITTED to userSubmitted in the sighting and
  sightings resolvers when they are written (the field is non-null).
- Get group agreement on the schema change: the mutation, the input
  fields and limits, userSubmitted and the error format.
- Connect SubmitSightingPage to the mutation instead of the local
  mock store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thortve thortve linked an issue Oct 8, 2026 that may be closed by this pull request
4 tasks
@thortve thortve self-assigned this Oct 8, 2026
Merge main to get the MySQL pool and sighting queries from #28, and
build on them so createSighting stores sightings for #37.

insertSighting runs in one transaction. It reuses or creates the
LOCATIONS and SHAPES rows, using <=> for nullable columns like the
import script, then inserts with DATE_POSTED = NOW() and
IS_USER_SUBMITTED = TRUE. City, state and country are lowercased to
match the imported data. The sighting queries now return
userSubmitted.

SubmitSightingPage now calls the mutation instead of the mock store.
Server field errors are shown next to their fields, and other
failures show a general message. The datetime is sent as local time,
since the server rejects UTC with Z. The created sighting is also
added to the local store so the detail link works until the list and
detail pages read from GraphQL.

The VM database needs the IS_USER_SUBMITTED column before deploying,
or the sighting queries fail.

Closes #37

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thortve thortve marked this pull request as ready for review October 8, 2026 12:13
@thortve thortve requested a review from a team as a code owner October 8, 2026 12:13
@asgeija asgeija added this to the Partial submission 2 milestone Oct 12, 2026
@thortve thortve added enhancement New feature or request feat New feature and removed configuration labels Oct 12, 2026
@asgeija
Copy link
Member

asgeija commented Oct 12, 2026 •

Youre good, LGTM.

@thortve thortve merged commit b404abf into main Oct 12, 2026
1 check passed
@asgeija asgeija deleted the 37-add-a-createsighting-mutation branch October 12, 2026 10:55
Sign in to join this conversation on GitHub.
Labels
backend enhancement New feature or request feat New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a createSighting mutation
2 participants