https://github.com/cult-of-coders/morpher
Morpher is a small npm library which allows you to work with GraphQL in isomorphic fashion.
https://github.com/cult-of-coders/morpher
Last synced: about 1 month ago
JSON representation
Morpher is a small npm library which allows you to work with GraphQL in isomorphic fashion.
- Host: GitHub
- URL: https://github.com/cult-of-coders/morpher
- Owner: cult-of-coders
- License: mit
- Created: 2018-06-25T06:37:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-24T07:03:28.000Z (over 6 years ago)
- Last Synced: 2024-04-25T06:22:36.304Z (12 months ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Morpher
Morpher is the client-side version of the `Morph` server-side exposure from `cultofcoders:apollo`.
The reason we have it on NPM is that it can be used with any frontend layer/bundler/framework & React Native.## Install
```js
// Then on the client
import db, { setClient } from 'apollo-morpher';// Set your Apollo client
setClient(apolloClient);// Built-in mutations
db.users.insert(document).then(({ _id }) => {});
db.users.update(selector, modifier).then(response => {});
db.users.remove(selector).then(response => {});// Or define the in object style:
const fields = {
firstName: 1,
lastName: 1,
lastInvoices: {
total: 1,
},
};// Or you could also define the fields in GraphQL style `firstName`
db.users
.find(fields, {
filters: {},
options: {},
})
.then(result => {});// find equivallent .findOne()
```