open-index/open-npm huggingface dataset:
npm package: @magnicache/client
Description: Client-side caching layer for GraphQL
Author: MagniCache
Latest version: 1.0.1

# Magnicache/client

<!-- @magnicache/client is a powerful library designed to significantly improve response times for GraphQL queries by leveraging the browser's localStorage. -->

A lightweight client-side GraphQL caching solution that optimizes queries by atomizing complex queries and caching them individually.
<br/>
MagniClient utilizes localStorage to cache query results across sessions.
<br>
Configurable cache size.

<br>

## How to use @magnicache/client in your GraphQL client

1. Install MagniCache Client.

```bash
npm i @magnicache/client
```

2. Import MagniCache Client.

```js
const MagniClient = require('@magnicache/client');
```

3. Declare a new instance of MagniClient, optionally passing in a cache capacity(defaults to 40).

```js
const magniClient = new MagniClient(maxSize);
```

4. Invoke magniClient.query, passing in the query string and the graphql endpoint.

```js
magniClient
  .query(
    `query {
    person(personID: 1) {
        name
        eyeColor
        height
    }
  }`,
    '/graphql'
  )
  .then((response) => {
    const queryData = response[0];
    const cacheStatus = response[1];
    // Handle the response data
  })
  .catch((err) => {
    // Handle errors
  });
```

## Contributors

[Ahmed Chami](https://www.linkedin.com/in/ahmed-chami/)

[Aria Soltankhah](https://www.linkedin.com/in/ariasol/)

[Truman Miller](https://www.linkedin.com/in/truman-miller)

[Yousuf Elkhoga](https://www.linkedin.com/in/yousufelkhoga/)
npm package: @magnicache/server
Description: Server side caching for GraphQL
Author: MagniCache
Latest version: 1.0.9

# Magnicache/server

@magnicache/server is a lightweight GraphQL caching solution. 

Imported as a package from npm, @magnicache/server can be inserted into the middleware chain for a GraphQL endpoint to intercept GraphQL requests and scan the cache for previously executed queries. 
<br>

Queries present in the cache will return the cached result to the client, improving response speeds and overall GraphQL performance.

<br>

## How to use @magnicache/server in your GraphQL api

1. Install MagniCache Server.

```bash
npm i @magnicache/server
```

2. Import MagniCache.

```js
const MagniCache = require('@magnicache/server');
```

3. Declare a new instance of MagniCache, passing in your GraphQL schema.

```js
const magnicache = new MagniCache(schema);
```

4. Insert magnicache.query into the middleware chain for your '/graphql' route.

   - Ensure all request bodies are parsed

```js
app.use(express.json());

app.use('/graphql', magnicache.query, (req, res) =>
  res.status(200).send(res.locals.queryResponse)
);
```

## Contributors

[Ahmed Chami](https://www.linkedin.com/in/ahmed-chami/)

[Aria Soltankhah](https://www.linkedin.com/in/ariasol/)

[Truman Miller](https://www.linkedin.com/in/truman-miller)

[Yousuf Elkhoga](https://www.linkedin.com/in/yousufelkhoga/)