-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types of property 'middlewares' are incompatible. #151
Comments
same issue, looks like "shield" type has changed from IMiddleware to IMiddlewareGenerator.
to (in 3.2.2)
|
Hey @artemzakharov @JazminGonzalez-Rivero 👋, I tried to reproduce the error but had no luck. I used graphql create sample
cd sample
yarn add graphql-shield and code; import {GraphQLServer} from 'graphql-yoga'
import {shield, allow} from 'graphql-shield'
import {Prisma} from './generated/prisma'
import resolvers from './resolvers'
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
middlewares: [
shield({
Query: allow,
}),
],
context: req => ({
...req,
db: new Prisma({
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`)
debug: true, // log all GraphQL queries & mutations sent to the Prisma API
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`)
}),
}),
})
server.start(() => console.log(`Server is running on http://localhost:4000`)) Super barebones. Since I wasn't able to reproduce the bug, I suggest you try removing Let me add a quick note about the versioning; I assume you are both familiar with I hope this clears things out a bit. Let me know if you're still experiencing the problem. 🙂 |
@maticzav yeah sorry was trying to explain the change.... but continuing forward, I have a setup that passes the |
@maticzav I did have On a side note, do you happen to have a guide for using shield with Apollo Server 2? I've been considering switching over from Yoga, but I haven't found any means to implement your library with them yet. |
I'm running into the same error using |
@JazminGonzalez-Rivero @artemzakharov @jonathanheilmann thanks for the feedback! Let's first fix the problem this issue is named after. I am unable to reproduce the bug you are all facing. Since the best reproduction explanation, so far, has been to try the provided combinations of package versions, which I also tested, I am unable to conclude anything. It would be super helpful if one of you could tinker together a small repository portraying the bug. This way I can take a look into the problem and fix it if we find its nucleus in Regarding the Apollo Server issue, yes, there's a way of doing it. I don't have and don't intend to make an article or anything similar explaining the procedure as I hope we will gain Since Apollo Server accepts const schema = makeExecutableSchema({ typeDefs, resolvers })
const schemaWithMiddleware = applyMiddleware(
schema,
shield()
)
const server = new ApolloServer({
mocks: false,
schema: schemaWithMiddleware,,
}); i hope this is somewhat helpful 🙂 |
Running into the same issue unfortunately. For reference I use yoga with the Lambda ctor. |
@morgothulhu could you pull together a reproduction repo? |
Same here. I'm just
After
and
index.ts
package.json
I discard changes in my package.json and only upgrade graphql-shield from 2.2.5 to 3.2.4 and everything is ok, my current package.json:
|
Hey @kevrat 👋, Thank you for posting a reproduction code. You're probably experiencing the issues because your I hope this solves your problem 🙂 |
OK, huge thanks to everyone for posting the reproduction code and contributing to the above discussion. I think I've finally found a pattern in the errors we have seen, here's my examination; @artemzakharov I am sorry, but I am still unable to reproduce your bug. The steps I take are as follows; graphql create project
yarn add graphql-shield This results in No error is shown.
This error occurs due to duplicated
This error occurs due to an outdated version of I'll close this issue as it seems we've covered everything hitherto discussed. If anyone finds any other bug related to this topic, don't hesitate to open another question or a reply to this thread. 🙂 |
As you say i updated graphql-yoga and now i'm getting:
my updated package.json
if i install it i get
If i remove graphql-shield from middlewares all is working. Also then i
GOTCHA! |
Hi @maticzav! 💯 Receiving the same error — could it lie with my codebase?
|
Hey @heymartinadams, your |
@kevrat perfect! I think we should add this to the I am so glad it's working now 🎉 |
Mmh, @maticzav, upgraded |
Hey @heymartinadams 👋, No, having rules in a separate folder is completely fine. Peeking at your |
That totally did the trick, @maticzav 💛 Thanks a bunches!! Can’t wait to try and test it out ✨ |
Bug report
Describe the bug
When using the most current versions of the
graphql-yoga
andgraphl-shield
libraries, trying to addshield({ ... })
to themiddlewares
option of the server creates this error:(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
The text was updated successfully, but these errors were encountered: