@firsthandjs/data-apollo 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Apollo Client as a client for [`@firsthandjs/data`](https://www.npmjs.com/packag
|
|
|
6
6
|
npm install @firsthandjs/data-apollo
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
0.
|
|
9
|
+
0.65 kB gzip. It has **no dependency on Apollo** and no peer dependency either —
|
|
10
10
|
the three methods it uses are declared structurally. That also keeps your copy
|
|
11
11
|
of `graphql` the only copy, which is a category of afternoon worth avoiding.
|
|
12
12
|
|
|
@@ -63,8 +63,12 @@ together, and only two:
|
|
|
63
63
|
const user = fromObservable(...billing.watch(UserDocument, { id: props.id }));
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
If you do give this client a cache, its keys carry the operation, the variables
|
|
67
|
+
(in any order they were written) and an identity — the `authorization` header
|
|
68
|
+
by default, or a `scope` you give.
|
|
69
|
+
|
|
70
|
+
What is not on the list is both caches at once, with the same data living in
|
|
71
|
+
two places under two invalidation rules. See
|
|
68
72
|
[ADR-0022](https://github.com/firsthandjs/firsthand/blob/main/docs/adr/0022-resources-not-a-cache.md).
|
|
69
73
|
|
|
70
74
|
## Tags come out of the document
|
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,13 @@ export interface ApolloClientOptions {
|
|
|
83
83
|
* application. Queries only.
|
|
84
84
|
*/
|
|
85
85
|
readonly cache?: false | CacheOptions | CacheClient;
|
|
86
|
+
/**
|
|
87
|
+
* Who the cached answers belong to. Defaults to the `authorization` header
|
|
88
|
+
* this request would carry, so two accounts in one session cannot read each
|
|
89
|
+
* other's answers out of one operation-shaped key. Read per request,
|
|
90
|
+
* untracked.
|
|
91
|
+
*/
|
|
92
|
+
readonly scope?: () => string;
|
|
86
93
|
/** Merged into the options of every query and mutation. */
|
|
87
94
|
readonly options?: Record<string, unknown>;
|
|
88
95
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAG3B,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACvE;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAC5C,SAAS,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,OAAO,CAAA;aAAE,KAAK,IAAI,CAAC;YAC1C,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OA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AAC,CAAC,EAC/B,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IAC/C,8EAA8E;IAC9E,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAuHd"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCacheClient as
|
|
1
|
+
import{createCacheClient as V,resolveTags as b,stableKey as f}from"@firsthandjs/data";import{untrack as d}from"@firsthandjs/core";function g(s,u,t={}){let c=t.cache===void 0||t.cache===!1?void 0:"read"in t.cache?t.cache:V(t.cache),i=()=>{let e=typeof t.headers=="function"?d(t.headers):t.headers;return e===void 0?{}:{context:{headers:e}}},y=()=>{if(t.scope!==void 0)return d(t.scope);let e=typeof t.headers=="function"?d(t.headers):t.headers??{};return e.authorization??e.Authorization??""},h=async(e,n,o,r)=>{let a=u(n.source);return e==="mutation"?(await s.mutate({...t.options,...i(),mutation:a,variables:o})).data:(await s.query({...t.options,...i(),query:a,variables:o,fetchPolicy:r.force?"network-only":"cache-first"})).data},m=(e,n,o)=>async r=>{let a=o[0]??{};r.tags?.(...b(e==="mutation"?n.invalidates:n.tags,a));let l=n;if(c===void 0||e==="mutation"||r.mutating===!0)return await h(e,l,a,r);let p=`${y()}\0${n.operation}(${f(a)})`;return await c.read(p,T=>h(e,l,a,T))(r)};return{cache:c,query:(e,...n)=>m("query",e,n),mutate:(e,...n)=>m("mutation",e,n),watch:(e,...n)=>{let o=s.watchQuery({...t.options,...i(),query:u(e.source),variables:n[0]??{}});return[{subscribe:r=>o.subscribe({next:a=>r.next?.(a.data),...r.error===void 0?{}:{error:r.error}})},{reload:()=>o.refetch()}]},with:e=>g(s,u,{...t,...e,cache:e.cache??c??!1})}}export{g as createApolloClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/data-apollo",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Loaders for Apollo Client, for @firsthandjs/data. Takes your client; never configures it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@firsthandjs/data": "0.6.
|
|
22
|
+
"@firsthandjs/data": "0.6.3"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20.11.0"
|