From ba4ceb3434233f7aa76a8492ddefa6fde0217fe2 Mon Sep 17 00:00:00 2001 From: yaacovCR Date: Wed, 8 Jan 2020 22:07:25 -0500 Subject: [PATCH] refactor(testUpload) 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. --- src/test/testUpload.ts | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/test/testUpload.ts b/src/test/testUpload.ts index 2e5f104b76f..35e3298a19a 100644 --- a/src/test/testUpload.ts +++ b/src/test/testUpload.ts @@ -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 = []; @@ -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(