apollographql / federation

🌐  Build and scale a single data graph across multiple services with Apollo's federation gateway.
https://apollographql.com/docs/federation/
Other
659 stars 248 forks source link

Multi-tenancy for Apollo Federation #2569

Open MitchK opened 5 years ago

MitchK commented 5 years ago

I got very excited when I learned about Apollo Federation.

One huge use case that I see for Apollo Federation is to allow multi-tenancy for the Apollo Gateway. This would mean that external stakeholders have the ability to dynamically register their federated service and make customizations to an existing schema, but only within their own realm.

Think of a cloud enterprise service software company that wants to allow its customers and partners to extend its "common data model" dynamically, without disrupting other tenants.

I just got started with Apollo Federation, so please let me know if this is already supported or does not make sense in any way.

From my understanding of Apollo Federation, this could be possible deploying one gateway per tenant that treats a central gateway server as a federated service, plus all the custom federated services the customer wants to register. However, wouldn't be true multi-tenancy.

Screen Shot 2019-08-30 at 2 57 33 PM

To make operations and life cycle management easier, it would be nice if this could be achieved within one single Apollo Gateway and so-called "Realms". Conceptually (with static configuration), this could look like this:

const gateway = new ApolloGateway({
  globalServiceList: [
    { name: 'hr', url: 'http://...' },
    { name: 'finance', url: 'http://...' },
  ],
  realms: [{
    name: 'tenant1',
    serviceList: [{
      name: 'hr-extension', url: 'http://...'
    }, {
      name: 'finance-extension', url: 'http://...'
    }]
  },
  {
    name: 'tenant1',
    serviceList: [{
      name: 'hr-extension', url: 'http://...'
    }, {
      name: 'finance-extension', url: 'http://...'
    }]
  }]
});

Together with dynamic realm registration at runtime:

Screen Shot 2019-08-30 at 2 57 37 PM

Have there been thoughts in this direction already?

FrankTaylorLieder commented 3 years ago

@MitchK Did you make any progress on solving this problem? Either with Apollo or using alternative approaches?

I have what looks like a similar requirement. I want to use GraphQL as a per-tenant extension mechanism, but don't want to have to host independent GraphQL gateway instances per tenant.