Changes
We had 2 copies of the same component for a page - one as draft and the other as published. Under this new change, the draft items will be removed and will be saved in the same row as the published item. This will reduce the number of items in the table by a lot.
Back-end
The change entails having to manage the creation and handling of the component to create and provide the data correctly. The creation and updation of the component involves having to map the input data to their draft columns so that the FE doesn't need to change anything. The deletion of a component will contain nullifying the content, position etc of the draft and flagging it as deleted but the published will stay as is. Once the draft is published, if the delete is flagged, the entire component is deleted.
While publishing the component, the contents of the draft columns will be copied to the publisher columns. Any subsequent edit happens in the draft columns.
Front-end
The change to be made by the front end is during fetching of the components. The creation, updation and deletion of the component remains the same. The thing to note is that since the published and draft are no longer different components, there will only be one id or client_reference_id whichever is being used.
The keys for fetching data remains unchanged - content, component_type, position and component_attachment.
The keys remain unchanged for the FE. The response depends on the input. For component creation and updation the draft items will be provided and for page query, the status determines what to respond with.
Sample query
query {
getPage(id: 2965) {
title
status
page_components(status: "draft") {
edges {
node {
id
content
position
component_type
}
}
}
}
}
Sample mutations
Create component
mutation {
pageComponentCreate(page_id: 2965, page_component: {
content: "mnop",
component_type: "text"
}) {
id
position
content
}
}
Update component
mutation {
pageComponentUpdate(id: 29652, page_component: {
position: 2
}) {
id
position
content
}
}
Delete component
The component is deleted. The response would be null. But during the page query, this component will be present with its content until published again.
mutation {
pageComponentDelete(id: 29652) {
id
}
}