未知指令“@isAuthenticated”。使用 Neo4j 和 Graphql
unknown directive "@isAuthenticated". Using Neo4j and Graphql
我正在尝试做这样的事情:
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,
},
},
})
但是当我在 graphql.schema 中这样做时:
type Avatar @isAuthenticated {
avatarId: ID! @id
name: String! @unique
picture: String!
coinPrice: Int!
collections: [AvatarCollection]
@relationship(type: "AVATAR_COLLECTION_AVATAR", direction: IN)
}
我收到这个错误:
unknown directive "@isAuthenticated".
我该如何添加指令?
用 Neo4jGraphql 做到这一点的正确方法是:
type Avatar @auth(rules: [{ operations: [CREATE], isAuthenticated: true }])
{
avatarId: ID!
...
}
有关详细信息,请参阅此文档:
https://neo4j.com/docs/graphql-manual/current/auth/
我正在尝试做这样的事情:
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,
},
},
})
但是当我在 graphql.schema 中这样做时:
type Avatar @isAuthenticated {
avatarId: ID! @id
name: String! @unique
picture: String!
coinPrice: Int!
collections: [AvatarCollection]
@relationship(type: "AVATAR_COLLECTION_AVATAR", direction: IN)
}
我收到这个错误:
unknown directive "@isAuthenticated".
我该如何添加指令?
用 Neo4jGraphql 做到这一点的正确方法是:
type Avatar @auth(rules: [{ operations: [CREATE], isAuthenticated: true }])
{
avatarId: ID!
...
}
有关详细信息,请参阅此文档: https://neo4j.com/docs/graphql-manual/current/auth/