我已经创建了一个neo4j graphql,它执行CRUD操作并试图实现突变,但是我收到了这个错误,不知道为什么会发生这种情况。
我没有遇到任何问题,实现这个页面的突变。但是当我尝试我自己的例子时,我得到了这个错误,并且无法解决它。
{
"errors": [
{
"message": "Invalid input 'on': expected\n \"*\"\n \"]\"\n \"{\"\n \"|\"\n a parameter (line 11, column 26 (offset: 360))\n\"MERGE (this0)-[:Activity on]->(this0_activityonDisease0_node)\"\n ^",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createUsers"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "Neo.ClientError.Statement.SyntaxError",
"name": "Neo4jError",
"stacktrace": [
"Neo4jError: Invalid input 'on': expected",
" \"*\"",
" \"]\"",
" \"{\"",
" \"|\"",
" a parameter (line 11, column 26 (offset: 360))",
"\"MERGE (this0)-[:Activity on]->(this0_activityonDisease0_node)\"",
" ^",
"",
" at captureStacktrace (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\result.js:239:17)",
" at new Result (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\result.js:59:23)",
" at newCompletedResult (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:433:12)",
" at Object.run (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:287:20)",
" at Transaction.run (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:137:34)",
" at execute (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\@neo4j\\graphql\\dist\\utils\\execute.js:87:51)",
" at resolve (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\@neo4j\\graphql\\dist\\schema\\resolvers\\mutation\\create.js:34:57)",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
}
}
}
],
"data": null
}下面给出了我使用的type definitions和mutations。
const typeDefs = gql`
type Disease {
name: String
medication: String
period: String
userActivityon: User @relationship(type: "Activity on", direction: IN)
}
type User {
name: String
age: Int
sex: String
weight: Int
smoking: Boolean
drinking: Boolean
nationality: String
birth_type: String
activityonDisease: Disease @relationship(type: "Activity on", direction: OUT)
}
`;mutation{
createUsers(input: {
name:"harsha"
age:22
sex:"male"
activityonDisease:{create:{node:{
name:"cold"
medication:"months"
}}}
}) {
users {
name
age
activityonDisease {
name
medication
}
}
}
}有人能指出我做错了什么吗?
发布于 2022-07-08 18:27:36
您正在为relationship type提供空格分隔的单词,如下所示:
@relationship(type: "Activity on", direction: IN)
@relationship(type: "Activity on", direction: OUT)这导致了错误。如果您想对一个relationship type使用多个单词,用下划线分隔它们,并保留所有的字母大写,这是推荐的方法。在任何定义关系的地方,都可以这样做:
@relationship(type: "ACTIVITY_ON", direction: IN)
@relationship(type: "ACTIVITY_ON", direction: OUT)https://stackoverflow.com/questions/72908208
复制相似问题