diff --git a/gateway-js/CHANGELOG.md b/gateway-js/CHANGELOG.md index ec8d06b7fb..12fdf84237 100644 --- a/gateway-js/CHANGELOG.md +++ b/gateway-js/CHANGELOG.md @@ -6,6 +6,7 @@ * Reduce interface expansion for types contained to a single service [#3582](https://github.com/apollographql/apollo-server/pull/3582) * Instantiate one `CachedFetcher` per gateway instance. This resolves a condition where multiple federated gateways would utilize the same cache store could result in an `Expected undefined to be a GraphQLSchema` error. [#3704](https://github.com/apollographql/apollo-server/pull/3704) +* Gateway: minimize downstream request size [#3737](https://github.com/apollographql/apollo-server/pull/3737) # v0.11.6 diff --git a/gateway-js/src/__tests__/executeQueryPlan.test.ts b/gateway-js/src/__tests__/executeQueryPlan.test.ts index 2069f88df9..a75f59eea9 100644 --- a/gateway-js/src/__tests__/executeQueryPlan.test.ts +++ b/gateway-js/src/__tests__/executeQueryPlan.test.ts @@ -144,7 +144,7 @@ describe('executeQueryPlan', () => { ); expect(response).toHaveProperty( 'errors.0.extensions.query', - '{\n me {\n name\n }\n}', + '{me{name}}', ); expect(response).toHaveProperty('errors.0.extensions.variables', {}); }); diff --git a/gateway-js/src/__tests__/gateway/buildService.test.ts b/gateway-js/src/__tests__/gateway/buildService.test.ts index aea121bf42..564d101962 100644 --- a/gateway-js/src/__tests__/gateway/buildService.test.ts +++ b/gateway-js/src/__tests__/gateway/buildService.test.ts @@ -85,11 +85,7 @@ it('correctly passes the context from ApolloServer to datasources', async () => expect(fetch).toHaveFetched({ url: 'https://api.example.com/foo', body: { - query: `{ - me { - username - } -}`, + query: `{me{username}}`, variables: {}, }, headers: { diff --git a/gateway-js/src/executeQueryPlan.ts b/gateway-js/src/executeQueryPlan.ts index a052ccbb11..3abc94a23d 100644 --- a/gateway-js/src/executeQueryPlan.ts +++ b/gateway-js/src/executeQueryPlan.ts @@ -14,6 +14,7 @@ import { TypeNameMetaFieldDef, VariableDefinitionNode, GraphQLFieldResolver, + stripIgnoredCharacters, } from 'graphql'; import { Trace, google } from 'apollo-engine-reporting-protobuf'; import { GraphQLDataSource } from './datasources/types'; @@ -289,7 +290,7 @@ async function executeFetch( operation: OperationDefinitionNode, variables: Record, ): Promise { - const source = print(operation); + const source = stripIgnoredCharacters(print(operation)); // We declare this as 'any' because it is missing url and method, which // GraphQLRequest.http is supposed to have if it exists. let http: any;