I`m trying to add custom resolvers to my grand stack app. There I get an error while passing DateInput to my mutation.
This is my 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
"""
)
}
This is my mutation, I use in the GraphQL playground:
mutation CreateRegistration {
CreateRegistration(
startDate: { year: 2020, month: 3, day: 22 }
endDate: { year: 2020, month: 4, day: 12 }
) {
registrationId
startDate {
formatted
}
}
}
this is the automated generated mutation by neo4j-graphql
package:
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 | }
this is the errorresponse I get back:
{
"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",
When I just use the autogenerated Resolver without @cypher, it works perfectly.
It looks like it is a problem with the input value for my date object. When I remove the date completely, it also works.
Does anybody have a suggestion, what I am doing wrong?
THX