feat: add registerChanges method
Exposes registerChanges to apply bulk changes onto the current migration.
Example usage:
const migration = newMigration({
endpoint: "...",
authToken: "...",
});
migration.registerChanges([
{
createModel: {
apiId: "Post",
apiIdPlural: "Posts",
description: "",
displayName: "Post",
previewURLs: [],
},
},
{
createSimpleField: {
apiId: "title",
modelApiId: "Post",
type: "STRING",
displayName: "Title",
description: null,
tableRenderer: "GCMS_SINGLE_LINE",
formRenderer: "GCMS_SINGLE_LINE",
tableExtension: null,
formExtension: null,
formConfig: {},
tableConfig: {},
isList: false,
isLocalized: false,
isRequired: false,
isUnique: false,
isHidden: false,
embeddableModels: [],
visibility: "READ_WRITE",
isTitle: false,
position: 9,
validations: null,
embedsEnabled: null,
},
},
{
createSimpleField: {
apiId: "content",
modelApiId: "Post",
type: "RICHTEXT",
displayName: "Content",
description: null,
tableRenderer: "GCMS",
formRenderer: "GCMS",
tableExtension: null,
formExtension: null,
formConfig: {},
tableConfig: {},
isList: false,
isLocalized: false,
isRequired: false,
isUnique: false,
isHidden: false,
embeddableModels: [],
visibility: "READ_WRITE",
isTitle: false,
position: 10,
validations: null,
embedsEnabled: false,
},
},
{
updateSimpleField: {
apiId: "fileName",
modelApiId: "Migration",
tableRenderer: "GCMS",
},
},
]);
migration.run();
I used GraphQLBatchMigrationChangeInput for better typing, but we may want to change it to MigrationChange if we don't want so strict typing.
size-limit report 📦
| Path | Size | Loading time (3g) | Running time (snapdragon) | Total time |
|---|---|---|---|---|
| dist/index.js | 17.7 KB (+0.1% 🔺) | 354 ms (+0.1% 🔺) | 134 ms (+49.41% 🔺) | 487 ms |
I'd prefer to add some named arguments here, e.g.
registerChanges({changes: []})
What do you think @d-winter ?
This feature would be amazing. Having this level of control will help in solving a lot of the migration issues we have in our team!
Just a small note this basically gives direct access to the underlying api with all it's power. It will give us less control to hide certain fields and will potentially make it harder to make backwards compatible changes.