apollo-resolvers icon indicating copy to clipboard operation
apollo-resolvers copied to clipboard

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

Open rodrigooler opened this issue 6 years ago • 7 comments

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

rodrigooler avatar Dec 14 '18 17:12 rodrigooler

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

    "allowSyntheticDefaultImports": true,

fakenickels avatar Dec 14 '18 17:12 fakenickels

@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 avatar Dec 14 '18 17:12 rodrigooler

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

rodrigooler avatar Dec 14 '18 18:12 rodrigooler

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

thebigredgeek avatar May 14 '19 19:05 thebigredgeek

is this fixed ?

sanket-work avatar Feb 21 '20 07:02 sanket-work

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

thebigredgeek avatar Mar 04 '20 19:03 thebigredgeek

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

thebigredgeek avatar Mar 04 '20 19:03 thebigredgeek