# Refactoring Backlog

**URL:** <https://discuss.dgraph.io/t/refactoring-backlog/7932>\
**Category:** Ratel\
**Tags:** untagged, ratel\
**Created:** [September 17, 2018, 6:48pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932 "2018-09-17T18:48:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 17, 2018, 6:48pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/1 "2018-09-17T18:48:10Z")

</div>

**Moved from GitHub [ratel/21](https://github.com/dgraph-io/ratel/issues/21)**

_Posted by_ [paulftw](https://github.com/paulftw):

### Implement proper Redux in FrameItem

Currently GraphContainer is a container, FrameItem is not.  
However, FrameItem is doing query execution and processing, storing it all in internal state (not redux).

Apart from violating ‘pure redux’ conventions this introduces several problems:

- child components depend on parent to do logic for them
- changing behaviour is not obvious: FrameItem has to be updated to add any new feature
- it’s hard to find where certain logic is - it’s not always in reducers and fetch results are not in store

Overall this problem slows down development

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 17, 2018, 9:28pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/2 "2018-09-17T21:28:38Z")

</div>

[paulftw](https://github.com/paulftw) _commented_ :

FrameSession is immediate child of FrameItem and does redux-style state management ops, FrameItem does fetching of queries but stores everything in the state.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 17, 2018, 11:25pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/3 "2018-09-17T23:25:59Z")

</div>

[paulftw](https://github.com/paulftw) _commented_ :

Approximate steps to fix:

1. make FrameItem connected
2. Move Frameitem state into redux store
3. make FrameSession presentational - disconnect FrameSession and move its dispatchers into FrameItem
4. maybe find entirely new home for FrameItem logic
5. ???
6. Profit!

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 19, 2018, 6:59pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/4 "2018-09-19T18:59:49Z")

</div>

[paulftw](https://github.com/paulftw) _commented_ :

Extra task:

In FrameLayout.js there’s changeCollapseState function. It dispatches an action, but also emits callbacks.  
It has a logic block: if I’m dispatching “collapse frame” - do collapse callback. If I’m dispatching “expand frame” - do a callback that will fetch a query.

There are multiple anti patterns in this code:

- doing logic in dispatcher,
- frame fetching being imperative not declarative,
- FrameItem is stateful and that state is managed by external, often child, components.

fix: make FrameItem self contained and reactive to prop changes. it must be a state machine controlled by changing props or redux store.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [September 19, 2018, 7:12pm UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/5 "2018-09-19T19:12:39Z")

</div>

[paulftw](https://github.com/paulftw) _commented_ :

Extra ^ 2:

FrameItem is single component for query frames, mutation frames, alter frames. and error messages.  
With inheritance pattern it can be broken down into multiple simpler independent components.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 3:12am UTC](https://discuss.dgraph.io/t/refactoring-backlog/7932/6 "2020-07-11T03:12:34Z")

</div>

Closed on July 11, 2020, 3:12am UTC


