Comments (23)
isMiddlewareGenerator
is incorrectly returning false for graphql-shield permissions, which causes this error to occur in the validation.
If you replace applyMiddleware(schema, permissions)
with applyMiddleware(schema, permissions.generate(schema))
then it will work correctly with the latest version of graphql-middleware, without needing to downgrade.
from graphql-middleware.
I've been trying different versions of graphql-middleware and am seeing the same as @todda00: the problem starts with 6.1.0.
from graphql-middleware.
Same problem, i have a repo to reproduce: https://github.com/wangel13/prisma-next-auth-graphql-starter
error - node_modules/graphql-middleware/dist/validation.mjs (10:0) @ eval Error: Type generator exists in middleware but is missing in Schema. null
Confirmed It's an issue with graphql-shield, since graphql-middleware ships an ESM version of the package and graphql-shield doesn't, it's just that graphql-middleware doesn't like duplicated versions of itself @maticzav
from graphql-middleware.
Me too, same error 🙋♂️
However, downgrading to =6.0.9 solves it 👏
downgrading works :)
from graphql-middleware.
still same problem,
6.0.9 solves it
from graphql-middleware.
I'm running into the same error with anything above 6.0.10
Not using next.js, using webpack / babel (latest versions of both)
from graphql-middleware.
Yeah sorry. I didn't dig deeper as I have things that I need to finish. If it shows up again I'll have a look as well.
Thanks for your work! 🤗
from graphql-middleware.
Same problem here, it worked fine with
- graphql-middleware 6.1.9
- graphql-shield 7.5.0
- next 11.1.2
but after upgrading to next 12 we get the same above error.
Downgrading graphql-middleware to 6.0.9 fixed it.
from graphql-middleware.
To downgrade graphql-middleware package to 6.0.9, do command:
With npm: npm uninstall graphql-middleware
then do npm install [email protected]
With yarn: yarn remove graphql-middleware
then do yarn add [email protected]
from graphql-middleware.
Update: I think the error wars next.js experimental: { esmExternals: true },
At least for now it seems to work. For the latest version as well.
from graphql-middleware.
Update: I think the error wars next.js
experimental: { esmExternals: true },
At least for now it seems to work. For the latest version as well.
I just tested a Next.js project using esmExternals: true
and graphql-middleware and everything works fine, and I executed all the tests on ESM and nothing fails
I'm running into the same error with anything above
6.0.10
Not using next.js, using webpack / babel (latest versions of both)
We need a reproduction repo / instructions to be able to debug it, I really tried to find this issue by myself, I just tested a lot of things and nothing fails
from graphql-middleware.
I'm encountering this same problem.
I'm new to this biome, so not sure what is important info to relay, but I'm using graphql-middleware 6.1.6, graphql-shield 7.5.0, apollo-server-express 2.25.2, and neo4j-graphql-js 2.19.4.
Relevant code bits (maybe). Note that makeAugmentedSchema comes from https://github.com/neo4j-graphql/neo4j-graphql-js (not sure if that's important):
const typeDefs = fs
.readFileSync(
//process.env.GRAPHQL_SCHEMA || path.join(__dirname, 'schema.graphql')
process.env.GRAPHQL_SCHEMA || './schema.graphql'
)
.toString('utf-8');
const schema = makeAugmentedSchema({
typeDefs: typeDefs
});
const isAuthenticated = rule({ cache: 'contextual' })(async (parent, args, ctx, info) => {
return ctx.user !== null
});
const isAdmin = rule({ cache: 'contextual' })(async (parent, args, ctx, info) => {
return ctx.user.roles.includes('admin');
});
const permissions = shield({
Query: {
"*": allow,
},
Mutation: {
"*": and(isAuthenticated, isAdmin)
},
})
const server = new ApolloServer({
context:
async ({ req }) => {
console.log("setting up context");
//get user from token
const token = req.headers.authorization || '';
const user = await getUser(driver, token);
// Add the user to the context
return {
user,
driver,
driverConfig: { database: process.env.NEO4J_DATABASE || 'neo4j' },
};
},
schema: applyMiddleware(schema, permissions),
introspection: true,
playground: true,
})
from graphql-middleware.
as already mentioned, @NoisyFlowers can you create a minimal reproduction repo? I already tried a lot of stuff trying to reproduce it and I couldn't
from graphql-middleware.
"graphql-middleware": "^6.1.9",
"graphql-shield": "^7.5.0"
The same code works when ran in a standalone Apollo Server Micro, but when in Next.js (webpack, that is)...
Sadly, adding experimental: { esmExternals }
to next.config.js did not help :/
However, downgrading to =6.0.9 solves it 👏
from graphql-middleware.
Same problem, i have a repo to reproduce: https://github.com/wangel13/prisma-next-auth-graphql-starter
error - node_modules/graphql-middleware/dist/validation.mjs (10:0) @ eval
Error: Type generator exists in middleware but is missing in Schema.
null
from graphql-middleware.
I have this issue and the fix presented above.
OS: macOS 11.4
Node: 14.18.1
npm: 6.14.15
graphql-middleware: "^6.1.12"
graphql-shield: "^7.5.0"
changing the middleware loader to graphql-middleware: "6.0.9"
fixed things
from graphql-middleware.
Facing same problem . Solved by downgrading middleware version 6.0.6.
from graphql-middleware.
Facing same problem . Solved by downgrading middleware version 6.0.6.
Are there any fix yet?
from graphql-middleware.
facing this problem tried downgrading, recently upgraded to nextjs 12
from graphql-middleware.
Reverting to version 6.0.9 and pinned it. Fixed my problem. Would love to see this fixed so I can update to the latest version.
from graphql-middleware.
it seems downgrading is the only way to fix this issue right now. Can this be fixed on graphql-middleware side or is it because of interactions with libraries?
from graphql-middleware.
isMiddlewareGenerator
is incorrectly returning false for graphql-shield permissions, which causes this error to occur in the validation.If you replace
applyMiddleware(schema, permissions)
withapplyMiddleware(schema, permissions.generate(schema))
then it will work correctly with the latest version of graphql-middleware, without needing to downgrade.
This worked for me!
Thanks!
from graphql-middleware.
Any updates on this issue?
from graphql-middleware.
Related Issues (20)
- Support for operations middleware HOT 7
- When used as specified in the middleware documentation, the function is executed for every type, for every field of that type, and for all subfields in the request. HOT 1
- Question and help: How to use with postgraphile? HOT 1
- applyMiddleware + __resolveReference HOT 4
- Middleware an external GraphQL API HOT 1
- Use graphql-middleware in subscriptions like queries and mutations HOT 4
- Resolver incompatibility with Postgraphile top-level Connections HOT 7
- docs: Clarification Middleware vs Plugins HOT 1
- applyMiddleware corrupts schema with Apollo federation `stub types` HOT 6
- High memory and CPU usage with a noop graphql-middleware HOT 1
- Add ability to mutate schema in-place
- Dependency Dashboard
- Graphql 16 update HOT 9
- bind middleware to return types
- Missing graphql-middleware-sentry middleware
- Could not find a declaration file for module 'graphql-middleware'. HOT 2
- Subscriptions can take both subscribe/resolve in it's definition, the applyMiddlewareToField overlooks that HOT 1
- graphql-middleware with custom directives, breaks directives HOT 1
- Catch error from nested field resolver in higher middleware
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-middleware.