Hey, I need some help. I have some trouble with the _Neo4JDateInput field.
schema:
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
"""
)
}
mutation in graphql playground:
mutation CreateRegistration {
CreateRegistration(
startDate: { year: 2020, month: 3, day: 22 }
endDate: { year: 2020, month: 4, day: 12 }
) {
registrationId
startDate {
formatted
}
}
}
resolver:
CreateRegistration: (parent, args, context, info) => {
// Fill in the custom logic
return neo4jgraphql(parent, args, context, info)
},
the autogenerated query is:
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 | }
The problem is, as soon as I create the custom mutation, I got an error because of the Date type.
The error:
{
"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",
I tried to just use the autogenerated mutation CreateRegistration which worked perfectly. As soon as I add the @cypher
directive, the Date
Input stops working.
The problem is, I have to use custom Resolvers where I need to add a Date, example for User Registration.
Thx for your help.