Skip to content

Commit bcd054c

Browse files
authored
Merge pull request #71 from oslabs-beta/master
Master
2 parents aefa842 + 316b707 commit bcd054c

File tree

10 files changed

+536
-373
lines changed

10 files changed

+536
-373
lines changed

ObsidianWrapper/ObsidianWrapper.jsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import React from "https://dev.jspm.io/react";
2-
import BrowserCache from "../src/Browser/CacheClassBrowser.js";
3-
import { insertTypenames } from "../src/Browser/insertTypenames.js";
1+
import React from 'https://dev.jspm.io/react';
2+
import BrowserCache from '../src/Browser/CacheClassBrowser.js';
3+
import { insertTypenames } from '../src/Browser/insertTypenames.js';
44

55
const cacheContext = React.createContext();
66

77
function ObsidianWrapper(props) {
88
const [cache, setCache] = React.useState(new BrowserCache());
99

1010
// You have to put your Google Chrome Obsidian developer tool extension id to connect Obsidian Wrapper with dev tool
11-
const chromeExtensionId = "dkbfipkapkljpdbhdihnlnbieffhjdmh";
12-
window.localStorage.setItem("cache", JSON.stringify(cache));
11+
const chromeExtensionId = 'apcpdmmbhhephobnmnllbklplpaoiemo';
12+
window.localStorage.setItem('cache', JSON.stringify(cache));
1313

1414
async function query(query, options = {}) {
1515
// dev tool messages
1616
const startTime = Date.now();
1717
chrome.runtime.sendMessage(chromeExtensionId, { query: query });
1818
chrome.runtime.sendMessage(chromeExtensionId, {
19-
cache: window.localStorage.getItem("cache"),
19+
cache: window.localStorage.getItem('cache'),
2020
});
2121
console.log(
2222
"Here's the message content: ",
23-
window.localStorage.getItem("cache")
23+
window.localStorage.getItem('cache')
2424
);
2525
// set the options object default properties if not provided
2626
const {
27-
endpoint = "/graphql",
27+
endpoint = '/graphql',
2828
cacheRead = true,
2929
cacheWrite = true,
3030
pollInterval = null,
@@ -50,7 +50,6 @@ function ObsidianWrapper(props) {
5050
// when the developer decides to only utilize whole query for cache
5151
if (wholeQuery) resObj = await cache.readWholeQuery(query);
5252
else resObj = await cache.read(query);
53-
console.log("query function resObj: ", resObj);
5453
// check if query is stored in cache
5554
if (resObj) {
5655
// returning cached response as a promise
@@ -74,10 +73,10 @@ function ObsidianWrapper(props) {
7473
try {
7574
// send fetch request with query
7675
const resJSON = await fetch(endpoint, {
77-
method: "POST",
76+
method: 'POST',
7877
headers: {
79-
"Content-Type": "application/json",
80-
Accept: "application/json",
78+
'Content-Type': 'application/json',
79+
Accept: 'application/json',
8180
},
8281
body: JSON.stringify({ query }),
8382
});
@@ -117,7 +116,7 @@ function ObsidianWrapper(props) {
117116
const startTime = Date.now();
118117
mutation = insertTypenames(mutation);
119118
const {
120-
endpoint = "/graphql",
119+
endpoint = '/graphql',
121120
cacheWrite = true,
122121
toDelete = false,
123122
update = null,
@@ -153,7 +152,7 @@ function ObsidianWrapper(props) {
153152
}
154153
// always write/over-write to cache (add/update)
155154
// GQL call to make changes and synchronize database
156-
console.log("WriteThrough - true ", responseObj);
155+
console.log('WriteThrough - true ', responseObj);
157156
const addOrUpdateMutationResponseTime = Date.now() - startTime;
158157
chrome.runtime.sendMessage(chromeExtensionId, {
159158
addOrUpdateMutationResponseTime: addOrUpdateMutationResponseTime,
@@ -165,10 +164,10 @@ function ObsidianWrapper(props) {
165164

166165
// use cache.write instead of cache.writeThrough
167166
const responseObj = await fetch(endpoint, {
168-
method: "POST",
167+
method: 'POST',
169168
headers: {
170-
"Content-Type": "application/json",
171-
Accept: "application/json",
169+
'Content-Type': 'application/json',
170+
Accept: 'application/json',
172171
},
173172
body: JSON.stringify({ query: mutation }),
174173
}).then((resp) => resp.json());
@@ -184,7 +183,7 @@ function ObsidianWrapper(props) {
184183
}
185184
// third behaviour just for normal update (no-delete, no update function)
186185
cache.write(mutation, responseObj);
187-
console.log("WriteThrough - false ", responseObj);
186+
console.log('WriteThrough - false ', responseObj);
188187
return responseObj;
189188
}
190189
} catch (e) {

README.md

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
## Features
2424

25+
- (New!) Server-side cache invalidation only on affected entries
26+
- (New!) Flexible cache responds with only data requested from selected fields
27+
- (New!) Developer tool for Obsidian is now updated to Manifest version 3 and invalid Bootstrap module imports were also fixed along with CodeMirror dependencies
2528
- GraphQL query abstraction and caching improving the performance of your app
2629
- SSR React wrapper, allowing you to cache in browser
2730
- Configurable caching options, giving you complete control over your cache
@@ -36,7 +39,6 @@ Obsidian is Deno's first native GraphQL caching client and server module. Boasti
3639

3740
With additional support for use in server-side rendered React apps built with Deno, full stack integration of Obsidian enables a fast and flexible caching solution.
3841

39-
4042
## Installation
4143

4244
<div align="center"><strong>QUICK START</strong></div>
@@ -47,29 +49,31 @@ With additional support for use in server-side rendered React apps built with De
4749
```javascript
4850
import { Application, Router } from 'https://deno.land/x/[email protected]/mod.ts';
4951
import { ObsidianRouter, gql } from 'https://deno.land/x/obsidian/mod.ts';
50-
import { resolvers } from './ import from your resolvers file'
51-
import { types } from './ import your schema/types from schema/types file'
52-
52+
import { resolvers } from './ import from your resolvers file';
53+
import { types } from './ import your schema/types from schema/types file';
5354

5455
interface ObsRouter extends Router {
5556
obsidianSchema?: any;
5657
}
5758

58-
const GraphQLRouter = await ObsidianRouter<ObsRouter>({
59-
Router,
60-
typeDefs: types,
61-
resolvers: resolvers,
62-
redisPort: 6379, //Desired redis port
63-
useCache: true, //Boolean to toggle all cache functionality
64-
usePlayground: true, //Boolean to allow for graphQL playground
65-
useQueryCache: true, //Boolean to toogle full query cache
66-
useRebuildCache: true, //Boolean to toggle rebuilding from normalized data
67-
customIdentifier: ["id", "__typename"]
68-
69-
});
59+
const GraphQLRouter =
60+
(await ObsidianRouter) <
61+
ObsRouter >
62+
{
63+
Router,
64+
typeDefs: types,
65+
resolvers: resolvers,
66+
redisPort: 6379, //Desired redis port
67+
useCache: true, //Boolean to toggle all cache functionality
68+
usePlayground: true, //Boolean to allow for graphQL playground
69+
useQueryCache: true, //Boolean to toogle full query cache
70+
useRebuildCache: true, //Boolean to toggle rebuilding from normalized data
71+
customIdentifier: ['id', '__typename'],
72+
mutationTableMap = {}, //Object where keys are add mutation types and value is an array of affected tables (e.g. {addPlants: ['plants'], addMovie: ['movies']})
73+
};
7074

7175
// attach the graphql routers routes to our app
72-
app.use(GraphQLRouter.routes(), GraphQLRouter.allowedMethods());
76+
app.use(GraphQLRouter.routes(), GraphQLRouter.allowedMethods());
7377
```
7478

7579
## Creating the Wrapper
@@ -151,51 +155,61 @@ const MovieApp = () => {
151155
```
152156

153157
## Documentation
158+
154159
[obsidian.land](http://obsidian.land)
155160

156161
## Developer Tool
157-
information and instructions on how to use our developer tool can be found here <br/>
162+
163+
Information and instructions on how to use our developer tool can be found here <br/>
158164
works with Obsidian 5.0 <br/>
159165
[oslabs-beta/obsidian-developer-tool](https://github.com/oslabs-beta/obsidian-developer-tool)
160166

161167
## Obsidian 5.0 Demo
162-
github for a demo with some example code to play with: <br/>
168+
169+
Github for a demo with some example code to play with: <br/>
163170
[oslabs-beta/obsidian-demo-5.0](https://github.com/oslabs-beta/obsidian-demo-5.0)
164171

165172
## Dockerized Demo
166-
working demo to install locally in docker:
173+
174+
Working demo to install locally in docker:
167175
[oslabs-beta/obsidian-demo-docker](https://github.com/oslabs-beta/obsidian-demo-docker)
168176

169-
## Working Example Demo Code
170-
github for a demo with some example code to play with:
171-
[oslabs-beta/obsidian-demo-3.2](https://github.com/oslabs-beta/obsidian-demo-3.2)
177+
## Features In Progress
172178

179+
- Ability to query the database for only those fields missing from the cache
180+
- Developer Tool Settings component, fully functioning Playground component
173181

174182
## Authors
175-
[Yurii Shchyrba](https://github.com/YuriiShchyrba)
176-
[Linda Zhao](https://github.com/lzhao15)
177-
[Ali Fay](https://github.com/ali-fay)
178-
[Anthony Guan](https://github.com/guananthony)
179-
[Yasir Choudhury](https://github.com/Yasir-Choudhury)
180-
[Yogi Paturu](https://github.com/YogiPaturu)
181-
[Michael Chin](https://github.com/mikechin37)
182-
[Dana Flury](https://github.com/dmflury)
183-
[Sardor Akhmedov](https://github.com/sarkamedo)
184-
[Christopher Berry](https://github.com/cjamesb)
183+
184+
[Derek Okuno](https://github.com/okunod)
185+
[Liam Johnson](https://github.com/liamdimitri)
186+
[Josh Reed](https://github.com/joshreed104)
187+
[Jonathan Fangon](https://github.com/jonathanfangon)
188+
[Liam Jeon](https://github.com/laj52)
189+
[Yurii Shchyrba](https://github.com/YuriiShchyrba)
190+
[Linda Zhao](https://github.com/lzhao15)
191+
[Ali Fay](https://github.com/ali-fay)
192+
[Anthony Guan](https://github.com/guananthony)
193+
[Yasir Choudhury](https://github.com/Yasir-Choudhury)
194+
[Yogi Paturu](https://github.com/YogiPaturu)
195+
[Michael Chin](https://github.com/mikechin37)
196+
[Dana Flury](https://github.com/dmflury)
197+
[Sardor Akhmedov](https://github.com/sarkamedo)
198+
[Christopher Berry](https://github.com/cjamesb)
185199
[Olivia Yeghiazarian](https://github.com/Olivia-code)
186-
[Michael Melville](https://github.com/meekle)
187-
[John Wong](https://github.com/johnwongfc)
188-
[Kyung Lee](https://github.com/kyunglee1)
189-
[Justin McKay](https://github.com/justinwmckay)
200+
[Michael Melville](https://github.com/meekle)
201+
[John Wong](https://github.com/johnwongfc)
202+
[Kyung Lee](https://github.com/kyunglee1)
203+
[Justin McKay](https://github.com/justinwmckay)
190204
[Patrick Sullivan](https://github.com/pjmsullivan)
191205
[Cameron Simmons](https://github.com/cssim22)
192206
[Raymond Ahn](https://github.com/raymondcodes)
193-
[Alonso Garza](https://github.com/Alonsog66)
207+
[Alonso Garza](https://github.com/Alonsog66)
194208
[Burak Caliskan](https://github.com/CaliskanBurak)
195209
[Matt Meigs](https://github.com/mmeigs)
196210
[Travis Frank](https://github.com/TravisFrankMTG/)
197211
[Lourent Flores](https://github.com/lourentflores)
198212
[Esma Sahraoui](https://github.com/EsmaShr)
199213
[Derek Miller](https://github.com/dsymiller)
200214
[Eric Marcatoma](https://github.com/ericmarc159)
201-
[Spencer Stockton](https://github.com/tonstock)
215+
[Spencer Stockton](https://github.com/tonstock)

0 commit comments

Comments
 (0)