Skip to content

Commit

Permalink
refactor(testUpload)
Browse files Browse the repository at this point in the history
Simply example usage within test.

Inclusion of the GraphQLUpload scalar within the resolver map is only necessary when merging an executable "local" subschema, as if the subschema has the original GraphqlUpload scalar defined, it will throw when attempting to serialize after it is merged into the gateway. The custom GraphqlUpload scalar can be used in that case to avoid that either within the local subschema or within the gateway.

In this case, the subschema is remote, and so the subschema custom scalar is imported with the default serialize method that does not throw.
  • Loading branch information
yaacovCR committed Jan 9, 2020
1 parent bd60b3f commit 49d8fcd
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/test/testUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import { AddressInfo } from 'net';
import { Readable } from 'stream';
import express, { Express } from 'express';
import graphqlHTTP from 'express-graphql';
import { graphqlUploadExpress } from 'graphql-upload';
import { GraphQLUpload, graphqlUploadExpress } from 'graphql-upload';
import FormData from 'form-data';
import fetch from 'node-fetch';
import { buildSchema } from 'graphql';
import { SubschemaConfig } from '../Interfaces';
import { createServerHttpLink } from '../links';
import { makeExecutableSchema } from '../makeExecutableSchema';
import { GraphQLUpload } from '../scalars';
import { mergeSchemas, delegateToSchema } from '../stitching';
import { mergeSchemas} from '../stitching';

function streamToString(stream: Readable) {
const chunks: Array<Buffer> = [];
Expand Down Expand Up @@ -105,22 +104,6 @@ describe('graphql upload', () => {

const gatewaySchema = mergeSchemas({
schemas: [subSchema],
resolvers: {
Mutation: {
upload: async (root, args, context, info) => {
const result = await delegateToSchema({
schema: subSchema,
operation: 'mutation',
fieldName: 'upload',
args,
context,
info,
});
return result;
}
},
Upload: GraphQLUpload,
},
});

const gatewayApp = express().use(
Expand Down

0 comments on commit 49d8fcd

Please sign in to comment.