Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import gql from 'graphql-tag';
  2.  
  3. const getAppState = gql`
  4. query {
  5. state @client {
  6. appState {
  7. isDarkModeEnabled
  8. }
  9. }
  10. }
  11. `;
  12.  
  13. export default (getState, writeState) => {
  14. return {
  15. Mutation: {
  16. updateAppState(_, appState) {
  17. // get current / initial state from cache
  18. const state = getState(getAppState);
  19.  
  20. const newState = {
  21. ...state,
  22. appState: Object.assign({}, state.appState, appState),
  23. };
  24.  
  25. writeState(newState);
  26. return newState;
  27. },
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement