prime
prime copied to clipboard
[Feature proposal] Schema stitching
How complicated do you think it would be to allow for schema sitiching ?
Maybe it could be another PrimeCMS instance at first to reduce the scope, and then evolve towards a more fully-fledged implementation.
The end idea would be to allow adding a stitched model to our currently edited one, having multiple microservices of PrimeCMS all connected together.
You can stitch by yourself with graphql-modules, but the source of truth should not be Prime at that point but rather some other entrypoint acting as the root module.
Something like this would work:
import { GraphQLModule } from '@graphql-modules/core';
import { createExternal } from '@primecms/core/modules/external';
import { connect } from '@primecms/core/utils/connect';
connect(process.env.DATABASE_URL).then(connection => {
const PrimeModule = await createExternal(connection);
// other modules
// const YourModule = ...
// const BlehModule = ...
const module = new GraphQLModule({
imports: [PrimeModule, YourModule, BlehModule],
});
const server = new ApolloServer({
playground: true,
...module,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
});
We may want to expose better API to get the actual Prime module.
Something like
import { createPrimeModule } from '@primecms/core';
const PrimeModule = createPrimeModule();
Ok, awesome, As soon as I get some time for a bit of R&D I'll dive into that. Thanks for the updates and the good work.