Skip to content

Commit 9478b1c

Browse files
authored
Update README.md
1 parent 33cc8a1 commit 9478b1c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

cacheiql-client/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,48 @@
1010
Install [cacheiql/client](https://www.npmjs.com/package/cacheiql-client) from npm using the terminal command: `npm i cacheiql-client` <br/>
1111
@cacheiql/client will be added as a dependency to your package.json file.
1212

13+
## Import CacheIQL-Server
14+
15+
**1. Add the following import to your .jsx file:**
16+
17+
CommonJS:
18+
``` js
19+
const { cacheIt } = require('cacheiql-client');
20+
```
21+
ES6+:
22+
``` js
23+
import { cacheIt } from 'cacheiql-client';
24+
```
25+
26+
**2. Pass into the cacheIt function your desired endpoint, query, and TTL (time-to-live)**
27+
28+
``` js
29+
const responseCharacter: ResponseObject = await cacheIt({
30+
endpoint: 'http://localhost:3000/graphql',
31+
query: `
32+
{
33+
people{
34+
_id
35+
gender
36+
birth_year
37+
skin_color
38+
hair_color
39+
name
40+
species_id
41+
homeworld_id
42+
}
43+
}`,
44+
time: 3600,
45+
});
46+
```
47+
**3. Start the server:** <br/>
48+
ex. <br/>
49+
`npm run start` <br/>
50+
`npm run serv`
51+
52+
**4. Visit http://localhost:3000/graphql to access GraphQL and start testing the caching functionality.**
53+
54+
1355
## How It Works
1456

1557
<img width="962" alt="Screenshot 2025-02-25 at 6 47 03 PM" src="https://github.com/user-attachments/assets/e3d60385-a6c5-46af-9536-92021ecea3aa" />

0 commit comments

Comments
 (0)