# graphql-object

> Use GraphQL syntax to query into an object in-memory.

Latest version **1.0.3** (published 2020-01-22) · 0 weekly downloads

## Install

```sh
npm install graphql-object
pnpm add graphql-object
yarn add graphql-object
bun add graphql-object
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-01-22 |
| First published | 2019-12-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Maintainers | andersdjohnson |
| Keywords | graphql, graphql-client, graphql-tag |

## Links

- npm: https://www.npmjs.com/package/graphql-object
- Repository: https://github.com/AndersDJohnson/graphql-object
- Homepage: https://github.com/AndersDJohnson/graphql-object#readme
- Issues: https://github.com/AndersDJohnson/graphql-object/issues
- npm.io page: https://npm.io/package/graphql-object

## 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

- 1.0.3 (latest) — 2020-01-22
- 1.0.2 — 2020-01-22
- 1.0.1 — 2019-12-12
- 1.0.0 — 2019-12-12

## README

# graphql-object

> Use GraphQL syntax to query into an object in-memory.

[![npm](https://img.shields.io/npm/v/graphql-object)](https://www.npmjs.com/package/graphql-object)

[![npm add graphql-object (copy)](https://copyhaste.com/i?t=npm%20add%20graphql-object)](https://copyhaste.com/c?t=npm%20add%20graphql-object "npm add graphql-object (copy)")
[![yarn add graphql-object (copy)](https://copyhaste.com/i?t=yarn%20add%20graphql-object)](https://copyhaste.com/c?t=yarn%20add%20graphql-object "yarn add graphql-object (copy)")

A dependency-free micro-library to letting you select from an object using GraphQL syntax.
Unlike alternatives such as [`graphql-anywhere`](https://www.npmjs.com/package/graphql-anywhere),
it does not rely on the heavy `graphql` library as a peer dependency.

You can use [`graphql-tag`](https://github.com/apollographql/graphql-tag) for string query syntax,
but it's recommended to use [`babel-plugin-graphql-tag`](https://github.com/gajus/babel-plugin-graphql-tag)
to pre-compile them at build-time for almost no runtime bundlesize overhead.

This library could be handy when when migrating existing traditional applications that get data from REST endpoints to a GraphQL ecosystem
by decoupling the fetching of that data from the querying into it for usage in components.

Or, it could be the basis for an architecture to switch to persisted queries from REST endpoints at runtime in production,
while still using real-time GraphQL queries in development environments.

To keep it light, it does not support `@skip`, `@include`, arguments, variables, fragments, or aliases at this time.

```js
import gql from 'graphql-tag'
import graphql from 'graphql-object'

const object = {
  firstName: 'Bill',
  lastName: 'Gates',
  job: {
    title: 'CEO',
    extra: true,
    company: {
      name: 'Microsoft',
      address: 'Redmond, WA 98052'
    }
  }
}

const query = gql`
  {
    firstName
    lastName
    job {
      title
      company {
        name
      }
    }
  }
`

const result = graphql(object, query)
// =>
{
  firstName: 'Bill',
  lastName: 'Gates',
  job: {
    title: 'CEO',
    company: {
      name: 'Microsoft',
    }
  }
}
```

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