From daf43bd7b539de3494fd6ecaf592c1791686c2bf Mon Sep 17 00:00:00 2001 From: Sashko Stubailo Date: Mon, 13 Aug 2018 12:52:16 -0700 Subject: [PATCH 1/2] Look in event.path first, and check for null See here: https://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-api-gateway-request --- packages/apollo-server-lambda/src/ApolloServer.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/apollo-server-lambda/src/ApolloServer.ts b/packages/apollo-server-lambda/src/ApolloServer.ts index 94a58c059dc..1949a43f25f 100644 --- a/packages/apollo-server-lambda/src/ApolloServer.ts +++ b/packages/apollo-server-lambda/src/ApolloServer.ts @@ -119,8 +119,13 @@ export class ApolloServer extends ApolloServerBase { if (this.playgroundOptions && event.httpMethod === 'GET') { const acceptHeader = event.headers['Accept'] || event.headers['accept']; if (acceptHeader && acceptHeader.includes('text/html')) { + const path = + event.path || + (event.requestContext && event.requestContext.path) || + '/'; + const playgroundRenderPageOptions: PlaygroundRenderPageOptions = { - endpoint: event.requestContext.path, + endpoint: path, ...this.playgroundOptions, }; From 892ca32caf597f43a546f3de16cebf1264b8e1ef Mon Sep 17 00:00:00 2001 From: Sashko Stubailo Date: Mon, 13 Aug 2018 12:54:27 -0700 Subject: [PATCH 2/2] Add to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 402eb2003f4..175752ef338 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All of the packages in the `apollo-server` repo are released with the same versi - express, koa: remove next after playground [#1436](https://github.com/apollographql/apollo-server/pull/1436) - Hapi: Pass the response toolkit to the context function. [#1407](https://github.com/apollographql/apollo-server/pull/1407) - update apollo-engine-reporting-protobuf to non-beta [#1429](https://github.com/apollographql/apollo-server/pull/1429) +- Lambda: Look in event.path first when picking endpoint for GraphQL Playground [#1527](https://github.com/apollographql/apollo-server/pull/1527) ### rc.10