[英]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 })
The Error I am getting is following TypeError: Class extends value undefined is not a constructor or null我得到的错误是 TypeError: Class extends value undefined is not a constructor or null
Looking at the apollo-server\/packages\/apollo-server-express\/src\/index.ts<\/a> , that function is not exposed.查看
apollo-server\/packages\/apollo-server-express\/src\/index.ts<\/a> ,该功能没有公开。
SchemaDirectiveVisitor<\/a> is a legacy function from
graphql-tools<\/code> .
SchemaDirectiveVisitor<\/a>是来自
graphql-tools<\/code>的遗留函数。
apollo-server-express@2.XX (last v2.25.2)<\/a> used graphql-tools 4.0.8<\/a> which still had that function.
apollo-server-express@2.XX (last v2.25.2)<\/a>使用了仍然具有该功能的 graphql-tools 4.0.8<\/a> 。
"
They got rid of the SchemaDirectiveVisitor and added two new functions to simplify: mapSchema and getDirectives.他们摆脱了 SchemaDirectiveVisitor 并添加了两个新函数来简化:mapSchema 和 getDirectives。
Source: https://www.the-guild.dev/blog/graphql-tools-v6 Then scroll to the following title.来源: https ://www.the-guild.dev/blog/graphql-tools-v6 然后滚动到以下标题。 Modify Schemas with Directives
使用指令修改模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.