I’m trying to do something like this :
const neoSchema = new Neo4jGraphQL({ typeDefs, driver, resolvers, config: { jwt: { secret: process.env.JWT_SECRET || 'secret', }, database: process.env.NEO4J_DATABASE || 'neo4j', auth: { isAuthenticated: true, hasRole: true, }, }, })
but when I do that in my graphql.schema :
type Avatar @isAuthenticated { avatarId: ID! @id name: String! @unique picture: String! coinPrice: Int! collections: [AvatarCollection] @relationship(type: "AVATAR_COLLECTION_AVATAR", direction: IN) }
I get this error :
unknown directive "@isAuthenticated".
how am I supposed to add the directives?
Advertisement
Answer
The right way to do that with Neo4jGraphql was :
type Avatar @auth(rules: [{ operations: [CREATE], isAuthenticated: true }]) { avatarId: ID! ... }
see this doc for more informations : https://neo4j.com/docs/graphql-manual/current/auth/