apollographql/supergraph-demo

When will the apollo gateway be able to consume a supergraph?

gabsn opened this issue ยท 6 comments

gabsn commented

The schema composition at runtime doesn't allow to use the apollo gateway as a lambda function because it takes too much time at startup.

Therefore I'm in the hope to be able to do this graph composition at build-time instead.

When do you think we'll be able to do so?

This runtime thing is a real blocker to me and I'm considering other federation solutions that do not have this requirement.

Thx

When do you think we'll be able to do so?

Hi @gabsn ๐Ÿ‘‹ good news, you can do this today! ๐Ÿš€

Now, instead of passing serviceList which did dynamic composition in the Gateway at run-time, you can do static composition at build-time and feed that to Apollo Gateway via supergraphSdl. This has been supported since Gateway v0.26.x which was released back in April '21 ahead of Apollo GraphQL Summit. ๐Ÿ™‚

Static composition and using supergraphSdl in the Gateway is covered in:

We should definitely add a Lambda example for the Gateway -- Apollo static composition at build-time is perfect for that. Note that Lambda functions are often cached by the cloud provider, so they can resemble a longer running container where Managed Federation and the Apollo Uplink can help deliver supergraph schema changes very quickly to cached Lambda functions so they can update in place, without the latency delay introduce by cloud provider Lambda function caching (which can often take 5 or 10 minutes for Lambda functions to recycle, especially if your Gateway is seeing traffic).

Would love to collaborate on adding a Serverless Gateway example here using a supergraph composed at build-time. You should be able to use router/index.js in this repo and run that as a serverless function, using either an embedded supergraph schema or using managed federation which helps speed supergraph schema delivery when cloud providers are caching Lambda functions.

gabsn commented

Thx @prasek for your quick answer! Will experiment with this and then I can open a PR to add the example!

@gabsn sounds great, looking forward to it! ๐Ÿ™

Leaving this open for a Serverless/Lambda example.

gabsn commented

Hi, I have a bit of time to work on this if you want. I'm a bit confused with the repo structure. Where should I put the serverless example?

Maybe in a serverless-example at the root of the directory?

Thanks for the contribution, added docs for this as well:
https://github.com/apollographql/supergraph-demo#serverless