Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graph 添加与属性的关系会中断其他查询_Graph_Neo4j_Cypher_Graphql_Grandstack - Fatal编程技术网

Graph 添加与属性的关系会中断其他查询

Graph 添加与属性的关系会中断其他查询,graph,neo4j,cypher,graphql,grandstack,Graph,Neo4j,Cypher,Graphql,Grandstack,我正在使用GRAND stack starter,最近升级了我的软件包和Neo4j数据库,以匹配GRAND starter工具包中确定的当前版本 这似乎打破了我最基本的疑问。我正在创建一个相当简单的演示数据库,用于包含配方的探索。我有一个节点,上面有一个配方,包括名称、说明和时间 此节点还具有关系,这些关系指示这顿饭的种类和难度。你可以在下面看到: 对于前端的查询或Graphql游乐场中的以下查询,返回的结果很好: query($searchQuery: String = "baked") {

我正在使用GRAND stack starter,最近升级了我的软件包和Neo4j数据库,以匹配GRAND starter工具包中确定的当前版本

这似乎打破了我最基本的疑问。我正在创建一个相当简单的演示数据库,用于包含配方的探索。我有一个节点,上面有一个配方,包括名称、说明和时间

此节点还具有关系,这些关系指示这顿饭的种类和难度。你可以在下面看到:

对于前端的查询或Graphql游乐场中的以下查询,返回的结果很好:

query($searchQuery: String = "baked") {
  RecipesBySubstring(searchQuery: $searchQuery) {
    name
    time
    instructions
    ingredients {
      name
      quantity
    }
    mealtype {
      type
    }
    difficulty {
      value
    }
  }
}
我的graphql-schema.js文件中的实际定义如下所示:

  RecipesBySubstring(searchQuery: String): [Recipe] @cypher(statement:
    "MATCH (r:Recipe) WHERE toLower(r.name) CONTAINS toLower($searchQuery) OR toLower(r.time) CONTAINS toLower($searchQuery) RETURN r ORDER BY r.name ASC")
但是,只要我尝试创建一个具有属性的关系,它就无法使用这些精确的查询返回任何结果。我创建了与此查询的关系:

MATCH (r:Recipe{name:"baked spaghetti"}),(i:Ingredient{name:"beef"})
CREATE (r)-[c:Contains{quantity:"1 pound"}]->(i)
RETURN r,i,c
它将其添加到数据库中

我还在graphql-schema.js中定义了我的成分,如下所示:

type Ingredient {
  name: String!
  quantity: String @cypher(statement:"MATCH (:Recipe)-[c:Contains]-(this) RETURN q.quantity")
  recipe: Recipe
}
{
  "data": {
    "RecipesBySubstring": null
  },
  "errors": [
    {
      "message": "Failed to invoke function `apoc.cypher.runFirstColumn`: Caused by: org.neo4j.cypher.internal.util.v3_4.SyntaxException: Variable `q` not defined (line 1, column 93 (offset: 92))",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "RecipesBySubstring"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.ClientError.Procedure.ProcedureCallFailed",
          "name": "Neo4jError",
          "stacktrace": [
            "Neo4jError: Failed to invoke function `apoc.cypher.runFirstColumn`: Caused by: org.neo4j.cypher.internal.util.v3_4.SyntaxException: Variable `q` not defined (line 1, column 93 (offset: 92))",
            "",
            "    at captureStacktrace (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\result.js:200:15)",
            "    at new Result (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\result.js:73:19)",
            "    at Session._run (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\session.js:116:14)",
            "    at Session.run (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\session.js:95:19)",
            "    at _callee$ (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-graphql-js\\dist\\index.js:80:28)",
            "    at tryCatch (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:62:40)",
            "    at Generator.invoke [as _invoke] (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:296:22)",
            "    at Generator.prototype.(anonymous function) [as next] (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:114:21)",
            "    at step (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\babel-runtime\\helpers\\asyncToGenerator.js:17:30)",
            "    at E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\babel-runtime\\helpers\\asyncToGenerator.js:35:14"
          ]
        }
      }
    }
  ]
}
在我升级之前,这些东西都很好用。我有多个食谱共享我可以查询的成分,查询一个食谱会返回所有需要的成分和数量。您可以在下图中看到数据库的上一次迭代,我可以确认它确实在graphql游乐场和我的前端中返回:

因此,我有点困惑可能发生了什么,或者如果有一种新的方式,我应该做这些事情。我可以退一步,但由于这是一个学习过程,我想让我的软件包和数据库保持最新,以应对这些挑战

尝试查询与属性有关系的节点时,GraphQL游乐场出现的完整错误如下所示:

type Ingredient {
  name: String!
  quantity: String @cypher(statement:"MATCH (:Recipe)-[c:Contains]-(this) RETURN q.quantity")
  recipe: Recipe
}
{
  "data": {
    "RecipesBySubstring": null
  },
  "errors": [
    {
      "message": "Failed to invoke function `apoc.cypher.runFirstColumn`: Caused by: org.neo4j.cypher.internal.util.v3_4.SyntaxException: Variable `q` not defined (line 1, column 93 (offset: 92))",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "RecipesBySubstring"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.ClientError.Procedure.ProcedureCallFailed",
          "name": "Neo4jError",
          "stacktrace": [
            "Neo4jError: Failed to invoke function `apoc.cypher.runFirstColumn`: Caused by: org.neo4j.cypher.internal.util.v3_4.SyntaxException: Variable `q` not defined (line 1, column 93 (offset: 92))",
            "",
            "    at captureStacktrace (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\result.js:200:15)",
            "    at new Result (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\result.js:73:19)",
            "    at Session._run (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\session.js:116:14)",
            "    at Session.run (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-driver\\lib\\v1\\session.js:95:19)",
            "    at _callee$ (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\neo4j-graphql-js\\dist\\index.js:80:28)",
            "    at tryCatch (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:62:40)",
            "    at Generator.invoke [as _invoke] (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:296:22)",
            "    at Generator.prototype.(anonymous function) [as next] (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\regenerator-runtime\\runtime.js:114:21)",
            "    at step (E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\babel-runtime\\helpers\\asyncToGenerator.js:17:30)",
            "    at E:\\Recipe Snap\\grand-stack-starter\\api\\node_modules\\babel-runtime\\helpers\\asyncToGenerator.js:35:14"
          ]
        }
      }
    }
  ]
}

该错误是一个密码语法错误。GraphQL架构定义中的
@cypher
指令中对
成分.quantity
使用的查询不正确,它引用的是尚未定义的变量
q
。由于
quantity
Contains
关系上的一个属性,并且您的查询将
c
绑定到该关系,因此您的
@cypher
指令查询应该是

quantity: String @cypher(statement:"MATCH (:Recipe)-[c:Contains]-(this) RETURN c.quantity")

另外,的v1.0.1引入了更好的关系类型支持,因此您不必使用
@cypher
指令来访问关系属性,而只需定义关系类型:

错误是一个cypher语法错误。GraphQL架构定义中的
@cypher
指令中对
成分.quantity
使用的查询不正确,它引用的是尚未定义的变量
q
。由于
quantity
Contains
关系上的一个属性,并且您的查询将
c
绑定到该关系,因此您的
@cypher
指令查询应该是

quantity: String @cypher(statement:"MATCH (:Recipe)-[c:Contains]-(this) RETURN c.quantity")

此外,的v1.0.1引入了更好的关系类型支持,因此您不必使用
@cypher
指令来访问关系属性,相反,您可以只定义一种关系类型:

grandstack或neo4j日志中是否有任何具体错误/错误消息?当我尝试使用前端创建关系时,我得到“调用函数失败
apoc.cypher.runFirstColumn
”让我再次启动数据库,看看是否还有其他东西可以共享。我添加了有关我看到的完整错误堆栈的附加信息。
MATCH(:Recipe)-[c:Contains](这)返回q.quantity
我想这里有一个输入错误-应该有一个
c
而不是
q
-以及一条关于它的消息-
变量“q”未定义
…我的名为Contains的关系有一个名为quantity的属性,在这种情况下,我实际上想要返回这个属性。在更新之前,查询配方确实会返回与配方关系上的成分和数量。但是当我今晚回到家时,我会将graphql查询修改为更简单的查询,看看这是否是个问题。尽管最终我仍然需要获取relationship属性值。grandstack或neo4j日志中是否有任何具体错误/错误消息?当我尝试使用前端创建关系时,我得到“调用函数失败
apoc.cypher.runFirstColumn
”让我再次启动数据库,看看是否还有其他东西可以共享。我添加了有关我看到的完整错误堆栈的附加信息。
MATCH(:Recipe)-[c:Contains](这)返回q.quantity
我想这里有一个输入错误-应该有一个
c
而不是
q
-以及一条关于它的消息-
变量“q”未定义
…我的名为Contains的关系有一个名为quantity的属性,在这种情况下,我实际上想要返回这个属性。在更新之前,查询配方确实会返回与配方关系上的成分和数量。但是当我今晚回到家时,我会将graphql查询修改为更简单的查询,看看这是否是个问题。虽然最终我还是需要得到关系属性的值,这与stdob所说的完全一致。奇怪的是,我两天前才开始工作,但你和他都指出了这一点,这是有道理的。今晚我将重新制作并试用。您关于neo4j graphql js库1.0.1中的更改的链接也非常棒。我一直在运行一个更旧的版本,从我的第一次拉大发令。谢谢你提供的信息。这绝对符合stdob的说法。奇怪的是,我两天前才开始工作,但你和他都指出了这一点,这是有道理的。今晚我将重新制作并试用。您关于neo4j graphql js库1.0.1中的更改的链接也非常棒。我一直在跑步