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

How to modify a property with a mutation request? #571

Open
@michaeldgraham

Description

@michaeldgraham

Taken from this post on the Neo4j Community Forum.

I have article nodes in a Neo4j database. One of his property is a boolean: "saved: false". The property name of this node is "saved".

I have a React interface where I want users to be able to save articles as favorites. So what I would like to do is change the property "saved" to true when they want to save an article or set to false when they want to cancel the favorite.

This process can be done with a graphql request but I don't know how to write my request to modify a node property.

Example: The user wants to save the article with id = 1, so he clicks on the button "favorite" and the article node property id = 1 and the node property "saved" goes from false to true.

I just want to update a node property, like this I think:

type Mutations {
    saved(article:ID!) : ??? (string ?)
      @cypher(statement:"MATCH (a:Article {id: $id, saved:$saved})
                         SET a.saved += true ")
}
schema {
   mutations: Mutations
}

How can I do it ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions