有没有人遇到以下情况
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,
},
},
})
这是我的 index.js 文件中的代码。
更新:这是我的函数/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,
mutation: true,
auth: {
isAuthenticated: true,
hasScope: true,
},
},
}),
context: ({ req }) => {
return { req, driver, neo4jDatabase: process.env.NEO4J_DATABASE }
},
})
exports.handler = server.createHandler()
`
在 makeAugmentedSchema 中包含配置对象后,错误现在变为说no authorisation token
我不确定我是否还有其他事情要做。在开发中一切正常。