Update Data Source Metadata
What's about to happen?
In your day-to-day development cycle, there's a good chance your data source's schema will change. When this happens, you'll need to update your data connector configuration and the supergraph metadata to match these schema changes.
![Create source metadata](/docs/3.0/assets/images/create-metadata-4fafa4c2ed81ee1143322ff856da954e.png)
Step 1. Introspect the data source
- The DDN CLI, VS Code extension, and Docker installed
- A new or existing supergraph
- A new or existing subgraph
- A connector initialized.
We can run the connector introspect
command to have the CLI introspect the data source schema, update the
configuration of the connector and also update the corresponding DataConnectorLink
metadata object for the supergraph
to be able to interact with the connector.
ddn connector introspect my_connector
After this command runs, you can open your my_subgraph/metadata/my_connector.hml
file and see the DataConnectorLink
schema completely updated for you to match your data source's schema changes 🎉.
Step 2. Update or add models
If an existing model's schema changed in your data source, update it to ensure your Hasura metadata matches the data source's schema.
ddn model update <model-name>
If you have a large number of models and want to update them en masse, we've got you covered.
ddn model update "*"
You'll see the CLI output information about which models are the same, and which have changed.
Alternatively, if you have models which need to be added (e.g., a new table in your underlying data source), you'll need
to create hml
files for these resources.
ddn model add <connector-link-name> <collection-name>
If you have a large number of models and want to add them en masse, we've got you covered just as before.
ddn model add <connector-name> '*'
ddn command add <connector-name> '*'
ddn relationship add <connector-name> '*'
You'll see the CLI output information about which models are the same, and which have changed.
What did this do?
By updating the my_connector.hml
file, we've provided Hasura with a link between our original data source and the
types which we'll eventually expose via our API.
ddn supergraph build local
Next steps
With our data source connected and all of our models tracked, we can move on to add custom authorization rules using permissions, incorporate custom business logic, or create relationships across data sources!