Closed rajankit296 closed 1 year ago
@Andy2003 Here, we want to fetch outgoing nodes but we are not able to proceed due to this issue. Can you please help here? Thanks
You should define the rich-relation type OutGoingActionTypeRelationship
with two different named fields, one for the start-node and one for the end-node of the relation, e.g.:
type OutGoingActionTypeRelationship @relation(name:"HAS", from:"from", to:"to" direction: OUT){
id: String
from: ActionType
to: ActionType
}
having just one field used both, for from
and to
is a misconfiguration.
If you don't need rich-relations, you can also define the relation directly on the field. Please take a look at the examples.
Thanks @Andy2003 for the suggestion.
As suggested above, we changed the schema like this:
We are using neo4j-graphql-java 1.6.0
Graphql Schema
type ActionType{
id: String!
outgoingActionTypeRel: [OutGoingActionTypeRelationship]
}
type OutGoingActionTypeRelationship @relation(name:"HAS", from:"from", to:"to", direction: OUT){
id: String
from: ActionType
to: ActionType
}
Graphql Query
query{
actionType{
id
outgoingActionTypeRel{
id
to{
id
}
}
}
}
Generated Cypher
MATCH (actionType:ActionType)
CALL {
WITH actionType
MATCH (actionType)<-[actionTypeOutgoingActionTypeRel:HAS]-(actionTypeOutgoingActionTypeRelFrom:ActionType)
RETURN collect(actionTypeOutgoingActionTypeRel {
.id,
to: actionTypeOutgoingActionTypeRelFrom {
.id
}
}) AS actionTypeOutgoingActionTypeRel
}
RETURN actionType {
.id,
outgoingActionTypeRel: actionTypeOutgoingActionTypeRel
} AS actionType
There is no change in the direction.
Take a look at this example on how to configure the relation correctly!
We have added a Schema where we have incoming/outgoing relationship with same type. When we try to fetch result from graphql query, we get opposite result. Instead of outgoing node details, we are getting incoming node details.
GraphQL schema
GraphQL request
Generated Cypher
Here, the direction of "actionTypeOutgoingActionTypeRel" should be from "actionType" to "actionTypeOutgoingActionTypeRelActionType"
but it is generating opposite.