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

Neo4jError: Variable <propertyName>Count not defined #5080

Closed
afreakk opened this issue May 6, 2024 · 5 comments · Fixed by #5147
Closed

Neo4jError: Variable <propertyName>Count not defined #5080

afreakk opened this issue May 6, 2024 · 5 comments · Fixed by #5147
Assignees
Labels
bug report Something isn't working confirmed Confirmed bug
Projects

Comments

@afreakk
Copy link

afreakk commented May 6, 2024

Describe the bug
When trying to mutate a type with @authorization through a @cypher like:

type Mutation {
    deleteCar(input: DeleteCarInput!): DeletedCar!
        @cypher(
            statement: """
            MATCH(s:Car)
            WHERE (s.id = $input.carId)
            REMOVE s:Car
            SET s:DeletedCar
            SET s.reason = $input.reason
            RETURN s AS s
            """
            columnName: "s"
        )
}

I get error like:

"Neo4jError: Variable \`ownerCount\` not defined (line 11, column 69 (offset: 240))"

Type definitions

type JWT @jwt {
    id: String
}
type User @authorization(filter: [{ where: { node: { userId: "$jwt.id" } } }]) {
    userId: String! @unique
    adminAccess: [Tenant!]!
        @relationship(type: "ADMIN_IN", direction: OUT, aggregate: false)
}

type Tenant
    @authorization(
        validate: [{ where: { node: { admins: { userId: "$jwt.id" } } } }]
    ) {
    id: ID! @id
    admins: [User!]!
        @relationship(type: "ADMIN_IN", direction: IN, aggregate: false)
    deletedCars: [DeletedCar!]!
        @relationship(type: "OWNED_BY", direction: IN, aggregate: false)
    cars: [Car!]!
        @relationship(type: "OWNED_BY", direction: IN, aggregate: false)
}

input DeleteCarInput {
    carId: ID!
    reason: String!
}
type Mutation {
    deleteCar(input: DeleteCarInput!): DeletedCar!
        @cypher(
            statement: """
            MATCH(s:Car)
            WHERE (s.id = $input.carId)
            REMOVE s:Car
            SET s:DeletedCar
            SET s.reason = $input.reason
            RETURN s AS s
            """
            columnName: "s"
        )
}

type Car
    @mutation(operations: [UPDATE])
    @authorization(
        validate: [
            { where: { node: { owner: { admins: { userId: "$jwt.id" } } } } }
        ]
    ) {
    id: ID! @id
    owner: Tenant!
        @relationship(type: "OWNED_BY", direction: OUT, aggregate: false)
    name: String!
    createdAt: DateTime! @timestamp(operations: [CREATE])
    updatedAt: DateTime! @timestamp(operations: [CREATE, UPDATE])
    updatedBy: String
        @populatedBy(
            callback: "getUserIDFromContext"
            operations: [CREATE, UPDATE]
        )
}

type DeletedCar
    @mutation(operations: [UPDATE])
    @authorization(
        validate: [
            { where: { node: { owner: { admins: { userId: "$jwt.id" } } } } }
        ]
    ) {
    id: ID! @id
    owner: Tenant!
        @relationship(type: "OWNED_BY", direction: OUT, aggregate: false)
    name: String!
    reason: String!
    createdAt: DateTime! @timestamp(operations: [CREATE])
    updatedAt: DateTime! @timestamp(operations: [CREATE, UPDATE])
    updatedBy: String
        @populatedBy(
            callback: "getUserIDFromContext"
            operations: [CREATE, UPDATE]
        )
}

extend schema @authentication @query(read: true, aggregate: false)

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/afreakk/n4j-issue.git
  2. cd n4j-issue/
  3. git checkout cypher-issue
  4. yarn
  5. ./test.sh watch-test
  6. see error

Expected behavior
No error

System (please complete the following information):

  • OS: linux
  • Version: @neo4j/graphql@5.3.2
  • Node.js version: 20.11.1
@afreakk afreakk added the bug report Something isn't working label May 6, 2024
@neo4j-team-graphql neo4j-team-graphql added this to Bug reports in Bug Triage May 6, 2024
@neo4j-team-graphql
Copy link
Collaborator

Many thanks for raising this bug report @afreakk. 🐛 We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

  • Type definitions
  • Resolvers
  • Query and/or Mutation (or multiple) needed to reproduce

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! 🙏

@neo4j neo4j deleted a comment from angrykoala May 7, 2024
@angrykoala
Copy link
Member

Hi @afreakk
This bug looks similar to the one fixed in 5.3.5. Would you mind checking if the bug still happens in the latest version of @neo4j/graphql?

@afreakk
Copy link
Author

afreakk commented May 7, 2024

Hi @afreakk This bug looks similar to the one fixed in 5.3.5. Would you mind checking if the bug still happens in the latest version of @neo4j/graphql?

afreakk/n4j-issue@c733817
I just tested here, but no, still the same error

@angrykoala
Copy link
Member

Thanks @afreakk
I'll take a look at this

@angrykoala angrykoala added the confirmed Confirmed bug label May 8, 2024
@neo4j-team-graphql
Copy link
Collaborator

We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @afreakk! 🙏 We will now prioritise the bug and address it appropriately.

@neo4j-team-graphql neo4j-team-graphql moved this from Bug reports to Confirmed in Bug Triage May 8, 2024
angrykoala added a commit that referenced this issue May 8, 2024
@darrellwarde darrellwarde moved this from Confirmed to Medium priority in Bug Triage May 14, 2024
@MacondoExpress MacondoExpress moved this from Medium priority to In progress in Bug Triage May 21, 2024
@MacondoExpress MacondoExpress moved this from In progress to In review in Bug Triage May 21, 2024
@MacondoExpress MacondoExpress self-assigned this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something isn't working confirmed Confirmed bug
Projects
Bug Triage
In review
4 participants