Neo4j 带有@cypher schema指令的自定义解析器不接受日期作为输入-GRANDStack

Neo4j 带有@cypher schema指令的自定义解析器不接受日期作为输入-GRANDStack,neo4j,graphql,grandstack,neo4j-graphql-js,Neo4j,Graphql,Grandstack,Neo4j Graphql Js,我正在尝试将自定义解析程序添加到我的grand stack应用程序中。在那里,我将DateInput传递给我的变体时出错 这是我的模式: type Registration @hasRole(roles: [admin]) { registrationId: ID! startDate: Date! endDate: Date } type Mutation { CreateRegistration(startDate: Date!, endDate: Date): Registra

我正在尝试将自定义解析程序添加到我的grand stack应用程序中。在那里,我将DateInput传递给我的变体时出错

这是我的模式:

type Registration @hasRole(roles: [admin]) {
  registrationId: ID!
  startDate: Date!
  endDate: Date
}
type Mutation {
CreateRegistration(startDate: Date!, endDate: Date): Registration
    @cypher(
      statement: """
      CREATE (registration: Registration {
                              registrationId: apoc.create.uuid(),
                              startDate: $startDate,
                              endDate: $endDate
                            })
      RETURN registration
      """
    )
}
这是我的变种,我在GraphQL游乐场中使用:

mutation CreateRegistration {
  CreateRegistration(
    startDate: { year: 2020, month: 3, day: 22 }
    endDate: { year: 2020, month: 4, day: 12 }
  ) {
    registrationId
    startDate {
      formatted
    }
  }
}
这是由
neo4j-graphql
包自动生成的突变:

20:49:51 api | 2020-11-29T19:49:51.949Z neo4j-graphql-js CALL apoc.cypher.doIt("CREATE (registration: Registration {registrationId: apoc.create.uuid(), startDate: $startDate, endDate: $endDate})
20:49:51 api | RETURN registration", {startDate:$startDate, endDate:$endDate, first:$first, offset:$offset}) YIELD value
20:49:51 api |     WITH apoc.map.values(value, [keys(value)[0]])[0] AS `registration`
20:49:51 api |     RETURN `registration` { .registrationId ,startDate: { formatted: toString(`registration`.startDate) }} AS `registration`
20:49:51 api | 2020-11-29T19:49:51.949Z neo4j-graphql-js {
20:49:51 api |   "startDate": {
20:49:51 api |     "year": 2020,
20:49:51 api |     "month": 3,
20:49:51 api |     "day": 22
20:49:51 api |   },
20:49:51 api |   "endDate": {
20:49:51 api |     "year": 2020,
20:49:51 api |     "month": 4,
20:49:51 api |     "day": 12
20:49:51 api |   },
20:49:51 api |   "first": -1,
20:49:51 api |   "offset": 0
20:49:51 api | }
这是我得到的错误回复:

{
  "errors": [
    {
      "message": "Failed to invoke procedure `apoc.cypher.doIt`: Caused by: org.neo4j.exceptions.CypherTypeException: Property values can only be of primitive types or arrays thereof",
当我只使用不带@cypher的自动生成解析器时,它可以完美地工作

我的日期对象的输入值似乎有问题。当我完全删除日期时,它也会起作用

有人有什么建议吗,我做错了什么


THX

问题在于,您正在将对象作为neo4j不支持的
startDate
endDate
属性的值传递

例如,您可以使用该函数将对象转换为合适的类型:

type Mutation {
CreateRegistration(startDate: Date!, endDate: Date): Registration
    @cypher(
      statement: """
      CREATE (registration: Registration {
                              registrationId: apoc.create.uuid(),
                              startDate: date($startDate),
                              endDate: date($endDate)
                            })
      RETURN registration
      """
    )
}
当我使用“格式化”版本时,它会起作用:

如果突变必须是:

mutation CreateRegistration {
  CreateRegistration(
    startDate: { formatted: "2020-3-22" }
    endDate: { formatted: "2020-6-22" }
  ) {
    registrationId
    startDate {
      formatted
    }
  }
}

我也尝试过这个解决方案,但不幸的是,它并没有解决问题。当我使用您的方法时,我得到以下错误:
“errors”:[{“message”:“调用过程apoc.cypher.doIt失败:原因:java.lang.IllegalArgumentException:year必须是整数值,但却是一个DoubleValue”,
mutation CreateRegistration {
  CreateRegistration(
    startDate: { formatted: "2020-3-22" }
    endDate: { formatted: "2020-6-22" }
  ) {
    registrationId
    startDate {
      formatted
    }
  }
}