question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types of property 'middlewares' are incompatible.

See original GitHub issue

Bug report

  • [Yes] I have checked other issues to make sure this is not a duplicate.

Describe the bug

When using the most current versions of the graphql-yoga and graphl-shield libraries, trying to add shield({ ... }) to the middlewares option of the server creates this error:

image

(it keeps going for quite a while, just didn’t want to copy and paste five dozen lines)

To Reproduce

Copy and paste the Graphql Yoga example file. No changes are necessary for the error to pop up.

Additional context

graphql-yoga version: 1.16.2 graphql-shield version: 3.2.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:18

github_iconTop GitHub Comments

2reactions
kevratcommented, Oct 3, 2018

As you say i updated graphql-yoga and now i’m getting:

Error: Cannot find module 'graphql-middleware'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/mnt/share/Git/aerobic-backend/node_modules/graphql-shield/src/shield.ts:1:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
[nodemon] app crashed - waiting for file changes before starting...

my updated package.json

"dependencies": {
  "apollo-errors": "^1.9.0",
  "bcryptjs": "^2.4.3",
  "graphql": "^14.0.2",
  "graphql-cli": "^2.16.7",
  "graphql-middleware-forward-binding": "^1.3.2",
  "graphql-shield": "^3.2.4",
  "graphql-yoga": "^1.16.2",
  "jsonwebtoken": "^8.3.0",
  "nodemailer": "^4.6.7",
  "npm-run-all": "^4.1.3",
  "prisma": "^1.17.1",
  "prisma-binding": "^2.1.6"
},

if i install it i get

Error: Type generator exists in middleware but is missing in Schema.

If i remove graphql-shield from middlewares all is working. Looks like some packages is conflict. But which. Removing ‘graphql-middleware-forward-binding’ from middlewares it is don’t cause any effect

Also then i yarn install i get some warnings:

warning " > graphql-middleware-forward-binding@1.3.2" has unmet peer dependency "graphql-middleware@^1.3.2".
warning "graphql-middleware-forward-binding > graphql-binding@2.2.5" has incorrect peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0".
warning "graphql-middleware-forward-binding > graphql-binding > graphql-import@0.5.3" has incorrect peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0".
warning "prisma-binding > graphql-tools@3.1.0" has incorrect peer dependency "graphql@^0.13.0".
warning " > graphql-shield@3.2.5" has unmet peer dependency "graphql-middleware@^1.6.4".
warning "prisma > prisma-cli-core@1.17.1" has incorrect peer dependency "graphql@^0.12.0 || ^0.13.0".
warning " > prisma-binding@2.1.6" has incorrect peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0".
warning "prisma-binding > apollo-link@1.2.2" has incorrect peer dependency "graphql@^0.11.3 || ^0.12.3 || ^0.13.0".
warning "prisma-binding > graphql-import@0.5.2" has incorrect peer dependency "graphql@^0.11.0 || ^0.12.0 || ^0.13.0".
warning "prisma-binding > subscriptions-transport-ws@0.9.8" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.1".
warning " > prettier-tslint@0.4.0" has incorrect peer dependency "typescript@^2.5.3".

GOTCHA! Using graphql": "^0.13.2 don’t cause any error. And looks like i don’t need this package, so i remove that and everything work. Don’t know why i installed it, but it is he who conflicts.

1reaction
heymartinadamscommented, Oct 11, 2018

That totally did the trick, @maticzav 💛 Thanks a bunches!! Can’t wait to try and test it out ✨

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types of property 'middlewares' are incompatible. #151 - GitHub
This error occurs due to duplicated graphql-middleware package. graphql-yoga is already packed with the latest graphql-middleware version ...
Read more >
Types being coerced to "any" and "Two different types with this ...
Two different types with this name exist, but they are unrelated. Types of property 'error' are incompatible. Type 'ValidationError' is not ...
Read more >
How to extend the Express Request object in TypeScript
Let's learn how to extend the Request type in TypeScript to make its instances store custom data you can use at the controller...
Read more >
18 Defining and Using a Job Incompatibility
This chapter describes how to use an Oracle Enterprise Scheduler job incompatibility, with which you can specify job requests that cannot run together....
Read more >
Type Phantoms and Safe APIs - /dev/solita
One way to create a type-safe API is to generate code from metadata. ... Declaring undefined properties helps with type inference: path: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found