Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/solid-query

Package Overview
Dependencies
Maintainers
2
Versions
303
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/solid-query - npm Package Compare versions

Comparing version 5.0.0-alpha.32 to 5.0.0-alpha.33

19

build/cjs/index.js

@@ -303,4 +303,8 @@ 'use strict';

});
const observer = new queryCore.QueriesObserver(client, defaultedQueries);
const [state, setState] = store.createStore(observer.getOptimisticResult(defaultedQueries));
const observer = new queryCore.QueriesObserver(client, defaultedQueries, queriesOptions().combine ? {
combine: queriesOptions().combine
} : undefined);
// @ts-expect-error - Types issue with solid-js createStore
const [state, setState] = store.createStore(observer.getOptimisticResult(defaultedQueries)[1]());
const unsubscribe = observer.subscribe(result => {

@@ -312,7 +316,2 @@ queryCore.notifyManager.batchCalls(() => {

solidJs.onCleanup(unsubscribe);
solidJs.onMount(() => {
observer.setQueries(defaultedQueries, {
listeners: false
});
});
solidJs.createComputed(() => {

@@ -324,3 +323,7 @@ const updatedQueries = queriesOptions().queries.map(options => {

});
observer.setQueries(updatedQueries);
observer.setQueries(updatedQueries, queriesOptions().combine ? {
combine: queriesOptions().combine
} : undefined, {
listeners: false
});
});

@@ -327,0 +330,0 @@ return state;

@@ -302,4 +302,8 @@ import { notifyManager, QueryClient as QueryClient$1, hydrate, QueryObserver, InfiniteQueryObserver, MutationObserver, QueriesObserver } from '@tanstack/query-core';

});
const observer = new QueriesObserver(client, defaultedQueries);
const [state, setState] = createStore(observer.getOptimisticResult(defaultedQueries));
const observer = new QueriesObserver(client, defaultedQueries, queriesOptions().combine ? {
combine: queriesOptions().combine
} : undefined);
// @ts-expect-error - Types issue with solid-js createStore
const [state, setState] = createStore(observer.getOptimisticResult(defaultedQueries)[1]());
const unsubscribe = observer.subscribe(result => {

@@ -311,7 +315,2 @@ notifyManager.batchCalls(() => {

onCleanup(unsubscribe);
onMount(() => {
observer.setQueries(defaultedQueries, {
listeners: false
});
});
createComputed(() => {

@@ -323,3 +322,7 @@ const updatedQueries = queriesOptions().queries.map(options => {

});
observer.setQueries(updatedQueries);
observer.setQueries(updatedQueries, queriesOptions().combine ? {
combine: queriesOptions().combine
} : undefined, {
listeners: false
});
});

@@ -326,0 +329,0 @@ return state;

@@ -49,6 +49,7 @@ import type { QueriesPlaceholderDataFunction, QueryFunction, QueryKey, DefaultError } from '@tanstack/query-core';

export declare type QueriesResults<T extends any[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? CreateQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...Result, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]> : T extends CreateQueryOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, any>[] ? CreateQueryResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError>[] : CreateQueryResult[];
export declare function createQueries<T extends any[]>(queriesOptions: Accessor<{
export declare function createQueries<T extends any[], TCombinedResult = QueriesResults<T>>(queriesOptions: Accessor<{
queries: readonly [...QueriesOptions<T>];
}>, queryClient?: Accessor<QueryClient>): QueriesResults<T>;
combine?: (result: QueriesResults<T>) => TCombinedResult;
}>, queryClient?: Accessor<QueryClient>): TCombinedResult;
export {};
//# sourceMappingURL=createQueries.d.ts.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/query-core"),require("solid-js"),require("solid-js/web"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","@tanstack/query-core","solid-js","solid-js/web","solid-js/store"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).index={},e.QueryCore,e.Solid,e.SolidWeb,e.SolidStore)}(this,(function(e,t,r,n,o){"use strict";t.notifyManager.setBatchNotifyFunction(r.batch);class i extends t.QueryClient{constructor(e={}){super(e)}}const u=r.createContext(void 0),s=e=>{const t=r.useContext(u);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t};function a(e,t){return"function"==typeof e?e(...t):!!e}function c(e,t,r){if(!1===r)return t;if("function"==typeof r){const n=r(e.data,t.data);return{...t,data:n}}const n=o.reconcile(t.data,{key:r})(e.data);return{...t,data:n}}function l(e,i,u){const l=r.createMemo((()=>s(u?.()))),d=l().defaultQueryOptions(e());d._optimisticResults="optimistic",d.structuralSharing=!1,n.isServer&&(d.retry=!1,d.throwOnError=!0);const f=new i(l(),d),[p,y]=o.createStore(f.getOptimisticResult(d)),m=()=>f.subscribe((e=>{t.notifyManager.batchCalls((()=>{const t=f.options.reconcile;h()?.data&&e.data&&!h.loading?(y((r=>c(r,e,void 0===t?"id":t))),b(p)):(y((r=>c(r,e,void 0===t?"id":t))),g())}))()}));let C=null;const[h,{refetch:g,mutate:b}]=r.createResource((()=>new Promise(((e,r)=>{n.isServer?C=((e,r)=>f.subscribe((n=>{t.notifyManager.batchCalls((()=>{const t=f.getCurrentQuery(),{refetch:i,...u}=o.unwrap(n),s={...u,dataUpdateCount:t.state.dataUpdateCount,fetchFailureCount:t.state.fetchFailureCount,isInvalidated:t.state.isInvalidated};s.isError&&("development"===process.env.NODE_ENV&&console.error(s.error),r(s.error)),s.isSuccess&&e(s)}))()})))(e,r):C||(C=m()),p.isLoading||e(p)}))),{initialValue:p,ssrLoadFrom:e().initialData?"initial":"server",get deferStream(){return e().deferStream},onHydrated(e,r){if(r.value&&t.hydrate(l(),{queries:[{queryKey:d.queryKey,queryHash:d.queryHash,state:r.value}]}),!C){const e={...d};!d.staleTime&&d.initialData||(e.refetchOnMount=!1),f.setOptions(e),y(f.getOptimisticResult(e)),C=m()}}});r.onCleanup((()=>{C&&(C(),C=null)})),r.createComputed(r.on((()=>l().defaultQueryOptions(e())),(()=>f.setOptions(l().defaultQueryOptions(e()))),{defer:!0})),r.createComputed(r.on((()=>p.status),(()=>{if(p.isError&&!p.isFetching&&a(f.options.throwOnError,[p.error,f.getCurrentQuery()]))throw p.error})));return new Proxy(p,{get(e,t){const r=h()?.[t];return void 0!==r?r:Reflect.get(e,t)}})}function d(){}e.QueryClient=i,e.QueryClientContext=u,e.QueryClientProvider=e=>(r.onMount((()=>{e.client.mount()})),r.onCleanup((()=>e.client.unmount())),n.createComponent(u.Provider,{get value(){return e.client},get children(){return e.children}})),e.createInfiniteQuery=function(e,n){return l(r.createMemo((()=>e())),t.InfiniteQueryObserver,n)},e.createMutation=function(e,n){const i=s(n?.()),u=new t.MutationObserver(i,e()),c=(e,t)=>{u.mutate(e,t).catch(d)},[l,f]=o.createStore({...u.getCurrentResult(),mutate:c,mutateAsync:u.getCurrentResult().mutate});r.createComputed((()=>{u.setOptions(e())})),r.createComputed(r.on((()=>l.status),(()=>{if(l.isError&&a(u.options.throwOnError,[l.error]))throw l.error})));const p=u.subscribe((e=>{f({...e,mutate:c,mutateAsync:e.mutate})}));return r.onCleanup(p),l},e.createQueries=function(e,n){const i=s(n?.()),u=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t})),a=new t.QueriesObserver(i,u),[c,l]=o.createStore(a.getOptimisticResult(u)),d=a.subscribe((e=>{t.notifyManager.batchCalls((()=>{l(o.unwrap(e))}))()}));return r.onCleanup(d),r.onMount((()=>{a.setQueries(u,{listeners:!1})})),r.createComputed((()=>{const t=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t}));a.setQueries(t)})),c},e.createQuery=function(e,n){return l(r.createMemo((()=>e())),t.QueryObserver,n)},e.queryOptions=function(e){return e},e.useIsFetching=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getQueryCache())),[i,u]=r.createSignal(n().isFetching(e?.())),a=o().subscribe((()=>{u(n().isFetching(e?.()))}));return r.onCleanup(a),i},e.useIsMutating=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getMutationCache())),[i,u]=r.createSignal(n().isMutating(e?.())),a=o().subscribe((t=>{u(n().isMutating(e?.()))}));return r.onCleanup(a),i},e.useQueryClient=s,Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})}))}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/query-core"),require("solid-js"),require("solid-js/web"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","@tanstack/query-core","solid-js","solid-js/web","solid-js/store"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).index={},e.QueryCore,e.Solid,e.SolidWeb,e.SolidStore)}(this,(function(e,t,r,n,o){"use strict";t.notifyManager.setBatchNotifyFunction(r.batch);class i extends t.QueryClient{constructor(e={}){super(e)}}const u=r.createContext(void 0),s=e=>{const t=r.useContext(u);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t};function a(e,t){return"function"==typeof e?e(...t):!!e}function c(e,t,r){if(!1===r)return t;if("function"==typeof r){const n=r(e.data,t.data);return{...t,data:n}}const n=o.reconcile(t.data,{key:r})(e.data);return{...t,data:n}}function l(e,i,u){const l=r.createMemo((()=>s(u?.()))),d=l().defaultQueryOptions(e());d._optimisticResults="optimistic",d.structuralSharing=!1,n.isServer&&(d.retry=!1,d.throwOnError=!0);const f=new i(l(),d),[p,y]=o.createStore(f.getOptimisticResult(d)),m=()=>f.subscribe((e=>{t.notifyManager.batchCalls((()=>{const t=f.options.reconcile;b()?.data&&e.data&&!b.loading?(y((r=>c(r,e,void 0===t?"id":t))),g(p)):(y((r=>c(r,e,void 0===t?"id":t))),h())}))()}));let C=null;const[b,{refetch:h,mutate:g}]=r.createResource((()=>new Promise(((e,r)=>{n.isServer?C=((e,r)=>f.subscribe((n=>{t.notifyManager.batchCalls((()=>{const t=f.getCurrentQuery(),{refetch:i,...u}=o.unwrap(n),s={...u,dataUpdateCount:t.state.dataUpdateCount,fetchFailureCount:t.state.fetchFailureCount,isInvalidated:t.state.isInvalidated};s.isError&&("development"===process.env.NODE_ENV&&console.error(s.error),r(s.error)),s.isSuccess&&e(s)}))()})))(e,r):C||(C=m()),p.isLoading||e(p)}))),{initialValue:p,ssrLoadFrom:e().initialData?"initial":"server",get deferStream(){return e().deferStream},onHydrated(e,r){if(r.value&&t.hydrate(l(),{queries:[{queryKey:d.queryKey,queryHash:d.queryHash,state:r.value}]}),!C){const e={...d};!d.staleTime&&d.initialData||(e.refetchOnMount=!1),f.setOptions(e),y(f.getOptimisticResult(e)),C=m()}}});r.onCleanup((()=>{C&&(C(),C=null)})),r.createComputed(r.on((()=>l().defaultQueryOptions(e())),(()=>f.setOptions(l().defaultQueryOptions(e()))),{defer:!0})),r.createComputed(r.on((()=>p.status),(()=>{if(p.isError&&!p.isFetching&&a(f.options.throwOnError,[p.error,f.getCurrentQuery()]))throw p.error})));return new Proxy(p,{get(e,t){const r=b()?.[t];return void 0!==r?r:Reflect.get(e,t)}})}function d(){}e.QueryClient=i,e.QueryClientContext=u,e.QueryClientProvider=e=>(r.onMount((()=>{e.client.mount()})),r.onCleanup((()=>e.client.unmount())),n.createComponent(u.Provider,{get value(){return e.client},get children(){return e.children}})),e.createInfiniteQuery=function(e,n){return l(r.createMemo((()=>e())),t.InfiniteQueryObserver,n)},e.createMutation=function(e,n){const i=s(n?.()),u=new t.MutationObserver(i,e()),c=(e,t)=>{u.mutate(e,t).catch(d)},[l,f]=o.createStore({...u.getCurrentResult(),mutate:c,mutateAsync:u.getCurrentResult().mutate});r.createComputed((()=>{u.setOptions(e())})),r.createComputed(r.on((()=>l.status),(()=>{if(l.isError&&a(u.options.throwOnError,[l.error]))throw l.error})));const p=u.subscribe((e=>{f({...e,mutate:c,mutateAsync:e.mutate})}));return r.onCleanup(p),l},e.createQueries=function(e,n){const i=s(n?.()),u=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t})),a=new t.QueriesObserver(i,u,e().combine?{combine:e().combine}:void 0),[c,l]=o.createStore(a.getOptimisticResult(u)[1]()),d=a.subscribe((e=>{t.notifyManager.batchCalls((()=>{l(o.unwrap(e))}))()}));return r.onCleanup(d),r.createComputed((()=>{const t=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t}));a.setQueries(t,e().combine?{combine:e().combine}:void 0,{listeners:!1})})),c},e.createQuery=function(e,n){return l(r.createMemo((()=>e())),t.QueryObserver,n)},e.queryOptions=function(e){return e},e.useIsFetching=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getQueryCache())),[i,u]=r.createSignal(n().isFetching(e?.())),a=o().subscribe((()=>{u(n().isFetching(e?.()))}));return r.onCleanup(a),i},e.useIsMutating=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getMutationCache())),[i,u]=r.createSignal(n().isMutating(e?.())),a=o().subscribe((t=>{u(n().isMutating(e?.()))}));return r.onCleanup(a),i},e.useQueryClient=s,Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})}))}));
//# sourceMappingURL=index.js.map
{
"name": "@tanstack/solid-query",
"version": "5.0.0-alpha.32",
"version": "5.0.0-alpha.33",
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",

@@ -46,3 +46,3 @@ "author": "tannerlinsley",

"dependencies": {
"@tanstack/query-core": "5.0.0-alpha.32"
"@tanstack/query-core": "5.0.0-alpha.33"
},

@@ -49,0 +49,0 @@ "peerDependencies": {

@@ -6,2 +6,3 @@ import type {

DefaultError,
QueriesObserverOptions,
} from '@tanstack/query-core'

@@ -11,3 +12,3 @@ import { notifyManager, QueriesObserver } from '@tanstack/query-core'

import type { Accessor } from 'solid-js'
import { createComputed, onCleanup, onMount } from 'solid-js'
import { createComputed, onCleanup } from 'solid-js'
import { createStore, unwrap } from 'solid-js/store'

@@ -153,8 +154,12 @@ import { useQueryClient } from './QueryClientProvider'

export function createQueries<T extends any[]>(
export function createQueries<
T extends any[],
TCombinedResult = QueriesResults<T>,
>(
queriesOptions: Accessor<{
queries: readonly [...QueriesOptions<T>]
combine?: (result: QueriesResults<T>) => TCombinedResult
}>,
queryClient?: Accessor<QueryClient>,
): QueriesResults<T> {
): TCombinedResult {
const client = useQueryClient(queryClient?.())

@@ -168,6 +173,15 @@

const observer = new QueriesObserver(client, defaultedQueries)
const observer = new QueriesObserver(
client,
defaultedQueries,
queriesOptions().combine
? ({
combine: queriesOptions().combine,
} as QueriesObserverOptions<TCombinedResult>)
: undefined,
)
const [state, setState] = createStore(
observer.getOptimisticResult(defaultedQueries),
// @ts-expect-error - Types issue with solid-js createStore
const [state, setState] = createStore<TCombinedResult>(
observer.getOptimisticResult(defaultedQueries)[1](),
)

@@ -177,3 +191,3 @@

notifyManager.batchCalls(() => {
setState(unwrap(result))
setState(unwrap(result) as unknown as TCombinedResult)
})()

@@ -184,6 +198,2 @@ })

onMount(() => {
observer.setQueries(defaultedQueries, { listeners: false })
})
createComputed(() => {

@@ -195,6 +205,14 @@ const updatedQueries = queriesOptions().queries.map((options) => {

})
observer.setQueries(updatedQueries)
observer.setQueries(
updatedQueries,
queriesOptions().combine
? ({
combine: queriesOptions().combine,
} as QueriesObserverOptions<TCombinedResult>)
: undefined,
{ listeners: false },
)
})
return state as QueriesResults<T>
return state
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc