# graph-data-layer

> Practical data queries inspired by GraphQL

Latest version **0.1.1** (published 2016-03-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install graph-data-layer
pnpm add graph-data-layer
yarn add graph-data-layer
bun add graph-data-layer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-03-16 |
| First published | 2016-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lucas Sunsi |
| Maintainers | lsunsi |
| Keywords | GraphQL, queries, schemas, graph, layer |

## Links

- npm: https://www.npmjs.com/package/graph-data-layer
- Repository: https://github.com/lsunsi/graph-data-layer
- Homepage: https://github.com/lsunsi/graph-data-layer#readme
- Issues: https://github.com/lsunsi/graph-data-layer/issues
- npm.io page: https://npm.io/package/graph-data-layer

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.6.1

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2016-03-16
- 0.1.0 — 2016-03-15

## README

Graph Data Layer
===

Description
---
This is an experimental package inspired by facebook's GraphQL.

It provides a practical way of declaring **data schemas** on the server so that data can be queried in a way that's easy to reason about.

Installation
---
```
npm install graph-data-layer
```

Usage
---

This package has two concerns only:
* Data schemas, providing all info a query can ask for.
* Data queries, providing all info needed to fulfill it.

Both schemas and queries are just JavaScript objects following an specific structure.
We target **convention over configuration** so we can achieve a simpler syntax for both schemas and queries that are as similar as possible.

#### Setup

```javascript
import initLayer from 'graph-data-layer';

const layer = initLayer();
```

#### Schema

```javascript
const schema = {
  resolve() {
    return {
      names: {
        first: 'Lucas',
        last: 'Sunsi',
      },
      occupation: 'Magician',
    };
  },

  firstName(u) {
    return user.names.first;
  },
  hasAwesomeOccupation(u) {
    return u.occupation === 'Magician';
  },
};

layer.register('ownerUser', schema);
```

### Query
```javascript
const query = {
  ownerUser: {
    firstName: true,
  },
};

layer.fulfill(query).then(console.log);
// { firstName: 'Lucas' }
```

License
---
MIT

---
_Source: https://npm.io/package/graph-data-layer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
