prime icon indicating copy to clipboard operation
prime copied to clipboard

[Feature proposal] Schema stitching

Open Dorkside opened this issue 6 years ago • 3 comments

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.

Dorkside avatar Feb 20 '19 08:02 Dorkside

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}`);
  });
});

birkir avatar Feb 25 '19 14:02 birkir

We may want to expose better API to get the actual Prime module.

Something like

import { createPrimeModule } from '@primecms/core';

const PrimeModule = createPrimeModule();

birkir avatar Feb 25 '19 14:02 birkir

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.

Dorkside avatar Feb 26 '19 09:02 Dorkside