thebigredgeek / apollo-resolvers

Expressive and composable resolvers for Apollostack's GraphQL server
MIT License
431 stars 41 forks source link

Typescript - TypeError: Cannot read property 'createResolver' of undefined #48

Open rodrigooler opened 5 years ago

rodrigooler commented 5 years ago

The following error is occurring when trying to use apollo-resolvers with typescript, I noticed that several people were having the same problem and I decided to open the issue, more details below.

Error

captura de tela 2018-12-14 as 15 19 00

resolvers

captura de tela 2018-12-14 as 15 22 56

userResolvers

captura de tela 2018-12-14 as 15 20 51

package.json

  "dependencies": {
    "@sentry/node": "4.4.2",
    "apollo-errors": "1.9.0",
    "apollo-resolvers": "1.4.1",
    "apollo-server-micro": "2.3.1",
    "bcryptjs": "2.4.3",
    "bluebird": "3.5.3",
    "ccxt": "1.18.36",
    "date-fns": "1.30.1",
    "dotenv": "6.2.0",
    "graphql": "14.0.2",
    "i18nh": "0.0.4",
    "idx": "2.5.2",
    "jsonwebtoken": "8.4.0",
    "micro": "9.3.3",
    "micro-compose": "0.0.3",
    "micro-cors": "0.1.1",
    "mongoose": "5.3.16",
    "ramda": "0.26.1",
    "ts-node": "7.0.1",
    "validator": "10.9.0"
  },
  "devDependencies": {
    "@types/bcryptjs": "2.4.2",
    "@types/bluebird": "3.5.25",
    "@types/dotenv": "6.1.0",
    "@types/graphql": "14.0.3",
    "@types/jsonwebtoken": "8.3.0",
    "@types/micro": "7.3.3",
    "@types/micro-cors": "0.1.0",
    "@types/mongoose": "5.3.5",
    "@types/ramda": "0.25.43",
    "@types/validator": "9.4.4",
    "husky": "1.2.1",
    "lint-staged": "8.1.0",
    "nodemon": "1.18.8",
    "prettier": "1.15.3",
    "tslint": "5.11.0",
    "tslint-config-prettier": "1.17.0",
    "tslint-config-security": "1.13.0",
    "typescript": "3.2.2"
  },
fakenickels commented 5 years ago

have you tried adding this to your tsconfig.json compilerOptions?

    "allowSyntheticDefaultImports": true,
rodrigooler commented 5 years ago

@grsabreu same problem.

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["es6"],
        "module": "commonjs",
        // "noImplicitAny": true, // will raise several errors
        "alwaysStrict": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true,
        "outDir": "dist",
        "allowSyntheticDefaultImports": true,
    },
    "include": [ "**/*" ], 
    "exclude": [
        "dist/*",
        "node_modules",
        "**/*.spec.ts"
    ]
}

captura de tela 2018-12-14 as 15 52 31

rodrigooler commented 5 years ago

Do you have any idea what this problem might be @thebigredgeek? I practically followed the details of the README.md but the only difference is that I am using typescript in the latest version

thebigredgeek commented 5 years ago

Huh no clue. it almost looks like something is overriding the value?

sanket-work commented 4 years ago

is this fixed ?

thebigredgeek commented 4 years ago

Let me take a look, apologies i've been busy bootstrapping my company!

thebigredgeek commented 4 years ago

https://github.com/boltsource/apollo-resolvers/pull/67