【发布时间】:2019-03-22 21:14:15
【问题描述】:
我正在尝试在我的 Neo4j 数据库中创建一个带有 GraphQL 突变的关系。除了这个引起问题的突变之外,我还有许多其他突变已经起作用。它看起来像这样:
mutation(
$id: String!,
$recipe: String!,
$date: String!
) {
CreateUserRecipeRelation(id:$id, recipe:$recipe, date:$date) {
id
recipe {
name
}
}
}
我正在传递以下一组参数:
{"id": "google-oauth2|yyyyremovedauthstuffyyyy", "recipe": "baked spaghetti", "date": "10/10/2018"}
但 GraphQL 操场抛出以下错误:
“未提供所需类型 \"String!\" 的变量 \"$id\"。”
在我的 schema.graphql 文件中,我定义了以下内容:
CreateUserRecipeRelation (
id: String
recipe: String
date: String
): User @cypher(statement:
"MATCH (r:Recipe{name:$recipe}), (u:User{id:$id}) CREATE (r)-[c:Created_By{date:$date}]->(u) RETURN r,c,u")
如果我直接在 Neo4j 中运行该密码查询,它就可以正常工作。在同一个项目中,我有 5 或 6 个其他创建关系的突变目前正在工作,但这个让我停下来。
更新:
这是我目前正在工作的突变,因此您可以看到结构上的相似性:
CreateIngredientRelation (
name: String
recipe: String
quantity: String
): Ingredient @cypher(statement:
"MATCH (r:Recipe{name:$recipe}), (i:Ingredient{name:$name}) CREATE (r)-[c:Contains{quantity:$quantity}]->(i) RETURN r,c,i")
这个效果很好,并与附加到它们的数量建立了大量的关系。这就是我感到困惑的原因。如果它们都不起作用,那么尝试提出我认为的解决方案会更容易。
【问题讨论】:
-
没有跟进你是如何解决这个问题的,如果你这样做了?
-
你知道,我不记得我是否解决了它。我想我做到了。今晚让我检查一下我的存储库,看看我做了哪些修复,我会告诉你的。