Hello, when I use @auth directive, the erorr will throw. When I delete it, graphql query work well.
Graphql schema
type User {
id: ID @id
username: String! @unique
firstName: String!
lastName: String!
email: String!
password: String! @private
roles: [Role!]! @relationship(type: "IN_ROLE", direction: OUT)
}
type Role {
name: String #read:Blog, write:Catogory
}
type Mutation {
signUp(username: String!, password: String!): String! ### JWT
signIn(username: String!, password: String!): String! ### JWT
}
extend type Role @auth(rules: [{operations: [READ], isAuthenticated: true }])
My query
query{users{username roles{name}}}
The eorror
{
"errors": [
{
"message": "Unknown function 'apoc.util.validatePredicate' (line 2, column 79 (offset: 96))\r\n\"RETURN `this`{.`username`, `roles`: ([(`this`)-[:`IN_ROLE`]->(`this_roles`:`Role`) WHERE (`apoc`.`util`.`validatePredicate`((not (`apoc`.`util`.`validatePredicate`((not ((($`auth`).`isAuthenticated`) = (true))), (\"@neo4j/graphql/UNAUTHENTICATED\"), ([0])))), (\"@neo4j/graphql/FORBIDDEN\"), ([0]))) | (`this_roles`{.`name`})])} AS `this`\"\r\n ^",
"locations": [
{
"line": 5,
"column": 7
}
],
"path": [
"users"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "Neo.ClientError.Statement.SyntaxError",
"name": "Neo4jError",
"stacktrace": [
"Neo4jError: Unknown function 'apoc.util.validatePredicate' (line 2, column 79 (offset: 96))\r",
"\"RETURN `this`{.`username`, `roles`: ([(`this`)-[:`IN_ROLE`]->(`this_roles`:`Role`) WHERE (`apoc`.`util`.`validatePredicate`((not (`apoc`.`util`.`validatePredicate`((not ((($`auth`).`isAuthenticated`) = (true))), (\"@neo4j/graphql/UNAUTHENTICATED\"), ([0])))), (\"@neo4j/graphql/FORBIDDEN\"), ([0]))) | (`this_roles`{.`name`})])} AS `this`\"\r",
" ^",
"",
" at captureStacktrace (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\result.js:239:17)",
" at new Result (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\result.js:59:23)",
" at newCompletedResult (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\transaction.js:375:12)",
" at Object.run (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\transaction.js:229:20)",
" at Transaction.run (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\transaction.js:101:34)",
" at C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\@neo4j\\graphql\\dist\\utils\\execute.js:66:104",
" at TransactionExecutor._safeExecuteTransactionWork (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\internal\\transaction-executor.js:92:26)",
" at TransactionExecutor._executeTransactionInsidePromise (C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\internal\\transaction-executor.js:83:34)",
" at C:\\Users\\icyfo\\VisualstudioProjects\\neo4j-graphql-example\\node_modules\\neo4j-driver-core\\lib\\internal\\transaction-executor.js:40:19",
" at new Promise (<anonymous>)"
]
}
}
}
],
"data": null
}
The package.json
{
"name": "neo4j-graphql-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "commonjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@neo4j/graphql": "^3.0.0",
"@neo4j/graphql-ogm": "^3.0.0",
"@neo4j/graphql-plugin-auth": "^1.0.0",
"@neo4j/introspector": "^1.0.1",
"apollo-server": "^3.6.3",
"bcrypt": "^5.0.1",
"fs": "^0.0.1-security",
"jsonwebtoken": "^8.5.1",
"neo4j-driver": "^4.4.2"
}
}
Any help? thanks.