Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-05-2022 09:42 PM
I'm using the Neo4j GraphQL library and I'm new at this. I successfully created a schema and some nodes of type event
. The event
nodes have a field called startTime
which is defined as a DateTime in my schema:
type Event {
id: ID! @id
title: String!
startTime: DateTime!
When I run a mutation to create the events, they are successfully created. But when I query the events, it breaks, but only when the startTime is included in the response. With this query
query {
events{
id
title
startTime
}
}
I get this error:
{
"errors": [
{
"message": "Unknown function 'apoc.date.convertFormat' (line 2, column 34 (offset: 52))\n\"RETURN this{.title, startTime: apoc.date.convertFormat(toString(this.startTime), \"iso_zoned_date_time\", \"iso_offset_date_time\")} AS this\"\n
The mutation I had previously used to create the node was like this:
mutation {
createEvents(input: [
{
title: "New Year's Eve Block Party at Hance Park2",
startTime: "2021-12-31T02:21:37.146Z",
...
It looks like there is something wrong with the format that I used to create the title string. I saw some docs about creating the date as an object, but that format was invalid as well. How do I create the DateTime correctly in the mutation?
Solved! Go to Solution.
02-07-2022 12:05 PM
OK, the problem was that I missed the database requirements and I didn't understand that APOC is a database plugin.
The solution is here: https://github.com/neo4j/graphql/issues/941#issuecomment-1031856171
I've suggested docs changes to clarify this:
02-06-2022 12:20 AM
I think extra field timezone should be added as far as Event Data model is concerned.
02-06-2022 09:46 AM
Have you installed the APOC library?
02-06-2022 05:21 PM
Have you installed the APOC library?
I tried installing it, with no effect. The error says it is an internal server error so I figured there must be something wrong with the input.
I think extra field timezone should be added
Do you have an example of that? I couldn't find an example in the documentation where you create a DateTime on a node along with the timezone in a separate field. I thought the timezone wouldn't have to be in a separate field because it is encoded in the Javascript date string.
I'm following these introductory docs. Getting Started - Neo4j GraphQL Library I made a simpler example and still got the error. I started with a Movie type in that tutorial and then added a startTime field to it:
type Movie {
title: String
actors: [Actor] @relationship(type: "ACTED_IN", direction: IN)
startTime: DateTime
}
When creating a movie with a startTime, the movie is created successfully:
mutation {
createMovies (input: {
title: "Test2"
startTime: "2022-02-07T01:13:43.342Z"
}){
movies {
title
}
}
}
But then when querying the movie it gives a similar error (it works if I don't include startTime
in the query):
query Query {
movies {
title
startTime
}
}
The full error is:
{
"errors": [
{
"message": "Unknown function 'apoc.date.convertFormat' (line 2, column 34 (offset: 52))\n\"RETURN this{.title, startTime: apoc.date.convertFormat(toString(this.startTime), \"iso_zoned_date_time\", \"iso_offset_date_time\")} AS this\"\n ^",
"locations": [
{
"line": 2,
"column": 2
}
],
"path": [
"movies"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "Neo.ClientError.Statement.SyntaxError",
"name": "Neo4jError",
"stacktrace": [
"Neo4jError: Unknown function 'apoc.date.convertFormat' (line 2, column 34 (offset: 52))",
"\"RETURN this{.title, startTime: apoc.date.convertFormat(toString(this.startTime), \"iso_zoned_date_time\", \"iso_offset_date_time\")} AS this\"",
" ^",
"",
" at captureStacktrace (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/result.js:239:17)",
" at new Result (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/result.js:59:23)",
" at newCompletedResult (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/transaction.js:375:12)",
" at Object.run (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/transaction.js:229:20)",
" at Transaction.run (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/transaction.js:101:34)",
" at /Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/@neo4j/graphql/dist/utils/execute.js:66:104",
" at TransactionExecutor._safeExecuteTransactionWork (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:92:26)",
" at TransactionExecutor._executeTransactionInsidePromise (/Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:83:34)",
" at /Users/catherineluse/gennit-vue/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:40:19",
" at new Promise (<anonymous>)"
]
}
}
}
],
"data": null
}
My full code is:
This seems like a bug so I opened an issue to track it: https://github.com/neo4j/graphql/issues/941
02-07-2022 12:05 PM
OK, the problem was that I missed the database requirements and I didn't understand that APOC is a database plugin.
The solution is here: https://github.com/neo4j/graphql/issues/941#issuecomment-1031856171
I've suggested docs changes to clarify this:
All the sessions of the conference are now available online