Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working anymore with graphql-upload #1372

Closed
Tjerk-Haaye-Henricus opened this issue Oct 24, 2022 · 3 comments
Closed

Not working anymore with graphql-upload #1372

Tjerk-Haaye-Henricus opened this issue Oct 24, 2022 · 3 comments
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved

Comments

@Tjerk-Haaye-Henricus
Copy link

Tjerk-Haaye-Henricus commented Oct 24, 2022

Hey There,

first of all thanks for this awesome library.

I'm running into issues by using graphql-upload together with type-graphql.

import { logger } from '@zeou/utils/logger'
import { sendToS3 } from '@zeou/utils/s3Client'
import GraphQlUpload from 'graphql-upload/GraphQLUpload.mjs'
import Upload from 'graphql-upload/Upload.mjs'
import { Arg, Mutation, Query } from 'type-graphql'
import { Image } from './Image.js'

export class FileResolver {
  @Mutation(() => Image)
  async uploadImage(
    @Arg('file', () => GraphQlUpload)
    { createReadStream, filename }: Upload,
  ) {
    const key = filename
    try {
      const result = await sendToS3({ key, body: createReadStream() })
      logger.info(result)
    } catch (error) {
      logger.error((error as Error).message)
    }
  }
}

With this code on the console i got the following errors.

 CannotDetermineGraphQLTypeError: Cannot determine GraphQL input type for argument named 'file' of 'uploadImage' of 'FileResolver' class. Is the value, that is used as its TS type or explicit type, decorated with a proper decorator or is it a proper input value?

All with this tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "allowJs": false,
    "baseUrl": ".",
    "declaration": true,
    "declarationMap": true,
    "emitDeclarationOnly": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "jsx": "react",
    "lib": ["es2018", "esnext.asynciterable", "dom"],
    "module": "ESNext",
    "moduleResolution": "nodenext",
    "removeComments": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,

    "strictPropertyInitialization": false,
    "target": "es2018",
    "types": ["react", "jest", "node"]
  }
}



merged with this one 

{
  "extends": "../../../tsconfig.base.json",
  "compilerOptions": {
    "outDir": "build"
  },
  "include": ["source"],
  "exclude": ["node_modules", "build"]
}

Environment (please complete the following information):

  • OS: Mac
  • Node 17
  • Package version ^1.1.1
  • TypeScript version ^4.8.4
@MichalLytek
Copy link
Owner

type-graphql is doing type instanceof GraphQLScalarType check. Please ensure you have a single graphql instance in your node_modules. Maybe graphql-upload is using it's own graphql@16.

@MichalLytek MichalLytek added Question ❔ Not future request, proposal or bug issue Need More Info 🤷‍♂️ Further information is requested labels Oct 25, 2022
@jaydenseric
Copy link

graphql-upload has a graphql peer dependency of ^16.3.0:

https://github.com/jaydenseric/graphql-upload/blob/e01b5d5541760d529b06c900883c5fa7febcff00/package.json#L53

So perhaps this type-graphql issue is relevant:

#1100

@Tjerk-Haaye-Henricus
Copy link
Author

It's working after updating to type-graphql@2... 🚀 We can close this issue. Thanks a lot for helping 🙏

@MichalLytek MichalLytek added Solved ✔️ The issue has been solved and removed Need More Info 🤷‍♂️ Further information is requested labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❔ Not future request, proposal or bug issue Solved ✔️ The issue has been solved
Projects
None yet
Development

No branches or pull requests

3 participants