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