@MuddyBootsCode - trying to replicate my issue using a minimal code example I now realize that what you describe above does work for trivial examples, but breaks in my actual code base. Should have tried this earlier! Stripping my codebase down, I've create an example which still triggers what I believe is a bug in neo4j-graphql-js
:
This is my schema:
# An interaction between two sets of entities
type Interaction {
kind: String! # Type of interaction that occured, eg, visited, spoke to, etc
subjects: [Entity] @cypher(statement: """
MATCH(this:Interaction)<-[:PARTICIPATED_IN { subject: true }]-(e:Entity)
RETURN e
""")
objects: [Entity] @cypher(statement: """
MATCH(this:Interaction)<-[:PARTICIPATED_IN { subject: false }]-(e:Entity)
RETURN e
""")
participants: [Entity] @cypher(statement: """
MATCH(this:Interaction)<-[:PARTICIPATED_IN]-(e:Entity)
RETURN e
""")
# ... extra fields for time, location, etc
}
interface Entity {
name: String!
subjectIn: [Interaction] @cypher(statement: """
MATCH(this:Entity)-[:PARTICIPATED_IN { subject: true }]->(i:Interaction)
RETURN i
""")
objectIn: [Interaction] @cypher(statement: """
MATCH(this:Entity)-[:PARTICIPATED_IN { subject: false }]->(i:Interaction)
RETURN i
""")
participantIn: [Interaction] @cypher(statement: """
MATCH(this:Entity)-[:PARTICIPATED_IN]->(i:Interaction)
RETURN i
""")
}
type Person implements Entity {
name: String!
# ... other Person fields ...
}
type Place implements Entity {
name: String!
# ... other Person fields ...
}
If I seed the DB with this data:
MERGE(a:Person:Entity { name: "Bob"})
MERGE(b:Place:Entity { name: "England"})
MERGE(i:Interaction { kind: "visited"})
MERGE (a)-[:PARTICIPATED_IN { subject: true }]->(i)
MERGE (b)-[:PARTICIPATED_IN { subject: false }]->(i)
RETURN *;
The following query fails:
query {
Person {
name
subjectIn {
kind
objects {
name
}
}
}
}
With the error:
"Variable `undefined` not defined (line 1, column 44 (offset: 43))\n\"MATCH (`person`:`Person`) RETURN `person` {undefined} AS `person`\"\n
I actually wonder if this is another intance of a bug I (and others) have reported on github:
- Potential bug adding {undefined} to @cypher final return clause · Issue #443 · neo4j-graphql/neo4j-graphql-js · GitHub
- Custom Mutation Response · Issue #444 · neo4j-graphql/neo4j-graphql-js · GitHub
Do you think my above GraphQL schema and query should work? (in which case this is a bug in neo4j-graphql-js
, or am I missunderstanding something about how this should work?