Skip to main content
Version: v3.x

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

Step 1. Introspect the data source

Required

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.

Run the following command, updating the referenced name to match your 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>
Have lots of models?

If you have a large number of models and want to update them en masse, we've got you covered.

Run the following:
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.

Run the following:
ddn model add <connector-link-name> <collection-name>
Have lots of new models to add?

If you have a large number of models and want to add them en masse, we've got you covered just as before.

Run the following:
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.

Be sure to create a new build before testing your 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!

Loading...