-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate existing mutations to queries (#1130)
- Loading branch information
Showing
10 changed files
with
50 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...toolpad-app/src/appDomMigrations/index.ts → ...oolpad-app/src/appDom/migrations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...es/toolpad-app/src/appDomMigrations/v1.ts → ...s/toolpad-app/src/appDom/migrations/v1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import invariant from 'invariant'; | ||
import * as appDom from '..'; | ||
import { mapValues } from '../../utils/collections'; | ||
|
||
function replaceMutation(node: any): appDom.AppDomNode { | ||
if (node.type === 'mutation') { | ||
return { | ||
...node, | ||
type: 'query', | ||
parentProp: 'queries', | ||
attributes: { | ||
...node.attributes, | ||
mode: appDom.createConst('mutation'), | ||
}, | ||
}; | ||
} | ||
|
||
return node; | ||
} | ||
|
||
export default { | ||
up(dom: appDom.AppDom): appDom.AppDom { | ||
invariant(dom.version === 1, 'Can only migrate dom of version 1'); | ||
return { | ||
...dom, | ||
nodes: mapValues(dom.nodes, (node) => replaceMutation(node)), | ||
version: 2, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.