@firsthandjs/data-urql 0.7.0 → 0.7.1
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/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
*/
|
|
32
32
|
import { type CacheClient, type CacheOptions, type DocumentArguments, type GraphQLDocument, type Loader, type Variables } from '@firsthandjs/data';
|
|
33
33
|
/** What urql gives back: a wonka source with a promise on it. */
|
|
34
|
-
export
|
|
34
|
+
export type UrqlResult<T> = {
|
|
35
35
|
data?: T;
|
|
36
36
|
error?: unknown;
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
/** The part of an urql client this package uses. Nothing else. */
|
|
39
|
-
export
|
|
39
|
+
export type UrqlLike = {
|
|
40
40
|
query(document: string, variables: Variables, context?: Record<string, unknown>): {
|
|
41
41
|
toPromise(): Promise<UrqlResult<unknown>>;
|
|
42
42
|
};
|
|
43
43
|
mutation(document: string, variables: Variables, context?: Record<string, unknown>): {
|
|
44
44
|
toPromise(): Promise<UrqlResult<unknown>>;
|
|
45
45
|
};
|
|
46
|
-
}
|
|
47
|
-
export
|
|
46
|
+
};
|
|
47
|
+
export type UrqlClientOptions = {
|
|
48
48
|
/**
|
|
49
49
|
* Headers for every request, sent through urql's `fetchOptions`. A function
|
|
50
50
|
* is called **per request and untracked**, which is what lets a token change
|
|
@@ -67,8 +67,8 @@ export interface UrqlClientOptions {
|
|
|
67
67
|
readonly scope?: () => string;
|
|
68
68
|
/** Merged into urql's operation context for every request. */
|
|
69
69
|
readonly context?: Record<string, unknown>;
|
|
70
|
-
}
|
|
71
|
-
export
|
|
70
|
+
};
|
|
71
|
+
export type UrqlClient = {
|
|
72
72
|
/**
|
|
73
73
|
* A query, as a loader. Declares the document's `@tag` directives before the
|
|
74
74
|
* request goes out, so an invalidation sent while it is in flight finds it.
|
|
@@ -83,6 +83,6 @@ export interface UrqlClient {
|
|
|
83
83
|
/** A copy with some options replaced. The cache is shared unless replaced. */
|
|
84
84
|
with(options: UrqlClientOptions): UrqlClient;
|
|
85
85
|
readonly cache: CacheClient | undefined;
|
|
86
|
-
}
|
|
86
|
+
};
|
|
87
87
|
export declare function createUrqlClient(client: UrqlLike, options?: UrqlClientOptions): UrqlClient;
|
|
88
88
|
//# sourceMappingURL=index.d.ts.map
|
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,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,
|
|
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,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CACH,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC;QAAE,SAAS,I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AAiB,GAAG,UAAU,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,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 T,resolveTags as V,stableKey as g}from"@firsthandjs/data";import{untrack as l}from"@firsthandjs/core";function p(c,t={}){let o=t.cache===void 0||t.cache===!1?void 0:"read"in t.cache?t.cache:T(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?.(...V(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}(${g(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=>p(c,{...t,...e,cache:e.cache??o??!1})}}export{p as createUrqlClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/data-urql",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.
|
|
22
|
+
"@firsthandjs/data": "0.7.1"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20.11.0"
|