You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
Hi, I want to satisfy a union type with a Map. Regular types can be satisfied with maps without any problem, but when a union is involved, an error Expected a Node, got: Map is thrown. I tested satisfying the union with an actual Node, which works as expected. In this example that won't work because the identifier properties in the DB have different names: one uses id for its identifier and one uses name, but when they come out of GraphQL, the identifier should be id in both cases, hence using a Map to rename them.
{
entities {
... on Person {
id
gender
}
... on Circuit {
id
size
}
}
}
Schema definition:
type Person {
id: ID!
type: String
gender: String
}
type Circuit {
id: ID!
type: String
size: Int
}
union Entity = Person | Circuit
type Query {
entities: [Entity] @cypher(
statement: """
MATCH (c:Circuit)
WITH COLLECT(DISTINCT {id: c.name, type: 'CIRCUIT', size: c.size}) AS circuitNodes
OPTIONAL MATCH (p:Person)
WITH COLLECT(DISTINCT {id: p.id, type: 'PERSON', gender: p.gender}) AS personNodes, circuitNodes
OPTIONAL MATCH (p:Person)-[:INVOLVED_IN]->(c:Circuit)
UNWIND personNodes + circuitNodes AS x
RETURN x
"""
)
}
Error that occurs:
{
"errors": [
{
"message": "Expected a Node, got: Map{gender -> String(\"M\"), type -> String(\"PERSON\"), id -> String(\"foo\")}",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"entities"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "Neo.ClientError.Statement.TypeError",
"name": "Neo4jError",
"stacktrace": [
"Neo4jError: Expected a Node, got: Map{gender -> String(\"M\"), type -> String(\"PERSON\"), id -> String(\"foo\")}",
"",
" at captureStacktrace (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-driver/lib/result.js:277:15)",
" at new Result (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-driver/lib/result.js:68:19)",
" at newCompletedResult (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-driver/lib/transaction.js:449:10)",
" at Object.run (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-driver/lib/transaction.js:287:14)",
" at Transaction.run (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-driver/lib/transaction.js:123:32)",
" at _callee2$ (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/neo4j-graphql-js/dist/index.js:222:35)",
" at tryCatch (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/regenerator-runtime/runtime.js:63:40)",
" at Generator.invoke [as _invoke] (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/regenerator-runtime/runtime.js:293:22)",
" at Generator.next (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/regenerator-runtime/runtime.js:118:21)",
" at asyncGeneratorStep (/home/amoe/dev/neo4j-graphql-js-return-aggregate-type/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)"
]
}
}
}
],
"data": {
"entities": null
}
}
Using version 2.19.2.
The text was updated successfully, but these errors were encountered:
Hi, I want to satisfy a
union
type with a Map. Regular types can be satisfied with maps without any problem, but when aunion
is involved, an errorExpected a Node, got: Map
is thrown. I tested satisfying the union with an actual Node, which works as expected. In this example that won't work because the identifier properties in the DB have different names: one usesid
for its identifier and one usesname
, but when they come out of GraphQL, the identifier should beid
in both cases, hence using aMap
to rename them.Sample data:
Sample query:
Schema definition:
Error that occurs:
Using version 2.19.2.
The text was updated successfully, but these errors were encountered: