Open
Description
Describe the bug
In certain scenarios, the order of fields on a type matter for @authorization validation.
To Reproduce
-
Clone the following repo https://github.com/afreakk/n4j-issue
-
yarn install
-
./test.sh watch-test
-
Test should now fail with:
...snipped... - "id": Any<String>, + "extensions": Object { + "code": "INTERNAL_SERVER_ERROR", + "stacktrace": Array [ + "Neo4jGraphQLForbiddenError: Forbidden", ...snipped...
-
Now if you change the following type in schema.graphql:
type VehicleCard @authorization( validate: [{ where: { node: { tenant: { admins: { userId: "$jwt.id" } } } } }] ) { id: ID! @id garages: [Garage!]! @relationship(type: "VALID_GARAGES", direction: OUT) tenant: Tenant! @relationship(type: "VEHICLECARD_OWNER", direction: OUT) # <--- this line }
By moving the pointed to line up so the type will look like this:
type VehicleCard @authorization( validate: [{ where: { node: { tenant: { admins: { userId: "$jwt.id" } } } } }] ) { id: ID! @id tenant: Tenant! @relationship(type: "VEHICLECARD_OWNER", direction: OUT) # <--- this line garages: [Garage!]! @relationship(type: "VALID_GARAGES", direction: OUT) }
-
Tests will now pass...
(you can force save index.test.js to force rerun of tests)
Expected behavior
Order of fields should not have an impact on @authorization.
System (please complete the following information):
- OS: NixOs
- Version: @neo4j/graphql@4.2.0
- Node.js version: v18.17.1
Metadata
Metadata
Assignees
Type
Projects
Status
Low priority