Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Runtime API couples all models with single datasource #1025

Closed
craicoverflow opened this issue Apr 1, 2020 · 1 comment
Closed

Runtime API couples all models with single datasource #1025

craicoverflow opened this issue Apr 1, 2020 · 1 comment

Comments

@craicoverflow
Copy link

The runtime APIs exposed the server app assumes each model is mapped to a single data-source.

@craicoverflow craicoverflow added this to the Graphback 1.0-beta milestone Apr 1, 2020
@craicoverflow
Copy link
Author

Each model could have their own data source defined.

"""
@model dataSource: 'usersDb'
"""
type User {
  ...
}

"""
@model dataSource: 'shopDb'
"""
type Shop {
  ...
}

would generate the following models.ts array:

export const models = [
  {
    name: "Shop",
    dataSource: "shopDb"
    pubSub: {
      publishCreate: true,
      publishUpdate: true,
      publishDelete: true,
    },
  },
  {
    name: "User",
    dataSource: "usersDb",
    pubSub: {
      publishCreate: true,
      publishUpdate: true,
      publishDelete: true,
    },
  },
]

const dbConfigs = [
{
  name: "shopDb",
  client: "pg",
  default: true,
  config: {
    ...
  }
},
{
  name: "usersDb",
  client: "mongo",
  config: {
    ...
  }
}
]

const services = createDataSources(models, schema, dbConfigs, puSub);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant