File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 10
10
Install [ cacheiql/client] ( https://www.npmjs.com/package/cacheiql-client ) from npm using the terminal command: ` npm i cacheiql-client ` <br />
11
11
@cacheiql/client will be added as a dependency to your package.json file.
12
12
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
+
13
55
## How It Works
14
56
15
57
<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 " />
You can’t perform that action at this time.
0 commit comments