Skip to content

Typescript mismatch between mongodb <Collection> and apollo-datasources-mongodb <Collection> #106

Open
@JRedded

Description

@JRedded

I replaced my UserAPI with the one in apollo-datasources-mongodb typescript section, and still got the same error.

---ERROR---

Argument of type 'import("C:/Users/969070/Code/pistachio_develpment/server/node_modules/mongodb/mongodb").Collection<import("C:/Users/969070/Code/pistachio_develpment/server/node_modules/bson/bson").Document>' is not assignable to parameter of type 'import("C:/Users/969070/Code/pistachio_develpment/server/node_modules/apollo-datasource-mongodb/node_modules/@types/mongodb/index").Collection<import("C:/Users/969070/Code/pistachio_develpment/server/node_modules/bson/bson").Document>'.
Type 'Collection' is missing the following properties from type 'Collection': geoHaystackSearch, group, parallelCollectionScan, reIndex, savet
--- ERROR ---

Argument of type 'Collection<Document>' is not assignable to parameter of type 'Collection<UserDocument>'.
Type 'Collection<Document>' is missing the following properties from type > 'Collection<UserDocument>': geoHaystackSearch, group, parallelCollectionScan, reIndex, save

--- APOLLO SERVER ---

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 ---

"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"
  },

It seems that there is a mismatch between the <Collection> from MongoClient and the <Collection> in apollo-datasources-mongodb.

That is the mongodb <Collection> not fitting with the apollo-datasource-mongodb <Collection> type, right?

Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions