Identifying the table/schema on the backend when ingesting from a generic mutation handler.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.9k
- Forks
- 266
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 55
Description
I have an app with a generic mutation handler as per https://github.com/TanStack/db/blob/main/docs/index.md#2-electricsql-sync
When I POST the mutations to the server, the only way of identifying the table/schema they should be applied to is to look in the syncMetadata.relation. This is current set from the ?table=... param in the streamOptions for the ElectricCollection.
This is fragile because it's totally valid not to use the table param when making a request to a proxy.
I see two ways forward:
- make a more resilient way of assigning the tablename / server-side identifier to the collection and have it reliably passed through to the mutations
- require the user to pass through the information, e.g.:
import genericMutationFn from './mutations'
const addTodo = useOptimisticMutation({ mutationFn: (params) => genericMutationFn('todos', params)})
As per #96, I would advocate for just having a way of passing the identifier through, e.g.: with an additional optional property on the collection options.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/index.md#2-electricsql-sync, then trace ElectricCollection streamOptions, syncMetadata.relation, and useOptimisticMutation through the generic mutation handler. Review the related discussion in #96 before choosing the identifier API. Done means the backend can reliably identify the target table or schema without depending on the table query parameter, with the chosen behavior documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100