簡體   English   中英

無法從 apollo-server-express 導入 SchemaDirectiveVisitor

[英]Unable to import SchemaDirectiveVisitor from apollo-server-express

const { SchemaDirectiveVisitor } = require('apollo-server-express');

class ReplaceDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field) {
    const { replacement } = this.args;
    field.resolve = () => {
        return replacement
    }
}
}

module.exports = Object.freeze({ ReplaceDirective })

我得到的錯誤是 TypeError: Class extends value undefined is not a constructor or null

他們擺脫了 SchemaDirectiveVisitor 並添加了兩個新函數來簡化:mapSchema 和 getDirectives。

來源: https ://www.the-guild.dev/blog/graphql-tools-v6 然后滾動到以下標題。 使用指令修改模式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM