paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
683 stars 54 forks source link

Error: Cannot find module 'graphql/language/parser' #171

Closed gavrichards closed 3 years ago

gavrichards commented 3 years ago

I'm trying to use this for handling cascading deletes in Prisma. I'm not using graphql in my project, but an error appears which suggests it is required, although this isn't mentioned on this doc page.

My code is:

import {PrismaClient, dmmf} from '../../prisma/client';
import {PrismaDelete} from '@paljs/plugins';

class Prisma extends PrismaClient {
  constructor(options) {
    super(options);
  }

  async onDelete(args) {
    const prismaDelete = new PrismaDelete(this, {dmmf});
    await prismaDelete.onDelete(args);
  }
}

I get the following (I have replaced sensitive bits with [redacted])

Error: Cannot find module 'graphql/language/parser'
Require stack:
- /[redacted]/node_modules/graphql-tag/lib/graphql-tag.umd.js
- /[redacted]/node_modules/@paljs/plugins/dist/plugins.cjs.development.js
- /[redacted]/node_modules/@paljs/plugins/dist/index.js
- /[redacted]/.next/server/pages/api/[redacted]/.js
- /[redacted]/node_modules/next/dist/next-server/server/next-server.js
- /[redacted]/node_modules/next/dist/server/next.js
- /[redacted]/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /[redacted]/node_modules/graphql-tag/lib/graphql-tag.umd.js:7:14
    at /[redacted]/node_modules/graphql-tag/lib/graphql-tag.umd.js:2:65
    at Object.<anonymous> (/[redacted]/node_modules/graphql-tag/lib/graphql-tag.umd.js:5:2)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/[redacted]/node_modules/@paljs/plugins/dist/plugins.cjs.development.js:10:27)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/[redacted]/node_modules/graphql-tag/lib/graphql-tag.umd.js',
    '/[redacted]/node_modules/@paljs/plugins/dist/plugins.cjs.development.js',
    '/[redacted]/node_modules/@paljs/plugins/dist/index.js',
    '/[redacted]/.next/server/pages/api/[redacted].js',
    '/[redacted]/node_modules/next/dist/next-server/server/next-server.js',
    '/[redacted]/node_modules/next/dist/server/next.js',
    '/[redacted]/server.js'
  ]
}

Is there any way around this? Thanks.

AhmedElywa commented 3 years ago

@gavrichards You can fix this now by installing graphql in your project npm install graphql

and I will fix this in my next release

gavrichards commented 3 years ago

@AhmedElywa thank you, that worked. I look forward to the update :)

AhmedElywa commented 3 years ago

Please upgrade to version 2.12.0 and remove graphql package and try

gavrichards commented 3 years ago

@AhmedElywa No sorry, the same error still occurs with 2.12.0.

AhmedElywa commented 3 years ago

Yes you are right I forgot that graphql-tag also requires graphql package

gavrichards commented 3 years ago

Confirmed this is fixed :) Thanks