knockout-apollo

A knockoutjs extension to connect to a GraphQL endpoint through an ApolloClient instance

Usage no npm install needed!

<script type="module">
  import knockoutApollo from 'https://cdn.skypack.dev/knockout-apollo';
</script>

README

knockout-apollo

A knockoutjs extension to connect to a GraphQL endpoint through an ApolloClient instance

Approach

  • A thin wrapper around an instance of the ApolloClient class for GraphQL queries, mutations and subscriptions
  • Utilises the structure and loading features of ko.plus for queries and mutations

How it works

Attaches additional methods to Observables/Observable Arrays via a Custom Function. This library is strongly influenced by Vue-Apollo v1.

Requirements

Documentation

Index

Demo

To run a demo in localhost open a terminal and:

  • git clone https://github.com/AntonyThorpe/knockout-apollo.git.
  • And cd knockout-apollo and type npm install.
  • Then npm run test (we use Meteor Tests as a server for the demo)
  • To update any of the demo files open a new terminal and npm run watch to save changes to dist/demo.js.
  • Once Meteor is up and running open a third terminal, cd to the project root and npm run demo to open in Firefox.

Tests

In the terminal cd to the tests folder and meteor test --driver-package=practicalmeteor:mocha --port 3002. Or, from project root, npm run tests.

Creating a knockout-apollo min bundle

  • Then npm run build

Contributions

Pull requests are most welcome!

Support

None sorry.

Change Log

File

Licence

MIT

Links