Skip to content

Commit

Permalink
Look in event.path first when selecting endpoint for GraphQL Playgrou…
Browse files Browse the repository at this point in the history
…nd on Lambda, and check for null (#1527)

* 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

* Add to changelog
  • Loading branch information
stubailo authored and James Baxley committed Aug 13, 2018
1 parent fec517d commit 8ca7380
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion packages/apollo-server-lambda/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down

0 comments on commit 8ca7380

Please sign in to comment.