neo4j-graphql / neo4j-graphql-js

NOTE: This project is no longer actively maintained. Please consider using the official Neo4j GraphQL Library (linked in README).
Other
609 stars 147 forks source link

Query on Date @cypher field returns error #430

Open alexluna7 opened 4 years ago

alexluna7 commented 4 years ago

I have the following GraphQL schema: type DateTest { dateField: Date dateCypher: Date @cypher(statement: "MATCH (this) RETURN this.dateField") }

1 - I run this mutation: mutation { CreateDateTest(dateField:{year:1970, month:7, day:24}){ dateField{ formatted } } }

and get this result: { "data": { "CreateDateTest": { "dateField": { "formatted": "1970-07-24" } } } }

So far, so good.

2 - I run this query: { DateTest{ dateField { year month day } } }

and get this result: { "data": { "DateTest": [ { "dateField": { "year": 1970, "month": 7, "day": 24 } } ] } }

So far, so good.

3 - I run this query: { DateTest{ dateCypher { year month day } } }

and get this result: { "errors": [ { "message": "1970-07-24 (of class org.neo4j.values.storable.DateValue)", "locations": [ { "line": 2, "column": 3 } ], "path": [ "DateTest" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "code": "Neo.DatabaseError.General.UnknownError", "name": "Neo4jError", "stacktrace": [ "Neo4jError: 1970-07-24 (of class org.neo4j.values.storable.DateValue)", "", " at captureStacktrace (/home/app/node_modules/neo4j-driver/lib/result.js:263:15)", " at new Result (/home/app/node_modules/neo4j-driver/lib/result.js:68:19)", " at newCompletedResult (/home/app/node_modules/neo4j-driver/lib/transaction.js:449:10)", " at Object.run (/home/app/node_modules/neo4j-driver/lib/transaction.js:287:14)", " at Transaction.run (/home/app/node_modules/neo4j-driver/lib/transaction.js:123:32)", " at /home/app/node_modules/neo4j-graphql-js/dist/index.js:134:25", " at TransactionExecutor._safeExecuteTransactionWork (/home/app/node_modules/neo4j-driver/lib/internal/transaction-executor.js:134:22)", " at TransactionExecutor._executeTransactionInsidePromise (/home/app/node_modules/neo4j-driver/lib/internal/transaction-executor.js:122:32)", " at /home/app/node_modules/neo4j-driver/lib/internal/transaction-executor.js:61:15", " at new Promise (<anonymous>)" ] } } } ], "data": { "DateTest": null } }

and the neo4j console shows this message:

2020-05-07 18:45:36.062+0000 ERROR Client triggered an unexpected error [Neo.DatabaseError.General.UnknownError]: 1970-07-24 (of class org.neo4j.values.storable.DateValue), reference 56c5f190-ba20-4efe-bbe2-b498e6fe8ccf.

Update: I have the debug.log output for that error, if anyone needs it.

Why i am getting an error in example 3 when the returned data is exactly the same as in example 2? Is this a bug or am I doing something wrong?

alexluna7 commented 4 years ago

I'm using neo4j 4.0.4 with APOC plugin 4.0.0.10 under Docker.

Update: I have just updated to APOC plugin 4.0.0.11 and the issue still happens.

alexluna7 commented 4 years ago

From the cypher-shell:

` neo4j@neo4j> MATCH (n:DateTest) return n; +-------------------------------------+ | n | +-------------------------------------+ | (:DateTest {dateField: 1970-07-24}) | +-------------------------------------+

1 row available after 108 ms, consumed after another 11 ms `

` neo4j@neo4j> MATCH (n:DateTest) with n.dateField as d return d as date, d.year as year, d.month as month, d.day as day; +---------------------------------+ | date | year | month | day | +---------------------------------+ | 1970-07-24 | 1970 | 7 | 24 | +---------------------------------+

1 row available after 419 ms, consumed after another 15 ms `

alexluna7 commented 4 years ago

To give you background about why I'm using @cypher where it isn't needed, my real schema need is a query field like the following:

birthdate: Date @cypher( statement: "MATCH (this)-[:HAS_READING]->(r:Reading)-[:READING_OF]->(:Version)-[:VERSION_OF]->(:Unique {id:'birthdate'}) RETURN r.value" )

michaeldgraham commented 3 years ago

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608