Copy Mutations

Have you considered adding “copy”-directives on types which generate “copyType” mutations?

Could be very useful I think!

type Project
  @copy(edit: [name]) {
  id ID!
  name: String!
  
  owner: User!  

  images: [Image!]
}

Could generate the mutation:

copyProject(
   input: {
     filter: {id: {eq: $projectId} }
     set: {name: $newName}
})

edit: would specify all fields that can be changed before copying. All other fields are copied without any changes.

I’m still unsure about how to handle child nodes.

  1. Copy all fields and only change the parent (here: project)
  2. Also allow changes to be made on child objects (Becomes very hard with arbitrary depths)

Any opionions?

1 Like

one must wonder, does this directive make GraphQL a turing complete language?

2 Likes

This seems like something that can be done by the client or using a custom DQL query?

Yes, I do it on a 2nd server right now which has a client to dgraph. This also reduces the traffic to the “real” clients.

It’s just a lot of manual work right now. E.g. you always have to type out every fieldname etc. And you also have to keep track of any schema changes.

1 Like

Any update on this? Will this be considered a feature in the future?

As maaft said, it is a lot of unnecessary manual work