问题描述
有没有人遇到过以下情况
errorMessage: "UnkNown directive "isAuthenticated".↵↵UnkNown directive "isAuthenticated"."
我正在使用 GRANDstack 构建我的第一个应用程序,并尝试在我的 api 中使用 @hasScope
和 @isAuthenticated
。
开发中一切正常。它发生在通过 netlify 函数提供服务的生产环境中。
const schema = makeAugmentedSchema({
typeDefs,resolvers,config: {
query: true,mutation: true,auth: {
isAuthenticated: true,hasScope: true,},})
更新: 这是我的函数/graphql/graphql.js 文件中的代码
`// This module can be used to serve the GraphQL endpoint
// as a lambda function
const { ApolloServer } = require('apollo-server-lambda')
const { makeAugmentedSchema } = require('neo4j-graphql-js')
const neo4j = require('neo4j-driver')
// This module is copied during the build step
// Be sure to run `npm run build`
const { typeDefs } = require('./graphql-schema')
const driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',process.env.NEO4J_PASSWORD || 'neo4j'
),{
encrypted: process.env.NEO4J_ENCRYPTED ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF',}
)
const server = new ApolloServer({
schema: makeAugmentedSchema({
typeDefs,config: {
query: true,auth: {
isAuthenticated: true,}),context: ({ req }) => {
return { req,driver,neo4jDatabase: process.env.NEO4J_DATABASE }
},})
exports.handler = server.createHandler()
`
在 makeAugmentedSchema 中包含配置对象后,错误现在已更改为 no authorisation token
我不确定是否还有其他我应该做的事情。开发中一切正常。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)