Giter Site home page Giter Site logo

Comments (23)

XTVB avatar XTVB commented on June 2, 2024 21

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.

NoisyFlowers avatar NoisyFlowers commented on June 2, 2024 5

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.

PabloSzx avatar PabloSzx commented on June 2, 2024 3

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.

deadcoder0904 avatar deadcoder0904 commented on June 2, 2024 2

Me too, same error 🙋‍♂️

However, downgrading to =6.0.9 solves it 👏

downgrading works :)

from graphql-middleware.

jgwiazdowski avatar jgwiazdowski commented on June 2, 2024 2

still same problem,
6.0.9 solves it

from graphql-middleware.

todda00 avatar todda00 commented on June 2, 2024 1

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.

Manubi avatar Manubi commented on June 2, 2024 1

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.

martinnabhan avatar martinnabhan commented on June 2, 2024 1

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.

nuronbeck avatar nuronbeck commented on June 2, 2024 1

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.

Manubi avatar Manubi commented on June 2, 2024

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.

PabloSzx avatar PabloSzx commented on June 2, 2024

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.

NoisyFlowers avatar NoisyFlowers commented on June 2, 2024

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.

Screenshot 2021-09-16 133103

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.

PabloSzx avatar PabloSzx commented on June 2, 2024

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.

balgamat avatar balgamat commented on June 2, 2024

"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)...
image

Sadly, adding experimental: { esmExternals } to next.config.js did not help :/

However, downgrading to =6.0.9 solves it 👏

from graphql-middleware.

wangel13 avatar wangel13 commented on June 2, 2024

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.

paulmikulskis avatar paulmikulskis commented on June 2, 2024

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.

harsh3977 avatar harsh3977 commented on June 2, 2024

Facing same problem . Solved by downgrading middleware version 6.0.6.

from graphql-middleware.

calboru avatar calboru commented on June 2, 2024

Facing same problem . Solved by downgrading middleware version 6.0.6.
Are there any fix yet?

from graphql-middleware.

brandoniumNutrien avatar brandoniumNutrien commented on June 2, 2024

facing this problem tried downgrading, recently upgraded to nextjs 12

from graphql-middleware.

Jl14Salvador avatar Jl14Salvador commented on June 2, 2024

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.

hyusetiawan avatar hyusetiawan commented on June 2, 2024

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.

Janushan avatar Janushan commented on June 2, 2024

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.

This worked for me!
Thanks!

from graphql-middleware.

adhamsalama avatar adhamsalama commented on June 2, 2024

Any updates on this issue?

from graphql-middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.