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.

File object is empty when using apollo federation

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Jul 13, 2019

Thanks @jaydenseric I’ve posted this issue on the apollo-server repo. Hopefully they will be able to fix it!

0reactions
mouhsinelonlycommented, Feb 3, 2020

thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Federation error codes - Apollo GraphQL Docs
If Apollo Gateway encounters an error, composition fails. This document lists subgraph validation and composition error codes, along with their root causes.
Read more >
Apollo Federation subgraph specification
In a federated supergraph, an entity is an object type that can define different fields across multiple subgraphs. You can identify an entity...
Read more >
Error handling - Apollo GraphQL Docs
Code, Description. GRAPHQL_PARSE_FAILED. The GraphQL operation string contains a syntax error. GRAPHQL_VALIDATION_FAILED. The GraphQL operation is not valid ...
Read more >
Federated schema design best practices
Throughout this section, we'll explore some proven best practices for GraphQL schema design with a specific lens on how these practices relate to...
Read more >
API Reference: ApolloServer - Apollo GraphQL Docs
A valid Schema Definition Language (SDL) string, document, or documents ... Object. You can use this field to integrate your server with Apollo...
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 Reddit Thread

No results found

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