Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

"Cannot read property 'value' of undefined" when attempting to access a Neo4jDateTime on a relationship type #561

Open
mlars84 opened this issue Dec 23, 2020 · 5 comments

Comments

@mlars84
Copy link

mlars84 commented Dec 23, 2020

I'm using the GRANDstack and when attempting to access a formatted Neo4j datetime on a relationship type I am running into this TypeError:

[
  TypeError: Cannot read property 'value' of undefined
      at getRelationTypeDirective (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/utils.js:709:7)
      at buildCypherSelection (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/selections.js:309:68)
      at recurse (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/selections.js:97:33)
      at buildCypherSelection (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/selections.js:545:17)
      at recurse (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/selections.js:97:33)
      at buildCypherSelection (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/selections.js:545:17)
      at customQuery (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/translate.js:993:68)
      at translateQuery (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/translate.js:828:24)
      at cypherQuery (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/index.js:277:40)
      at _callee3$ (/Users/matthewlarson/Projects/carebear_backend/node_modules/neo4j-graphql-js/dist/index.js:105:31) {
    message: "Cannot read property 'value' of undefined",
    locations: [ [Object] ],
    path: [ 'GetNotificationsByUser' ]
  }
]

Here is GetNotificationsByUser:

GetNotificationsByUser(userId: ID!): Notification
    @cypher(
        statement: """
            MATCH (u:User {id: $userId})<-[rel:NOTIFIES]-(n)
            RETURN rel
    """)

and the Notification relationship type:

type Notification @relation(name: "NOTIFIES") {
    to: User
    body: String!
    notificationType: NotificationType!
    createdAt: DateTime!
    updatedAt: DateTime!
}

The userId I am querying with has one "notification" and this is what rel returns in Neo4j:

{
  "identity": 636,
  "start": 249,
  "end": 1,
  "type": "NOTIFIES",
  "properties": {
"createdAt": "2020-12-22T19:57:48.433000000Z",
"notificationType": "POST_MENTION",
"body": "og mentioned you in a thread",
"updatedAt": "2020-12-22T19:57:48.433000000Z"
  }
}

The createdAt property looks the same as any other NeojDateTime and GetNotificationsByUser returns just fine when leaving off createdAt. Example GraphQL query:

query GetNotificationsByUser($userId: ID!) {
  GetNotificationsByUser(userId: $userId) {
    notificationType,
    body,
    createdAt {
      formatted
    }
  }
}
@AdrienLemaire
Copy link
Contributor

AdrienLemaire commented Dec 24, 2020

Are you sure your createdAt date is a datetime object and not a string ? Asking because you didn't share your mutation, although you probably meant that with The createdAt property looks the same as any other NeojDateTime

When visualizing on neo4j desktop, a datetime object would be highlighted in gray.

@dvision1979
Copy link

@mlars84 hello. Did you fix your issue, If so, could you please share the solution?
Thank you.

@mlars84
Copy link
Author

mlars84 commented Jan 12, 2021

@AdrienLemaire - It's definitely a datetime object. @danionescu2007 - Sadly I opted to create the Notification as a node rather than a relationship to avoid this issue. That works fine, I'm now just creating one extra unnecessary relationship.

@dvision1979
Copy link

thanks for your reply @mlars84 , I appreciate it.

@michaeldgraham
Copy link
Collaborator

#608

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants