feat: moved up the state logic for graphql query change

This commit is contained in:
Anoop M D
2022-01-18 21:55:22 +05:30
parent 2f222aebde
commit 3133f5e253
4 changed files with 28 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ const SIDEBAR_COLLECTION_ITEM_CLICK = "SIDEBAR_COLLECTION_ITEM_CLICK";
const REQUEST_TAB_CLICK = "REQUEST_TAB_CLICK";
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
const REQUEST_URL_CHANGED = "REQUEST_URL_CHANGED";
const REQUEST_GQL_QUERY_CHANGED = "REQUEST_GQL_QUERY_CHANGED";
const RESPONSE_RECEIVED = "RESPONSE_RECEIVED";
const SEND_REQUEST = "SEND_REQUEST";
const SENDING_REQUEST = "SENDING_REQUEST";
@@ -16,6 +17,7 @@ export default {
REQUEST_TAB_CLICK,
REQUEST_TAB_CLOSE,
REQUEST_URL_CHANGED,
REQUEST_GQL_QUERY_CHANGED,
RESPONSE_RECEIVED,
SEND_REQUEST,
SENDING_REQUEST,

View File

@@ -73,6 +73,21 @@ const reducer = (state, action) => {
});
}
case actions.REQUEST_GQL_QUERY_CHANGED: {
return produce(state, (draft) => {
const collection = find(draft.collections, (c) => c.id === action.collectionId);
if(collection) {
let flattenedItems = flattenItems(collection.items);
let item = findItem(flattenedItems, action.requestTab.id);
if(item) {
item.request.body.graphql.query = action.query;
}
}
});
}
case actions.ADD_NEW_HTTP_REQUEST: {
return produce(state, (draft) => {
const uid = nanoid();