question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uploading file crashes application when built with webpack

See original GitHub issue

Hi

I am trying to use graphql-upload in a typescript app built with webpack.

My setup

  • Typescript app
  • Apollo server / Typegraphql
  • Build with webpack

My Code

(stripped down to the essentials)

https://github.com/ziggy6792/graphql-file-uploads

My Problem

When I run with ts-node yarn start:ts:node then run yarn test an image gets uploaded no problem

But then I build with webpack yarn start then run yarn test I get the following error

/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:56105
            if (!isObject(operations) && !Array.isArray(operations))
                 ^

TypeError: isObject is not a function
    at Busboy.<anonymous> (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:56105:18)
    at Busboy.emit (node:events:378:20)
    at Busboy.module.exports../node_modules/busboy/lib/main.js.Busboy.emit (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:32204:33)
    at PartStream.onEnd (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:32528:15)
    at PartStream.emit (node:events:390:22)
    at Dicer.onPart (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:32386:13)
    at Dicer.emit (node:events:378:20)
    at Dicer.module.exports../node_modules/dicer/lib/Dicer.js.Dicer.emit (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:45439:35)
    at Dicer.module.exports../node_modules/dicer/lib/Dicer.js.Dicer._oninfo (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:45540:12)
    at SBMH.<anonymous> (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:45486:10)
[nodemon] app crashed - waiting for file changes before starting...

My Attempts to solve

Sorry I am not sure if this actually a problem with graphql-upload or webpack or something else. I also noticed that my issue looks similar to this issue, but I didn’t really understand if there were any fixes to that issue and if indeed it is the same issue I am facing.

I tried to upgrade webpack (branch upgraded-packages) but this made the problem worse as I get this issue when I start the server

TypeError: Cannot read property 'graphql' of undefined
    at getPeerDependencyGraphQLRequirement (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:104216:44)
    at Object.ensureInstalledCorrectGraphQLPackage (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:104221:32)
    at Function.checkForErrors (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:103346:27)
    at Function.generateFromMetadataSync (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:103325:14)
    at Function.generateFromMetadata (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:103315:29)
    at Object.buildSchema (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:103940:61)
    at /Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:99831:41
    at Generator.next (<anonymous>)
    at /Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:99819:71
    at new Promise (<anonymous>)
    ```
    
   Any help would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ziggy6792commented, Aug 17, 2021

Hi @rickklaasboer

Thanks for your input. I would really like to get webpack5 working.

I tried your suggestion and pushed to branch webpack5

resolve: {
      extensions: ['.mjs', '.ts', '.js'],
      alias: {
        graphql$: path.resolve(__dirname, './node_modules/graphql/index.js'),
        isobject$: path.resolve(__dirname, './node_modules/isobject/index.cjs.js'),
      },
      plugins: [
        new TsconfigPathsPlugin({
          /* options: see below */
        }),
      ],
    },

However I still get the same error when I start

TypeError: Cannot read property 'graphql' of undefined
   at getPeerDependencyGraphQLRequirement (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:115757:44)
   at Object.ensureInstalledCorrectGraphQLPackage (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:115762:32)
   at Function.checkForErrors (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:114887:27)
   at Function.generateFromMetadataSync (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:114866:14)
   at Function.generateFromMetadata (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:114856:29)
   at Object.buildSchema (/Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:115481:61)
   at /Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:111372:41
   at Generator.next (<anonymous>)
   at /Users/sive/Documents/workspace/graphql-file-uploads/dist/index.js:111360:71
   at new Promise (<anonymous>)

Thanks

1reaction
ziggy6792commented, Aug 16, 2021

Hey @jaydenseric

I worked it out with esbuild I just needed to use an extra plugin @anatine/esbuild-decorators

Thanks again for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express application crashes when it is built with webpack
I am trying to use graphql-upload in a typescript express app (graphql api) built with webpack. When I run with ts-node my app...
Read more >
Troubleshooting build errors and crashes - Expo Documentation
This particular error means that the app is importing ./src/Routes and it is not found. The cause could be that the filename case...
Read more >
Eight Practices in React That Will Crash Your App in the Future
If you're currently building an application using react or thinking of using react for upcoming projects, then this tutorial is for you.
Read more >
How to fix the Whitescreen After a Static Deployment with ...
Specifiying “homepage” Now that we told your app it's base URL, run npm run build again and copy the app to your web...
Read more >
Untitled
The built-in Photos app on Mac offers several useful photo editing tools. ... May 30, 2019 · Before start learning react image or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found