-
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/gateway doesn't work with apollo-server-lambda since 0.9.0 #3190
Comments
Reproducible repository here: https://github.com/nihalgonsalves/apollo-server-issue3190 Run curl -d '{"query":"{ hello }"}' -H "Content-Type: application/json" -X POST http://localhost:3000/graphql
> {"data":{"hello":"world"}} On the other branches (gateway-@-0.9.0 & gateway-@-0.9.1), it should fail, on the second request:
You can also go to http://localhost:3000/graphql in a browser to see the same error. |
This is the exact problem I'm facing as well! |
@nihalgonsalves thank you for the great issue report and reproduction. I've confirmed the bug (and also confirmed it doesn't happen for I'll get back to this issue with an update within the week - I'll need to do some digging and probably pick @abernix 's brain in order to understand what might be going on here, as I'm wholly unfamiliar with lambda. In the meantime, any results of further debugging on your end would be welcomed! |
Update: I had originally thought I had a similar issue, albeit in the context of Azure Function, not AWS Lambda. Note that the cause in my case simply was using the wrong URLs for the federated services. For those ending up here for the Azure issue: Use In my Azure Function setup, passing the wrong URL to the gateway, I am getting the same issue, testing on localhost. My function script was using Apollo Gateway ( const gateway = new ApolloGateway({
serviceList: [
{ name: 'YetAnotherAPI', url: 'http://localhost:7071' },
]
});
const server = new ApolloServer({
gateway, subscriptions: false, playground: true, introspection: true
});
exports.graphqlHandler = server.createHandler(); During startup, my Azure Function complained:
My fix was to correct the API URL by specifying {
"version": "2.0",
"extensions": {
"http": {
"routePrefix": ""
}
},
"watchDirectories": [
"dist"
]
} Alternatively, I could just have specified the path to the API as I have tried Nihal's repo to see if the issue is also URL-related but I couldn't find a similarly simple fix. Next I've tried Apollo Gateway 0.9.1 with my Azure Function setup but I don't have the same issue there... if the URLs are correct. I hope this information is useful for someone anyway. |
@trevor-scheer Any updates on this issue? |
I'm running into this error as well, although it's tied to using the Graph Manager (i.e. no @nihalgonsalves I cloned your repo and saw the reproduction. After hitting that error, I upgraded "dependencies": {
- "@apollo/federation": "^0.8.0",
- "@apollo/gateway": "^0.9.0",
+ "@apollo/federation": "^0.10.2",
+ "@apollo/gateway": "^0.10.7",
"apollo-server": "^2.8.2",
"apollo-server-lambda": "^2.8.2",
"graphql": "^14.5.0" |
@nathanchapman Thanks. It does work now, so I will close this issue. We ended up running it in a container instead, because it seems like the gateway isn't really designed for the lambda execution model (fetching schema updates, caching, eventually: subscriptions, etc). Even if it's being fetched from the Graph Manager, every new concurrent execution will incur a cold start penalty of loading the schema. @trevor-scheer would it make sense to document that the gateway is not intended to be run in a Lambda environment (and other FaaS envs)? |
@nathanchapman were you able to solve your It does work with AWS SAM, but am curious if there's a solution using |
@nihalgonsalves did you find a way to make this work on Lambda? I'd love to push forward with that approach by rendering remote schemas to a file during a build step or something similar but haven't found any references for doing so. |
@cazzer We didn't spend any more time on it and just used a regular container on Fargate ECS. I suspect that it would be technically feasible to do what you propose, but it wouldn't really fit in with the decentralised approach of deploying federated services separately and registering them with Graph Manager. Every time a team wants to deploy, they'd have to trigger the Lambda build and make sure that's okay as well. Or if you use Graph Manager and somehow poll for changes to re-build your Lambda, the team still has to make sure that it succeeded, etc. |
@apollo/gateway
v0.9.0
v0.8.2
The server crashes with "Error: Expected undefined to be a GraphQL schema" when using new gateway version with apollo-server-lambda.
If you call
gateway.load()
manually and pass the schema and executor to the ApolloServer constructor, you get "Error: Apollo Server requires either an existing schema, modules or typeDefs"Here's a minimal reproducible example:
Here's what changed between the versions: b0a9ce0...99f78c6 (from a preliminary look
gateway.load()
seems to be the change that causes the issue).The text was updated successfully, but these errors were encountered: