如何解决我在使用 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,},})
更新: 这是我的函数/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 举报,一经查实,本站将立刻删除。