Open mzvdev opened 11 hours ago
We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @mzvdev! :pray: We will now prioritise the bug and address it appropriately.
Hey @mzvdev, I've been investigating this one and generally looking into the issues with the graphql-tools
packages.
The issue here is actually in your type definitions! In your JWT you have defined sub
as an integer (https://github.com/mzvdev/n4j-issues/blob/main/src/schema.graphql#L4) but then compare to it as a string (https://github.com/mzvdev/n4j-issues/blob/main/src/schema.graphql#L9).
This is a bit of a shortcoming of the authorization features because the $
string interpolation only really works with string variables. However, I have added a test to #5458 which proves that this all works when this definition is changed to String
with the updated versions of graphql-tools
.
@darrellwarde Oups, Sorry! Thank you for finding. Indeed a type mistake from our side in the repo.
But in the main project we have still that error, but the code is a bit different:
GraphQLError: String cannot represent value: { where: { node: [Object] } }
type JWT @jwt {
roles: [String]
id: String
sub: String
}
@authorization(
validate: [
{ where: { node: { admins: { authId: "$jwt.id" } } } }
{ where: { node: { ref: "$jwt.sub" } }, operations: [READ] }
{ where: { jwt: { roles_INCLUDES: "overlord" } } }
]
)
Will try to reproduce it again in my isolated repo and share it with you.
@darrellwarde Quick question: is it possible to somehow identify which line cause an error? I have added the debug option, but not very helpful, to identify which line cause the error.
I have this error, but I have 50 places where I use { where: { node: {...} }, tried to isolate one by one, but not able to find it.
GraphQLError: String cannot represent value: { where: { node: [Object] } }
Describe the bug We found that when we delete the yarn lock file in our current project, we had an error parsing the GraphQL Schema. It fails to parse @authorization rules (error message:
Invalid argument: validate, error: String cannot represent a non string value
) By removing @authorization rules it worked. Then we tried to isolate the problem in a separate repo, we still had the same issue.Details Run tests by executing following commands:
Test should now fail with:
Now if you remove following @authorization in schema.graphql:
Tests will now pass...
To Reproduce Steps to reproduce the behavior:
./test.sh watch-test
Expected behavior No errors parsing the schema
Environment