【发布时间】:2022-08-19 02:20:38
【问题描述】:
apollo-datasources-mongodb 的打字稿演示不再有效。它会产生与我自己的代码相同的错误:
- - 错误 - -
类型参数 \'import(\"C:/Users/user/Code/development/server/node_modules/mongodb/mongodb\").Collection<import(\"C:/Users/user/Code/development/server/ node_modules/bson/bson\").Document>\' 不能分配给 \'import(\"C:/Users/user/Code/development/server/node_modules/apollo-datasource-mongodb/node_modules/@ 类型的参数types/mongodb/index\").Collection<import(\"C:/Users/user/Code/development/server/node_modules/bson/bson\").Document>\'. 类型 \'Collection\' 缺少类型 \'Collection\' 中的以下属性:geoHaystackSearch、group、parallelCollectionScan、reIndex、savet
--- 阿波罗服务器 ---
const server : ApolloServer = new ApolloServer({ schema : authorizedSchema , dataSources: () => ({ users: new Test( mongoClient.db(\"myapp\").collection(\"users\") ) // intellisense highlights the input to new Test as the error }) , context: async ( { req } ) => { await verifyAccessToken( req ) } , csrfPrevention: true });--- 依赖项 ---
\"dependencies\": { \"@apollo/client\": \"^3.6.9\", \"@azure/msal-common\": \"^7.1.0\", \"@graphql-tools/schema\": \"^8.5.0\", \"@graphql-tools/utils\": \"^8.8.0\", \"@types/express\": \"github:types/express\", \"@types/jsonwebtoken\": \"^8.5.8\", \"@types/node\": \"^18.0.3\", \"apollo-datasource-mongodb\": \"^0.5.4\", \"apollo-server\": \"^3.9.0\", \"apollo-server-core\": \"^3.9.0\", \"cookie-parser\": \"^1.4.6\", \"debug\": \"^4.3.4\", \"dotenv\": \"^16.0.1\", \"express\": \"^4.18.1\", \"express-jwt\": \"^7.7.5\", \"graphql\": \"^15.8.0\", \"graphql-tools\": \"^8.3.0\", \"http-errors\": \"^2.0.0\", \"jsonwebtoken\": \"^8.5.1\", \"jwks-rsa\": \"^2.1.4\", \"jws\": \"^4.0.0\", \"mongodb\": \"^4.8.1\", \"openid-client\": \"^5.1.8\", \"type-graphql\": \"^1.1.1\", \"typescript\": \"^4.7.4\" },MongoClient 中的 <Collection> 和 apollo-datasources-mongodb 中的 <Collection> 似乎不匹配。
那就是 mongodb <Collection> 不适合 apollo-datasource-mongodb <Collection> 类型,对吧?
我错过了什么吗?
编辑:
我尝试将缺少的属性设置为可选来扩展 MongoDB 集合。这已经超越了关于 mongodb 类型的这些属性的错误,现在我得到另一个错误,即不同的属性是错误的。
标签: mongodb react-apollo apollo-server