要求本地模块与node_modules模块之间的差异
A在私有库中有一个在node_modules
文件夹内的node_modules
。
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _graphql = require('graphql'); var FileTypeEnum = new _graphql.GraphQLEnumType({ name: 'FileType', description: 'The types of report files.', values: { CSV: { value: 'CSV', description: 'Comma-separated values.' }, XLS: { value: 'XLS', description: 'Microsoft Excel.' } } }); exports.default = FileTypeEnum;
我的问题是当我需要它时,它带有正确的属性的对象,但不是GraphQLEnumType的一个实例。 另一方面,如果在我的项目中创build一个本地模块的副本,就像本地模块一样,它可以很好地工作。
import FileTypeA from 'my_lib/graphql/report/types/FileTypeEnum'; import FileTypeB from '../types/FileTypeEnum'; console.log(FileTypeA instanceof GraphQLEnumType); # false console.log(FileTypeB instanceof GraphQLEnumType); # true
如果不是GraphQLEnumType,我不能使用这个类。 有什么build议么?
也许你的库有一个不同于你的应用程序的graphql版本。
- Apollo Graphql架构拼接冲突
- 在执行react-relay时,无法读取属性'undefined'
- Graphql:必须提供查询string
- Webpack html插件不会生成html
- Graphql的date字段types必须是输出types,但得到:未定义
- Edge.node字段types必须是输出types,但是:undefined
- 发送一个http请求到一个graphql api时“parsingJSON的问题”
- GraphQL参数错误:参数types必须是inputtypes,但得到:function GraphQLObjectType(config){
- Graphql需要模块外部vs GraphQLObjectType内部