apollographql / apollographql/federation
File upload object is empty in federated gateway but not if called directly on the service
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
After federating a service that implements the upload scalar, for some reason, if I hit that resolver from the federated gateway, the file object is empty.
```
(base) cL:gateway chris$ npm run start-apollos
> bx-gateway@1.0.0 start-apollos /Users/chris/projects/bx/gateway
> concurrently "npm:start-apollo-*"
[start-apollo-data]
[start-apollo-data] > bx-gateway@1.0.0 start-apollo-data /Users/chris/projects/bx/gateway
[start-apollo-data] > NODE_ENV=development node -r ts-node/register ./src/apollos/DataLibrary/index.ts
[start-apollo-data]
[start-apollo-accounts]
[start-apollo-accounts] > bx-gateway@1.0.0 start-apollo-accounts /Users/chris/projects/bx/gateway
[start-apollo-accounts] > node -r ts-node/register ./src/apollos/Accounts/index.ts
[start-apollo-accounts]
[start-apollo-bioref]
[start-apollo-bioref] > bx-gateway@1.0.0 start-apollo-bioref /Users/chris/projects/bx/gateway
[start-apollo-bioref] > node -r ts-node/register ./src/apollos/BioRef/index.ts
[start-apollo-bioref]
[start-apollo-accounts] Account apollo running at http://localhost:9001/
[start-apollo-bioref] BioRef Apollo running at http://localhost:9003/
[start-apollo-data] 🚀 Server ready at http://localhost:9002/graphql
[start-apollo-data] { file: {}, something: 'hello' }
[start-apollo-data] { file: {}, something: 'hello' }
```
But then if I hit the service directly, everything is fine.
```
[start-apollo-data] 🚀 Server ready at http://localhost:9002/graphql
[start-apollo-data] Promise {
[start-apollo-data] { filename: 'test.csv',
[start-apollo-data] mimetype: 'text/csv',
[start-apollo-data] encoding: '7bit',
[start-apollo-data] createReadStream: [Function: createReadStream] } }
```
Is there something I am doing wrong with the apollo-gateway?
For reference,
```
// TypeDefs
export const typeDefs = gql`
scalar Upload
extend type Mutation {
testUpload(file: Upload, something: String): String
}
`;
// *Resolvers
import { GraphQLUpload } from 'graphql-upload';
const testUpload = async (obj, { file }, ctx, info) => {
const { createReadStream } = await file;
console.log(file);
return '';
};
export const resolvers = {
Upload: GraphQLUpload,
Mutation: {
testUpload(obj, args, ctx, info) {
return testUpload(obj, args, ctx, info)
}
},
};
```
For now, I've worked around it by registering another client that directly hits the service instead of the gateway just to do file uploads, but I feel like this defeats the point of federating in the first place.
Any suggestions/guidance would be greatly appreciated!
Contributor guide
Research direction
Reproduce the upload through the federated gateway using the npm run start-apollos entry point and compare it with the direct service request. Start with src/apollos/DataLibrary/index.ts, the Upload scalar using GraphQLUpload, and the gateway path; done means the resolver receives the same filename, mimetype, encoding, and createReadStream data through federation as it does directly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100