Apollo-server: Could not find a declaration file for module 'graphql-upload'

Created on 13 Dec 2018  路  7Comments  路  Source: apollographql/apollo-server

Using apollo-server-express v2.3.0 in a Typescript project produces the following error due to missing typings for the graphql-upload module.

node_modules/apollo-server-core/dist/processFileUploads.d.ts:1:49 - error TS7016: Could not find a declaration file for module 'graphql-upload'. 'node_modules/graphql-upload/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/graphql-upload` if it exists or add a new declaration (.d.ts) file containing `declare module 'graphql-upload';`

1 declare const processFileUploads: typeof import('graphql-upload').processRequest | undefined;
bug 馃殌 shipped 馃К typings

Most helpful comment

Temp solution until they have fixed it:

declare module 'graphql-upload' {
export function processRequest(
request: any,
response: any,
options?: any
): Promise
}

All 7 comments

I have nothing helpful to add, but we have the same issue when we tried to re-deploy our server just now.

Temp solution until they have fixed it:

declare module 'graphql-upload' {
export function processRequest(
request: any,
response: any,
options?: any
): Promise
}

Depending on your compiler settings, you might need:

declare module 'graphql-upload' {
  export function processRequest<T>(
    request: any,
    response: any,
    options?: any
  ): Promise<T>;
}

otherwise, you get this:

@types/vendor.d.ts(15,6): error TS2314: Generic type 'Promise<T>' requires 1 type argument(s)

This is happening in version 2.1.0 too. And breaks all compilation in the code for this version that uses typescript. The package graphql-upload disappears from the npm.

Thanks for reporting this!

Please give 2.3.1 (just published) a try and see if that resolves the problem for you! This certainly supports my belief that integration tests which better test the consumption of Apollo Server would be a welcome addition to this repository.

@apoloa This particular error is certainly something new and reproducible which I wasn't seeing before. That said, sharing the specific error could be helpful because graphql-upload was not used in this project at that time (it was still apollo-upload-server, before 2.3.0.).

@abernix v2.3.1 fixes the issue. Thanks!

@abernix I will check which are the specific version that npm downloads.

Was this page helpful?
0 / 5 - 0 ratings