mercurius-js / mercurius

Implement GraphQL servers and gateways with Fastify
https://mercurius.dev/
MIT License
2.33k stars 234 forks source link

GraphiQL crashes after adding a plugin #1103

Open michal-wajrak opened 1 month ago

michal-wajrak commented 1 month ago

Adding a plugin to GraphiQL (in my case @graphiql/plugin-explorer), causes the /graphiql endpoint to crash.

Error shown in the console:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'umdPlugin')
    at main.js:145:78
    at Array.map (<anonymous>)
    at render (main.js:145:36)

index.ts:

const app = Fastify({
    logger: true,
});

const prisma = new PrismaClient();

app.register(mercurius, {
    schema,
    resolvers,
    context: () => {
        return { prisma };
    },
    graphiql: {
        enabled: true,
        plugins: [
            {
                name: "explorerPlugin",
                umdUrl: "https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js",
            },
        ],
    },
});

Dependencies: "mercurius": "14.1.0" "fastify": "4.28.1", "node": "20.13.1"

mercurius-graphiql-plugin-issue

mcollina commented 1 month ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.