Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.0 breaks custom cypher. #315

Closed
tlester opened this issue Jul 12, 2021 · 1 comment · Fixed by #318
Closed

1.1.0 breaks custom cypher. #315

tlester opened this issue Jul 12, 2021 · 1 comment · Fixed by #318
Labels
bug Something isn't working confirmed Confirmed bug

Comments

@tlester
Copy link

tlester commented Jul 12, 2021

Describe the bug
1.0.3 with double quotes works fine.
1.1.0 with escaped double quotes breaks.
1.1.0 with non-escaped single quotes breaks.
1.0.3 with non-escaped single quotes works fine.

type Query {
    getContent(userID: ID): [Content]
        @cypher(
            statement: """
            MATCH (myUser:User {id: $userID})
            OPTIONAL MATCH (myUser)<-[:HAS_USER]-(:Profile)-[:HAS_FRIEND]->(x)<-[:HAS_FRIEND]-(:Profile)-[:HAS_USER]->(myFriends:User)
            CALL {
                WITH myUser, myFriends
                MATCH (myFriends)-[:HAS_POST]->(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myFriends)-[:HAS_COMMENT]->(:Comment)<-[:HAS_COMMENT]-(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myFriends)-[:HAS_REACTION]->(:Reaction)<-[:HAS_REACTION]-(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myUser)<-[:HAS_USER]-(myProfile:Profile)
                MATCH (myProfile)-[:HAS_USER]->(myUsers:User)
                MATCH (myUsers)-[:HAS_POST]->(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myUser)<-[:HAS_USER]-(myProfile:Profile)
                MATCH (myProfile)-[:HAS_USER]->(myUsers:User)
                MATCH (myUsers)-[:HAS_COMMENT]->(:Comment)<-[:HAS_COMMENT]-(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myUser)<-[:HAS_USER]-(myProfile:Profile)
                MATCH (myProfile)-[:HAS_USER]->(myUsers:User)
                MATCH (myUsers)-[:HAS_REACTION]->(:Reaction)<-[:HAS_REACTION]-(post:Post)
                RETURN post
            }
            RETURN DISTINCT apoc.map.merge(properties(post), { __resolveType: 'Post' }) AS result ORDER BY result.modifiedDate DESC
            """
        )
}

In 1.0.3, the above cypher returns 80+ records on an account.
In 1.1.0 it always returns a single record.

Type definitions
See above.

To Reproduce
Run the cypher with quotes in 1.0.3. and verify that it returns many records.
Upgrade to 1.1.0 and either escape double quotes or use single quotes and it will return only one record.

Expected behavior
I expect the same records to be returned in 1.1.0 as in 1.0.3.

Screenshots
If applicable, add screenshots to help explain your problem.

@tlester tlester added bug Something isn't working inbox labels Jul 12, 2021
@darrellwarde
Copy link
Contributor

Reproduced using simpler example:

union Content = Post

type Post {
    content: String!
    modifiedDate: DateTime! @timestamp(operations: [CREATE, UPDATE])
}

type User {
    id: ID!
    friends: [User!]! @relationship(type: "HAS_FRIEND", direction: OUT)
    posts: [Post!]! @relationship(type: "HAS_POST", direction: OUT)
}

type Query {
    getContent(userID: ID): [Content]
        @cypher(
            statement: """
            MATCH (myUser:User {id: $userID})
            OPTIONAL MATCH (myUser)-[:HAS_FRIEND]->(myFriends:User)
            CALL {
                WITH myUser, myFriends
                MATCH (myUser)-[:HAS_POST]->(post:Post)
                RETURN post
                UNION
                WITH myUser, myFriends
                MATCH (myFriends)-[:HAS_POST]->(post:Post)
                RETURN post
            }
            RETURN DISTINCT apoc.map.merge(properties(post), { __resolveType: 'Post' }) AS result ORDER BY result.modifiedDate DESC
            """
        )
}

And I believe I've found the problem, should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants