Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Generate ID if not provided in create mutation #70

Closed
johnymontana opened this issue Jul 12, 2018 · 3 comments
Closed

Generate ID if not provided in create mutation #70

johnymontana opened this issue Jul 12, 2018 · 3 comments

Comments

@johnymontana
Copy link
Contributor

Use apoc.create.uuid in the generated create mutations so the user does not need to specify an id at creation time.

If an ID param is provided, then a generated uuid should not be used.

@johnymontana
Copy link
Contributor Author

Use @autogenerate directive on ID field in typedef to indicate field should be autogenerated. If @autogenerate is found on an ID field it will not be included as an argument in the create mutation but will be set automatically at creat time.

@YizYah
Copy link

YizYah commented Aug 19, 2018

@johnymontana thanks! That sounds like a big step forward! If I could just ask a few questions...

  1. When do you plan to commit this change? (I see that it's not in the latest.)
  2. Is this a UUID, meaning that I could expect uniqueness to be maintained even across types? (e.g. given types X and Y, every autogenerated X.id would be different than every Y.id?)
  3. Am I correct that you don't currently have implemented "If an ID param is provided, then a generated uuid should not be used."?

Regarding that last question, I just want to point out that, since we currently don't have nested updates, our front end will have to wait for the generated id for every creation mutation before requesting anything else that uses that generated id. For instance, given types X and Y, we can't have a single mutation function that uses an id for a CreateX and also for AddXY.

[As I've said elsewhere, I think that the biggest improvement to the package would be to allow for nested mutations. At a minimum, nested creation which supported the calls to Add would profoundly simplify the front end!]

@johnymontana
Copy link
Contributor Author

Instead of using directives to drive this we keep the id field nullable and if a value for it is not provided in the mutation then one is generated using apoc.create.uuid, if the id value is provided then no UUID is generated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants