deep-foundation / deep-foundation/deeplinks
cannot insert object relationship "string" as "id" column values are already determined
- Dominant language
- TypeScript
- Stars
- 13
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
# Minimal Example
```js
const ids = await deep.reserve(1);
await deep.insert({
type_id: await deep.id("@deep-foundation/core", "SyncTextFile"),
string: {
data: {
value: "Text"
}
},
id: ids.pop()
})
```
# Error
```
cannot insert object relationship "string" as "id" column values are already determined
```
# Example with link_id defined for value
```js
const ids = await deep.reserve(1);
await deep.insert({
type_id: await deep.id("@deep-foundation/core", "SyncTextFile"),
string: {
data: {
link_id: ids[0],
value: "Text"
}
},
id: ids[0]
})
```
# Output
```
cannot insert object relationship "string" as "id" column values are already determined
```
When this error happens:
When we use reserved id and any value. Right now we must choose between using reserved ids or inserting value (in the same query)
# Workaround
```ts
const [linkId] = await deep.reserve(1);
const data = await deep.apolloClient.mutate(generateSerial({
actions: [
generateMutation({
tableName: 'links', operation: 'insert',
variables: { objects: [{ id: linkId, type_id: await deep.id("@deep-foundation/core", "SyncTextFile") }] },
}),
generateMutation({
tableName: 'strings', operation: 'insert',
variables: { objects: [{ link_id: linkId, value: "Text" }] },
}),
],
name: 'INSERT_LINK_AND_STRING',
}))
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the deep.insert and deep.reserve entry points, then trace how relationship insertion builds the Apollo mutation used by generateSerial. Reproduce the minimal example with a reserved id and a string value; done means one insertion query accepts both without requiring the separate links and strings workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100