Closed jorgev259 closed 2 years ago
What might be happening is that there are multiple installations/versions of graphql-upload
, and one is being used for the middleware and another is being used for the Upload
scalar. This causes a conflict; there should be only one version of graphql-upload
integrated.
If you're using an old version of Apollo Server that automatically integrates an outdated version of graphql-upload
, you need to opt out. From memory, you can do that via an Apollo Server contractor option uploads: false
.
Once you have disabled Apollo's integration, follow the setup instructions in the graphql-upload
readme carefully.
uploads is already set to false, and apollo-server-micro in my current installation seems to be using 3+ apollo-server
Silly question, but is what you're using the variable $cover
for in the GraphQL query correctly an Upload
scalar? Maybe you're trying to use a file where some other kind of type is expected.
It is, yarn why
showed the direct graphql-upload dependency as the only one. But it seems a similar problem as other similar issues was the culprit.
Solved by using the full path to import the Scalar: import { GraphQLUpload } from 'node_modules/graphql-upload/public/index.js'
Sounds like something weird about how dependencies are installed and resolved in your project.
BTW, it's best to skip the index module and directly deep import the thing you need:
import GraphQLUpload from 'graphql-upload/public/GraphQLUpload.js';
Or for your funny workaround:
import GraphQLUpload from 'node_modules/graphql-upload/public/GraphQLUpload.js';
When uploading a file im getting the following error.
Server code:
Resolvers object:![imagen](https://user-images.githubusercontent.com/19596334/143669609-2aff36d5-e4fc-4892-8f3a-68ee12843f99.png)