0

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?

4

1 回答 1

1

使用 Neo4jGraphql 的正确方法是:

type Avatar @auth(rules: [{ operations: [CREATE], isAuthenticated: true }]) 
    {
       avatarId: ID!
        ...
    }

有关更多信息,请参阅此文档: https ://neo4j.com/docs/graphql-manual/current/auth/

于 2021-11-24T08:25:04.097 回答