首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >字段级密码语句在接受阿波罗服务器中的参数时不工作。

字段级密码语句在接受阿波罗服务器中的参数时不工作。
EN

Stack Overflow用户
提问于 2021-07-28 23:16:00
回答 1查看 77关注 0票数 0

字段级的cypher指令不像期望的那样工作。

最起码的例子:

代码语言:javascript
复制
type Question {
  id: ID! @id
  required: Boolean
  testing(someId: ID!): Boolean
    @cypher(statement: """
      MATCH (q:Question {id:$someId}) RETURN q.required
    """)
}

当运行下面的查询时,我会得到一个错误。

代码语言:javascript
复制
{
  Question {
    testing(someId: "12345678-1234-1234-1234-0123456789ab")
  }
}

这是在阿波罗游乐场中看到的错误日志:

{“错误”:[{“消息”:“无效输入‘_偏”:预期\n!=“\n "%"\n ""\n "+"\n ",“n”-“n "."\n”/“n ":"\n "<"\n "<="\n "\n”<>“”n“=”n“=”n ">"\n ">="\n“和”n“中包含”\n“结尾的”\n“是”\n“或”n“开头的”异或“N "^"\n }“(第1行,第195列(偏移量:194)\n“MATCH (questionQuestion)返回question {this: apoc.cypher.runFirstColumn("MATCH (q:Question {id:$偏定})返回q.required",{this:q.required,cypherParams:$cypherParams,someId:$1_someId},false)} AS question__"\n ^“、”位置“:{”行“:2、”列“:3}、”路径“:”问题“、”扩展“:{”代码“:"INTERNAL_SERVER_ERROR”、“异常”:{“代码”:"Neo.ClientError.Statement.SyntaxError“、”名称“:"Neo4jError”、“堆栈跟踪”:[ "Neo4jError:无效输入'_someId':expected“、”!=“、”%“、“、”+“、”<“、”<=“、”<>“、”=“、”=“、”>“、”>=“、”>=“、”和“、”包含",“结束”、“在”、“或”、“开始”、“异或”、“[”、“^”、"}“(第1行,第195列(偏移:194))、”匹配(questionQuestion)返回question {testing: apoc.cypher.runFirstColumn(“Q:问题{id:$id})返回q.required",{这:问题,cypherParams:$cypherParams,someId:$1_someId},false)} AS question“,”^",":",“at captureStacktrace (/home/m1/citizentric/grand-housing/node_modules/neo4j-driver-core/lib/result.js:239:17)",”at new Result (/home/m1/citizentric/grand-housing/node_modules/neo4j-driver-core/lib/result.js:59:23)",“at newCompletedResult (/home/m1/citizentric/grand-housing/node_modules/neo4j-driver-core/lib/transaction.js:372:12)",”“at Object.run (/home/m1/citizentric/grand-housing/node_modules/neo4j-driver-core/lib/transaction.js:226:20)",”at Transaction.run (/home/m1/citizentric/grand-housing/node_modules/neo4j-driver-core/lib/transaction.js:98:34)",at _callee3$ (/home/m1/citizentric/grand-housing/node_modules/neo4j-graphql-js/dist/index.js:226:35)",“at tryCatch (/home/m1/citizentric/grand-housing/node_modules/regenerator-runtime/runtime.js:63:40)",”at Generator.invoke 调用,“at Generator.next (/home/m1/citizentric/grand-housing/node_modules/regenerator-runtime/runtime.js:118:21)",”at asyncGeneratorStep (/home/m1/citizentric/grand-housing/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator/index.js:5:24)",“at (/home/m1/citizentric/grand-housing/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator/index.js:27:9)",at _next _next”at /home/m1/citizentric/grand-housing/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator/index.js:34:7",“at新承诺()",“在新F (/home/m1/citizentric/grand-housing/node_modules/@babel/runtime-corejs2/node_modules/core-js/library/modules/_export.js:36:28)",”在/home/m1/citizentric/grand-housing/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator/index.js:23:12",“at /home/m1/citizentric/grand-housing/node_modules/neo4j-graphql-js/dist/index.js:241:30”]}} ],“数据”:{“问题”:null }

我的package.json包括以下版本:

代码语言:javascript
复制
"apollo-server": "^2.25.0",
"apollo-server-core": "^2.25.0",
"graphql-tag": "^2.12.5",
"neo4j-driver": "^4.3.1",
"neo4j-graphql-js": "^2.19.2",

顶级查询(带有参数)和带密码装饰器的字段级查询工作良好,只要这些查询不接受参数。我当时的印象是,这件事以前起过作用。

EN

回答 1

Stack Overflow用户

发布于 2021-07-31 21:22:59

除非创建突变,否则库"neo4j-graphql-js": "^2.19.2"似乎不会传递自定义参数。尝试以下方法:

代码语言:javascript
复制
type Question {
  id: ID! @id
  required: Boolean
}

extend type Mutation {
  testing(someId: ID!): Boolean
    @cypher(
      statement: """
      MATCH (q:Question {id: $someId}) RETURN q.required
      """
    )
}
代码语言:javascript
复制
mutation {
  testing (someId: "12345678-1234-1234-1234-0123456789ab") 
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68568327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档