Git Product home page Git Product logo

helios's Introduction

Helios

A Chrome Dev Tool for tracking state in Apollo and Vue.js.

Getting Started

To use Helios install our Chrome Dev Tool. In your Vue application, bind our custom function to your component . Wrap the built-in Apollo mutate method with the custom method from our library.

After that the Chrome Dev Tool observes your application, allowing it to pass messages between the browser and Helios. Helios captures the Apollo state immediately before and immediately after the mutation and does a diff on those two objects, organizing them by mutation type, and displays the changes in the dev tool panel.

Prerequisites

Google Chrome, the Helios extension and the code below in a util file (Helios.js)

Installing

After installing the Helios extension, create a file in your project called Helios.js containing the following code:

export default function ApolloDev (configObj) {
  const prevState = JSON.parse(
    JSON.stringify(this.$apolloProvider.clients.defaultClient.cache.data.data))
  return new Promise((resolve, reject) => {
    this.$apollo.mutate(configObj).then(res => {
      const newState = this.$apolloProvider.clients.defaultClient.cache.data.data
      window.postMessage([prevState, newState], '*')
      resolve(res)
    })
  })
}

Now import Helios.js wherever you make state mutations

import ApolloDev from "../utils/Helios";

Finally, bind the function and make your state mutation.

this.ApolloDev = ApolloDev.bind(this);
      this.ApolloDev({
        mutation: CREATE_VOTE_MUTATION,
        variables: {
          userId,
          linkId
        },
        update: (store, { data: { createVote } }) => {
          this.updateStoreAfterVote(store, createVote, linkId);
        }
      });

Built With

  • deep-diff - A diffing tool for determining structural differences between objects
  • Browserify - Dependency bundler
  • Apollo-Client - A fully-featured GraphQL client

Contributing

Fork the repo and create a pull request

Authors

  • Erik Cox - Chrome Dev Tool UI and messaging
  • Stephanie Fong - Designed wrapper function for Apoll retaining original mutate functionality
  • Paul Valderama - Developed diffing function for Apollo state objects

License

This project is licensed under the MIT License

Acknowledgments

helios's People

Contributors

erikcox avatar paulvalderama avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.