# shortql

> smart graphql cache

Latest version **1.2.1** (published 2019-05-30) · private license · 0 weekly downloads

## Install

```sh
npm install shortql
pnpm add shortql
yarn add shortql
bun add shortql
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2019-05-30 |
| First published | 2019-05-17 |
| Weekly downloads | 0 |
| License | private |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 273.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ioobot inc |
| Maintainers | ioobot |
| Keywords | clojurescript, cljs, shadow-cljs, graphql |

## Links

- npm: https://www.npmjs.com/package/shortql
- Repository: https://github.com/IooBot/shortql
- Issues: https://github.com/IooBot/shortql/issues
- npm.io page: https://npm.io/package/shortql

## 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.2.1 (latest) — 2019-05-30
- 1.2.0 — 2019-05-29
- 1.1.0 — 2019-05-17
- 1.0.0 — 2019-05-17

## README

## shortql

> A simple, modular GraphQL cache supporting multi-platform for Javascript.
> Flexible configuration control for querying data and also support open or close debug log.

The old version is named graphql-sync-multi-platform


### Install

> npm install shortql --save

### Quickstart

## axios

    import * as QL from 'shortql/graphql_cache.core';
    import axios from 'axios';
    const graphqlEndpoint = 'http://xxx/graphql';

    //request axios
    QL.init(graphqlEndpoint,axios));

## Taro

     import * as QL from 'shortql/graphql_cache.core';
     import Taro, { Component } from '@tarojs/taro';
     const graphqlEndpoint = 'http://xxx/graphql';

     QL.init(graphqlEndpoint, Taro.request);

## flyio

    import * as QL from 'shortql/graphql_cache.core';
    import Fly from 'flyio';
    const graphqlEndpoint = 'http://xxx';

     function flyReqest(options){
      const url ='/graphql';
      return Fly.request(url,options.data,options);
    }

    //request flyio
    QL.init(graphqlEndpoint,flyReqest));

## open debug log

**open**

    QL.init(graphqlEndpoint, request, {enable_log : true});

**close**

default close console.log

    QL.init(graphqlEndpoint, request);
    QL.init(graphqlEndpoint, request, {enable_log : false});

### Usage

**` QL.find_one(collection,condition,fields,option) `**

**` QL.find_many(collection,condition,fields,option) `**

#### skip cache and get new fetch data

    setting option: {force : true}

    eg:

    QL.find_one('order', {id: "xxx"}, ['id'], {force: true});

**` QL.insert(collection,condition,fields) `**

**` QL.update(collection,condition,fields) `**

**` QL.remove(collection,condition) `**

    eg:

    import * as QL from "shortql/graphql_cache.core";

    QL.find_many(collection,condition,fields).then(res => {
        return res;
    });

    // return result with 'ok' when insert or update success
    QL.update(collection,condition,fields).then(res => {
        if(res.result === 'ok'){
            return res;
        }
    });

    QL.remove(collection,condition).then(res => {
        if(res === 'ok'){
            // others operation
        }
    });

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