Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zshipko/irmin-graphql-js
Irmin GraphQL bindings for Javascript
https://github.com/zshipko/irmin-graphql-js
Last synced: about 1 month ago
JSON representation
Irmin GraphQL bindings for Javascript
- Host: GitHub
- URL: https://github.com/zshipko/irmin-graphql-js
- Owner: zshipko
- License: isc
- Created: 2018-08-31T18:22:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-12T22:48:38.000Z (over 2 years ago)
- Last Synced: 2024-05-01T23:58:28.589Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 8
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# irmin-graphql-js
`irmin-graphql-js` is a Javascript library for communicating directly with [irmin-graphql](https://github.com/mirage/irmin) GraphQL servers.
## Getting started
To create an Irmin instance:
```javascript
var ir = new Irmin("https://127.0.0.1:8080/graphql");
```Setting a value:
```javascript
let commit = await ir.main().set("a/b/c", "123");
console.log(commit.hash);
```Getting a value:
```javascript
let value = await ir.main().get("a/b/c");
console.log(value);
```## Writing custom queries
Once you get past the most basic operations you will most likely need to write and execute custom queries. `irmin.js` makes this easy:
```javascript
let body = `
query GetExample($key: String!) {
main {
tree {
get(key: $key)
}
}
}
`;let query = {
body: body,
vars: {
key: "a/b/c"
},
operation: "GetExample"
};let res = await ir.execute(query);
console.log(res.main.tree.get);
```In the example above, `body` is a string containing the actual query, `data` is an object with `body`, `vars` and `operation` fields. The `vars` and `operation` fields may be left undefined if not in use.
## Examples
There are some examples using NodeJS in the `examples/` directory, they require the `node-fetch` package to be installed via npm.
You may also be interested in checking out the [GraphQL](https://irmin.io/tutorial/graphql) section of the [Irmin Tutorial](https://irmin.io/tutorial)!