erquhartE
Convex Community3y ago
3 replies
erquhart

Creating co-dependent records

- I have tables
foo
and
bar

-
foo
has a required
defaultBarId
field
-
bar
must have a
fooId
field

I currently have to set
foo.defaultBarId
to optional, even though it's not, just to serve the split second of the
foo
record's existence when it doesn't have a
defaultBarId
.

Curious if there's a workaround or a better approach, I'd like to type both fields as required.

If there's not something I'm missing here, I'm wondering if ID generation would be possible, as long as the ID is used within the confines of the mutation that it's generated in. In this case I could generate an ID for the
bar
record first, and then create both records with properly required types.
Was this page helpful?