-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add the missing fields to the GraphQL schema #49
Conversation
…he GraphQL schema Gymnast.items with addGymnastItem and removeGymnastItem, Routine.createdAt and updatedAt, and CatalogItem.removed. API.md describes the rules, errors and limits.
…d items do not count addGymnastItem throws ALREADY_EXISTS and removeGymnastItem throws NOT_FOUND when nothing would change. A gymnast's list is limited to 100 items. Removed items do not count in the D-score, and calculateDScore rejects them. API.md describes the warning in the UI, the seed report and the other error codes.
Names are trimmed and checked in the backend, BAD_USER_INPUT otherwise.
|
Looks good:) Im ready to merge when you're done with fixing the merge conflicts @ronjalh |
Resolves the conflicts with the search and schema changes in dev. dev's names are kept (Gymnast.elements, addGymnastElement, removeGymnastElement, difficultyValues, no difficultyLetter, duplicates in a routine). The decisions for #37 are kept: errors for a duplicate add and a missing remove, a limit of 100, names of 70 characters, and removed items do not count.
Do you agree with this approach?While this PR was open, #38 put its own version of the gymnast's list in What changes compared with
Kept from Alternatives
@anettkva, you wrote the version in #38 and will probably write the resolvers, so I would like to hear from you before this merges. The same goes for everyone who builds the UI (#39–#48), since the UI has to handle Please answer with: agree, object, or prefer (a) or (b). Comment made with Claude Code in discussion with Ronja |
Keeps both AI_USAGE sections. Puts the one-line descriptions in schema.graphql back as they are in dev: an earlier Prettier run had turned all of them into blocks.
|
Agree with most of it, but I prefer (a) for the gymnast's list. Agree: the limit of 100, names trimmed to 1–70 characters, and removed items cannot be added but can stay or be removed. Prefer (a), keep the silent no-op:
Removed items: I agree that Comment made with Claude Code in discussion with Anette |
|
Not ready to merge yet. The merge of dev into this branch ( Must fix before merging
|
Vault.dValue, CatalogFilter.difficultyValues, createGymnast, renameGymnast and createRoutine had ended up inside doc comments and were missing from the schema. Also restores the searchCatalog search description from dev (80 characters, 8 words, text without searchable words finds nothing).
Adding an item that is already in a gymnast's list, or removing one that is not, now changes nothing and returns the gymnast, so ALREADY_EXISTS is gone and NOT_FOUND is only for unknown ids. Routine.dScore is null while the routine has a removed item, the same rule as calculateDScore. calculateDScore keeps taking only item ids.
Only the layout of the doc comments changes. printSchema gives the same result before and after.
Summary
Adds the fields that the database has and
schema.graphqldid not expose, and describes them indocs/API.md.Gymnast.elements(apparatusId)withaddGymnastElementandremoveGymnastElement. Both return the wholeGymnast, so the client can update its cache.Routine.createdAtandupdatedAt.setRoutineItemsmust touchupdatedAtin the same transaction as the items.CatalogItem.removed: Boolean!(also onElementandVault).Decisions
What "removed" means. An element or vault is removed when it is no longer in the edition of the Code of Points that the app uses. The database sets
removedAtand never deletes the row, because routines and lists point to it. It is global catalog data set by the seed script, never by a coach. No removed items exist today, sincedata/only has the 2025–2028 edition.Errors are never silent. Adding an item that is already in the list throws
ALREADY_EXISTS, and removing one that is not in the list throwsNOT_FOUND. The list is unchanged in both cases, so repeating a call does no harm, but the client is told that nothing changed. The names follow the gRPC/Google error vocabulary. The UI should disable the button while a call runs and treat these two errors as "my list is out of date, reload".Removed items:
searchCatalog, but returned byelement(id),vault(id)andcatalogItem(id)withremoved: trueINVALID_ITEMS), but can stay where they are and can be removedRoutine.dScore, andcalculateDScorerejects them withINVALID_ITEMSLimit: a gymnast's list has at most 100 items (
LIMIT_REACHED).Two tabs:
setRoutineItemsreplaces the whole list and the last save wins. This is written down as a choice for the prototype, withCONFLICTandupdatedAtas the way to change it later.Merged with dev
devgot its own version of the gymnast list and theremovedflag through #38 (Gymnast.elements,addGymnastElement,removeGymnastElement, where adding twice or removing a missing item did nothing and there was no limit). This PR keepsdev's names and additions (difficultyValues, nodifficultyLetter, the same element twice in a routine, removed variants left out ofvariants) and keeps the decisions for #37: adding twice givesALREADY_EXISTS, removing a missing item givesNOT_FOUND, a gymnast's list has at most 100 elements, names are 1–70 characters, and removed items do not count in the D-score. The part ofdev's docs that said the opposite is changed.Other docs
docs/API.md: error table with the new code and the Apollo codes (GRAPHQL_VALIDATION_FAILED,INTERNAL_SERVER_ERROR),UNAUTHENTICATEDalso for an expired session or Google token, limits and tests.docs/USER_LIST_PAGINATION.mdanddocs/AI_USAGE.mdare updated.Notes for review
graphql@16(buildSchema). Nothing else can be run, because there is no server yet.schema.graphqlanddocs/API.md, in other places. I expect no conflict, but check when merging.BAD_USER_INPUT), the length the UK Government Data Standards give for a full name in one field. Checked in the backend; the database does not check it yet.Closes #37
🤖 Generated with Claude Code