-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add supergraph endpoint #189
base: master
Are you sure you want to change the base?
Conversation
5738ead
to
bdb6578
Compare
hey @agologan . Thanks for the effort. How is supergraph different from |
router.get('/schema/latest', asyncWrap(schema.composeLatest)); export async function composeLatest(req, res) {
const schema = await getAndValidateSchema(connection, false, false);
return res.json({
success: true,
data: schema,
});
} At a quick glance it just returns the schema wrapper in JSON object, but looking further.. export async function getAndValidateSchema(
trx,
services = false,
validate = true
) {
const schemas = services
? await schemaModel.getSchemaByServiceVersions({ trx, services })
: await schemaModel.getLastUpdatedForActiveServices({ trx });
logger.info(
'Validating schema. Got services schemas from DB transaction..',
{
schemas,
}
);
if (validate && schemas && schemas.length) {
federationHelper.composeAndValidateSchema(schemas);
}
return schemas;
} So Put together By comparison, the new endpoint composes, caches and returns the supergraph to be used directly in a gateway or router. In case of Apollo Router it does not do it's own composition as seen here https://www.apollographql.com/docs/router/migrating-from-gateway#servicelist--introspectandcompose |
please add tests and examples of how its used |
Added a sanity test to LE: Provided a working compose example and updated the examples docs. See: 34ab51a |
Problem
In order to use Apollo Router #162 one needs a composed supergraph to provide to it.
While this can be done using Rover CLI or via @apollo/composition it's not very easy to do it and may require an extra infrastructure component.
Changes
New
/schema/supegraph
that can be passed directly to the router.Endpoint is cached in memory (without other deps), and is invalidated on subgraph changes.
Example Helm values for Apollo Router: