Skip to content

Conversation

@plohan
Copy link
Contributor

@plohan plohan commented Aug 18, 2025

Why did you create this PR

Nested create flow is not working

What did you do

  • Fix nested relation for create flow

For update flow, I can't find function which map prisma values into form. Even though it exists, I can't decide by myself what is it behavior.

Screenshots / Recordings

2025-08-18.19-51-02.mov

Checklist

  • Self-reviewed your code
  • Wrote coverage tests (only code changes)
  • Added screenshots or recordings if applicable

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2025

🦋 Changeset detected

Latest commit: 86e4db5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@genseki/react Patch
@example/erp Patch
@example/ui-playground Patch
@genseki/next Patch
@genseki/plugins Patch
@genseki/prisma-generator Patch
@genseki/react-query Patch
@genseki/rest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 521 to 498
allowConnect={true}
allowCreate={true}
allowConnect={false}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 options (connect, create, connectOrCreate) does not give the same result of AutoRelationshipField

It should be

allowConnect={field.type === "connect" || field.type === "connectOrCreate"}
allowCreate={field.type === "create" || field.type === "connectOrCreate"}

interface AutoRelationshipFieldProps {
name: string
fieldShape: FieldRelationShapeClient
prefix: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be responsibility of name. Try to utilize it.

@saenyakorn
Copy link
Member

About default value of update form. It should be from updateDefaultApi. As you can see in the code,

export type CollectionUpdateConfig<
  TContext extends AnyContextable = AnyContextable,
  TFields extends Fields = Fields,
> = {
  fields: TFields
  updateApi?: ApiConfigHandlerFn<TContext, TFields, typeof ApiDefaultMethod.UPDATE>
  // TODO: This is not correct, it should return default value of form instead of just simple findOne response
  updateDefaultApi?: ApiConfigHandlerFn<TContext, TFields, typeof ApiDefaultMethod.FIND_ONE>
} & CollectionFieldsOptions<TContext, TFields>

Currently, it just a clone of fineOne but it should transform data into form value first before sending to client. It would be great if you also fix the logic.

@saenyakorn
Copy link
Member

You can find the similar function in transformer folder which located in packages/react/src/core/transformer.

@saenyakorn
Copy link
Member

Please also add changeset file and describe what you did in this PR into it.

@plohan
Copy link
Contributor Author

plohan commented Aug 19, 2025

Currently, it just a clone of fineOne but it should transform data into form value first before sending to client. It would be great if you also fix the logic.

I think update logic is much more complicated and required more coordination than this PR. For example, if a post has 3 post tags post.0.postTag.connect = "a", post.1.postTag.connect = "b" and post.2.postTag.connect = "c". If they update by removing the first postTag and create new one, then it become post.0.postTag.connect = "b" and post.1.postTag.connect = "c" and post.2.postTag.connect = "a". What should the application do.

@plohan plohan force-pushed the feat/create-nested-relation branch from 092204c to 8945254 Compare August 19, 2025 11:11
@plohan plohan force-pushed the feat/create-nested-relation branch from 8945254 to 86e4db5 Compare August 19, 2025 14:01
@saenyakorn saenyakorn merged commit a3f4e3b into softnetics:main Aug 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants