Skip to content

Variable this0 not defined on create with authorization #6797

@angrykoala

Description

@angrykoala

Given a schema with authorization in create operations:

type Group @node {
    id: ID! @id
    name: String!
    invitees: [Invitee!]! @relationship(type: "INVITED_TO", direction: IN, aggregate: true)
}

enum InviteeStatus {
    PENDING
    ACCEPTED
}

type Invitee
    @node
    @authorization(
        validate: [
            { operations: [CREATE], where: { node: { group_SINGLE: { inviteesAggregate: { count_LT: 5 } } } } }
        ]
    ) {
    id: ID! @id
    group: [Group!]! @relationship(type: "INVITED_TO", direction: OUT)
    email: String!
    status: InviteeStatus! @default(value: PENDING)
}

And a query with a nested create and connect:

mutation CreateGroups {
  createGroups(
    input: [
      {
        name: "My Name"
        invitees: {
          create: [
            {
              node: {
                email: "an email"
                group: { connect: [{ where: { node: { id_EQ: "id" } } }] }
              }
            }
          ]
        }
      }
    ]
  ) {
    groups {
      invitees {
        email
      }
    }
  }
}

The following Cypher is invalid with the error: Neo4jError: Variable this0 not defined (line 30, column 12 (offset: 821)):

CYPHER 5
CALL {
    CREATE (this0:Group)
    SET
        this0.id = randomUUID(),
        this0.name = $param0
    WITH *
    CREATE (this1:Invitee)
    WITH *
    CALL (this1) {
        MATCH (this2:Group)
        WHERE this2.id = $param1
        CREATE (this1)-[this3:INVITED_TO]->(this2)
    }
    MERGE (this0)<-[this4:INVITED_TO]-(this1)
    SET
        this1.id = randomUUID(),
        this1.email = $param2,
        this1.status = $param3
    MATCH (this1)-[:INVITED_TO]->(this5:Group)
    CALL (this5) {
        MATCH (this5)<-[this6:INVITED_TO]-(this7:Invitee)
        RETURN count(this7) < $param4 AS var8
    }
    WITH *
    WHERE var8 = true
    RETURN count(this5) = 1 AS var9
    WITH *
    CALL apoc.util.validate(NOT ($isAuthenticated = true AND var9 = true), "@neo4j/graphql/FORBIDDEN", [0])
    RETURN this0 AS this
}
WITH this
CALL (this) {
    CALL (this) {
        MATCH (this)<-[this10:INVITED_TO]-(this11:Invitee)
        WITH DISTINCT this11
        WITH this11 { .email } AS this11
        RETURN collect(this11) AS var12
    }
    RETURN this { invitees: var12 } AS var13
}
RETURN collect(var13) AS data

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions