neo4j - 我在使用 GRANDstack 的 Netlify 生产中不断收到错误“未知指令”
问题描述
有没有人遇到以下情况
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
我不确定我是否还有其他事情要做。在开发中一切正常。
解决方案
推荐阅读
- c# - 从 MongoDB 存储和取回文件
- android - 将 dd-mm-yy 字符串转换为 dd-mm-yyyy
- ruby-on-rails - 如何在 Ruby on Rails 上使用 base64 编码传递字段?
- css - 许多 CSS 文本阴影
- python - Python groupby ID 并增加关联列
- html - 一个 Font Awesome Icon 具体已停止在我的 wordpress 网站上显示
- node.js - Mongoose 无法进行深度填充
- c++ - 在 Windows x86 上安装 qt 5.5.1 msvc 2012
- reactjs - 连接组件的酶 wrapper.instance() 为空
- c# - 从不同的表中检索数据