@firsthandjs/data-urql 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 -2
- 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 @@ urql as a client for [`@firsthandjs/data`](https://www.npmjs.com/package/@firsth
|
|
|
6
6
|
npm install @firsthandjs/data-urql
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
0.
|
|
9
|
+
0.58 kB gzip. It has **no dependency on urql** and no peer dependency either —
|
|
10
10
|
the two methods it uses are declared structurally. It was checked against
|
|
11
11
|
`@urql/core` 6, which has no React dependency of its own.
|
|
12
12
|
|
|
@@ -72,7 +72,12 @@ invalidation, so neither call site writes a tag at all.
|
|
|
72
72
|
from a helper. `force` is passed on as `requestPolicy: 'network-only'`, so an
|
|
73
73
|
invalidation reaches past it.
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
If you do give this client a cache, its keys carry the operation, the variables
|
|
76
|
+
(in any order they were written) and an identity — the `authorization` header
|
|
77
|
+
by default, or a `scope` you give — so two accounts in one session cannot read
|
|
78
|
+
each other's answers.
|
|
79
|
+
|
|
80
|
+
What you should not have is two caches over one piece of data, because they
|
|
76
81
|
disagree. If urql's cache should be the source of truth for an entity shown in
|
|
77
82
|
many places, subscribe to it with `fromObservable` instead.
|
|
78
83
|
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,13 @@ export interface UrqlClientOptions {
|
|
|
58
58
|
* only, keyed by operation and variables.
|
|
59
59
|
*/
|
|
60
60
|
readonly cache?: false | CacheOptions | CacheClient;
|
|
61
|
+
/**
|
|
62
|
+
* Who the cached answers belong to. Defaults to the `authorization` header
|
|
63
|
+
* this request would carry, so two accounts in one session cannot read each
|
|
64
|
+
* other's answers out of one operation-shaped key. Read per request,
|
|
65
|
+
* untracked.
|
|
66
|
+
*/
|
|
67
|
+
readonly scope?: () => string;
|
|
61
68
|
/** Merged into urql's operation context for every request. */
|
|
62
69
|
readonly context?: Record<string, unknown>;
|
|
63
70
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAG3B,iEAAiE;AACjE,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,KAAK,CACH,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC;QAAE,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;IACjD,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC;QAAE,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3E;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,YAAY,GAAG,WAAW,CAAC;IACpD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EAC1B,QAAQ,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,MAAM,CAAC,CAAC,CAAC,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EAC3B,QAAQ,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,MAAM,CAAC,CAAC,CAAC,CAAC;IACb,8EAA8E;IAC9E,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAoG9F"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCacheClient as
|
|
1
|
+
import{createCacheClient as f,resolveTags as T,stableKey as V}from"@firsthandjs/data";import{untrack as l}from"@firsthandjs/core";function g(c,t={}){let o=t.cache===void 0||t.cache===!1?void 0:"read"in t.cache?t.cache:f(t.cache),y=()=>{if(t.scope!==void 0)return l(t.scope);let e=typeof t.headers=="function"?l(t.headers):t.headers??{};return e.authorization??e.Authorization??""},d=async(e,r,s,n)=>{let a=typeof t.headers=="function"?l(t.headers):t.headers,i={...t.context,fetchOptions:{signal:n.signal,...a===void 0?{}:{headers:a}},requestPolicy:n.force?"network-only":"cache-first"},u=await(e==="mutation"?c.mutation(r,s,i):c.query(r,s,i)).toPromise();if(u.error!==void 0)throw u.error;return u.data},m=(e,r,s)=>async n=>{let a=s[0]??{};if(n.tags?.(...T(e==="mutation"?r.invalidates:r.tags,a)),o===void 0||e==="mutation"||n.mutating===!0)return await d(e,r.source,a,n);let i=`${y()}\0${r.operation}(${V(a)})`;return await o.read(i,h=>d(e,r.source,a,h))(n)};return{cache:o,query:(e,...r)=>m("query",e,r),mutate:(e,...r)=>m("mutation",e,r),with:e=>g(c,{...t,...e,cache:e.cache??o??!1})}}export{g as createUrqlClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/data-urql",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Loaders for urql, 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"
|