-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apollo-server-lambda: Root ("/") path breaks server #5462
Comments
Thanks, I'll take a look. To be clear: are you seeing this when running your serverless app locally or when deployed to Lambda or both? |
I'll try to reproduce soon (or maybe tomorrow, I'm nearing the end of my day), but I think this is working as intended. By default, all versions of ApolloServer other than This is not particularly well-documented right now though (at https://www.apollographql.com/docs/apollo-server/deployment/lambda/ or https://www.apollographql.com/docs/apollo-server/integrations/middleware/#apollo-server-lambda or https://www.apollographql.com/docs/apollo-server/api/apollo-server/#framework-specific-middleware-function). |
We should probably at least get this better documented in the migration guide (and generally document expressGetMiddlewareOptions). In AS2, apollo-server-lambda only cared about its path to check for health checks. In AS3 it works just like the non-serverless framework integrations: there's a Frankly I think the While AS3 is officially released, I think we can make some quick changes over the next week that align the serverless integrations back with AS2 behavior. I think we could change the serverless integrations so that (like |
@glasser In response to your first question, it was happening both locally and in Lambda. If the requirement to get it working is just adding something like the |
In Apollo Server 2, none of the serverless integrations paid much attention to the HTTP request path (other than for health checks). In AS3 we rewrote the Lambda and GCF integrations on top of `apollo-server-express` so they inherited ASE's behavior of only responding under `/graphql`. This doesn't make that much sense for serverless integrations, where paths are typically specified in the API Gateway (etc) configuration, and where functions typically do one thing. (Frankly, it doesn't make much sense for a default path to be built in to the framework integrations either rather than letting you specify the path when you attach the middleware to your app, but changing that in AS3 would have been one backwards-incompatible change too many). So we're going to change how AS3 works by saying that serverless integrations serve on `/`. This is technically incompatible with 3.0.0 but hey, it just came out, and this is more compatible with AS2. Improve some other docs while we're at it. Fixes #5472.
Fix released in 3.0.1 (by #5497). |
When I use the example posted by @Alec2435, I got the following error: {
"body": "POST body missing, invalid Content-Type, or JSON object has no keys.",
"isBase64Encoded": false,
"multiValueHeaders": {
"access-control-allow-origin": ["*"],
"content-length": ["68"],
"content-type": ["text/html; charset=utf-8"],
"etag": ["W/\"44-LstwwwiSrcEeuZb+mu4TKVPIfxQ\""],
"x-powered-by": ["Express"]
},
"statusCode": 400
} I'm executing this code: const event = generateEvent({
query: `
query {
hello
}
`,
});
const result = await graphqlHandler(event, context);
expect(JSON.parse(result.body).data.hello).toEqual("Hello world!"); Where the event is generated by: exports.generateEvent = body => ({
body: body ? JSON.stringify(body) : null,
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
},
multiValueHeaders: {},
httpMethod: "POST",
isBase64Encoded: false,
path: "/",
pathParameters: null,
queryStringParameters: null,
multiValueQueryStringParameters: null,
stageVariables: null,
requestContext: {
accountId: "1234567890",
apiId: "appid",
httpMethod: "POST",
identity: {},
authorizer: {},
protocol: "HTTP/1.1",
path: "/",
stage: "dev",
requestId: "test",
requestTimeEpoch: 0,
resourceId: "none",
resourcePath: "/",
},
resource: "/",
});
exports.context = {
callbackWaitsForEmptyEventLoop: false,
functionName: "",
functionVersion: "latest",
invokedFunctionArn: "aws:arn:",
memoryLimitInMB: "128",
awsRequestId: "test",
logGroupName: "test",
logStreamName: "test",
getRemainingTimeInMillis() {
return 0;
},
done() {
// do nothing.
},
fail() {
// do nothing.
},
succeed() {
// do nothing.
},
} What am I doing wrong? In v2 it works perfectly! |
(followed up with @tiagocpeixoto in #5504) |
Hi, My setup looks like :
in the server less offline logging I can see that an endpoint has been setup:
when I try calling the endpoint from the browser I get Works fine if I give the path a route .. deps :
any ideas? |
Do you know if there is anyway to remove the environment from end of the url |
@apatelvero This seems like a question about the |
Package/Version
This bug relates to apollo-server-lambda 3.0 (this issue did not appear in any 2.x releases)
Expected Behavior
apollo-server-lambda runs regardless of the specific http path used for it within the
serverless.yml
configuration.Actual Behavior
I built an example based exactly on the steps found on the tutorial page with the only change being that I used an http path of
/
instead ofgraphql
withinserverless.yml
. This is so that the GraphQL server runs at the root of the domain instead of at/graphql
. When run, this results in the server responding to all requests with the following message:This does not happen if I revert back to a path of
graphql
.In our use case, we simply had defaulted to using the root url for GraphQL and had done so with all previous releases, so we were hoping to keep the paradigm to avoid unnecessary changes to our client applications. It's my understanding that a path of
/
is the correct way to reference the root url within serverless configurations as it's worked before.Reproduction Steps
An example for reproduction can be found at pearljobs/apollo-serverless-bug
The text was updated successfully, but these errors were encountered: