neo4j-graphql-js
neo4j-graphql-js copied to clipboard
Using types as sub objects
This question might be really dumb, I'm not the best at neither GraphQL nor Neo4j.
I have a schema created with makeAugmentedSchema, where there's a user that has an address field:
type Address {
country: String
city: String
}
type User {
name: String
address: Address
}
Now it tries to generate the address type as a node, which makes sense. Is it possible to just have a type as a nested object, that can be created directly in a CreateUser mutation?
Would love to be able to do that
We currently map GraphQL types directly to node labels in the database, which makes it easy to reason about the data model. In your case, this results in having to execute 3 mutations to create an Address, User, and connect them: CreateAddress, CreateUser, and AddAddressUser.
Combining all of this into a single mutation operation - known as a nested mutation. is on our radar, but not something that is currently supported.
In the mean time, you could add this functionality manually to your schema by creating a mutation with a @cypher schema directive and defining the logic for updating the database with a Cypher query.
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608