Adding non unique keyed child?

Lets say I have this schema

type ACL {

type Person {
  id: ID
  access: [ACL]
  customId: String
  name: String!

type Note {
  type: ID
  forPerson: Person
  note: String

So Person.customId is not globally unique or even type unique, but is unique per the controlled ACL controlled through another layer.

What I want to do is add a Note with an import script mutation. I have the customID. If I add the forPerson and only supply the customID how will it be handled if there are existing matching Person with that customId already?

  1. Add a new Person with only that field.
  2. Link to existing Person(s) that have that value.

If 1, how can I process it so that it does 2 without making that a unique field.

I think this is a good candidate for custom mutation directive. When you add a note, the following logic is applied:

  1. Query for person with that customID.

  2. If Person exists, the actual Person (with id based unique link) is hooked into the Note. Mutation is commited into the backend.

  3. If not, a new Person is created along with a Note with a normal mutation commit.

Ok, If that is the best way to go, then next question is what is the ETA of custom logic such as Javascript in custom directive? I think this would be agood use case to keep all this logic on database side and not need to send it to to a 3rd party script that will need to male additional round trips to the db.

1 Like

It is on our list, No ETA yet.

Since its only a String field which is not an ID, it would just add a new person with only that field.

We have started scoping out the RFC for it. The RFC should be out in a couple of weeks. We aim for the feature should be live by Oct/Nov.