-
Notifications
You must be signed in to change notification settings - Fork 73
Support of multiple datasources #2011
Comments
/cc @craicoverflow, @wtrocki |
Totally possible now thru data providers. Based on model we can pick different data provider etc. |
Fully onboard with this. There was similar issue for the old runtime API - #1025 |
This can be achieved simple enough from the user code: import { KnexDBDataProvider } from '@graphback/runtime-knex';
import { MongoDBDataProvider } from '@graphback/runtime-mongo';
const { typeDefs, resolvers, contextCreator } = buildGraphbackAPI(modelDefs, {
dataProviderCreator: (model: ModelDefinition) => {
if (['Note', 'Comment'].includes(model.graphqlType.name)) {
return new KnexDBDataProvider(model, Knex({...}));
} else {
return new MongoDBDataProvider(model, db);
}
}
}); Is there a need to create a helper for this when it is so easily achieved? |
Right, this should have been also mentioned as an alternative and viable solution. I was thinking more of a declarative way to achieving this. i.e a db name is declared on model, and auto-magically the "helper" will handle which database provider to instantiate. |
Otherwise, we are fine documenting this option now. |
Is your feature request related to a problem? Please describe.
Being able to attach certain models in one database (e.g a Postgres schema, database), and other in a different database e.g mongodb database.
Describe the solution you'd like
Describe alternatives you've considered
To achieve this, users have to setup two separate or more APIs, one for each database.
The text was updated successfully, but these errors were encountered: