How to stop duplication when streaming data into Neoj4


(Werner) #1

I am dealing with different methods of creating uniqueness over a graphql interface
currently where using neo4j-graphql-js which features auto-generated mutations for graphql types in neo4j

under the hood it's really just translating e.g. create mutations to a cypher CREATE query

which is why duplicates can occur
busy using
e.g. using CONSTRAINT or MERGE

i was thinking about forking the lib and extend the auto-generation method with MERGE
but maybe there is something more elegant


type Mutation {
  MergeCustomer(id: ID!, device: String): Customer
    @cypher(
      statement: """
      MERGE (S:Customer {id:$id, device:$device}) RETURN S
      """
    )
  MergeIPAddress(ip: String!): IPAddress
    @cypher(
      statement: """
      MERGE (S:IPAddress {ip:$ip}) RETURN S
      """
    )
...
}

but in a streaming fashion it's difficult to maintain a consistent db state as duplicate values are constantly flooding in.


(William Lyon) #2

Hi @werner - yes, we should really expose the option of using MERGE in the generated mutations. This has come up a few times, and we've discussed a few options here: https://github.com/neo4j-graphql/neo4j-graphql-js/issues/83

Would you mind adding your thoughts to that Github issue?


(Werner) #3

Hey @William_Lyon - thanks for the speedy reply will add my question/ thoughts on git.