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
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 typenpm 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 todist/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
Licence
Links
- The Anatomy of a GraphQL Query - Apollo Blog by Sashko Stubailo. The code follows these definitions.
- Apollo-Vue - contains good non-React examples
- Meteor-Ticker - Apollo+Meteor app showcasing GraphQL subscriptions in its simplest form