File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,11 @@ export class QueryCache extends Subscribable<QueryCacheListener> {
109109 arg2 ?: QueryFilters
110110 ) : Query < TQueryFnData , TError , TData > | undefined {
111111 const [ filters ] = parseFilterArgs ( arg1 , arg2 )
112+
113+ if ( typeof filters . exact === 'undefined' ) {
114+ filters . exact = true
115+ }
116+
112117 return this . queries . find ( query => matchQuery ( filters , query ) )
113118 }
114119
Original file line number Diff line number Diff line change @@ -153,6 +153,25 @@ describe('queryClient', () => {
153153 } )
154154 } )
155155
156+ describe ( 'getQueryData' , ( ) => {
157+ test ( 'should return the query data if the query is found' , ( ) => {
158+ const key = queryKey ( )
159+ queryClient . setQueryData ( [ key , 'id' ] , 'bar' )
160+ expect ( queryClient . getQueryData ( [ key , 'id' ] ) ) . toBe ( 'bar' )
161+ } )
162+
163+ test ( 'should return undefined if the query is not found' , ( ) => {
164+ const key = queryKey ( )
165+ expect ( queryClient . getQueryData ( key ) ) . toBeUndefined ( )
166+ } )
167+
168+ test ( 'should match exact by default' , ( ) => {
169+ const key = queryKey ( )
170+ queryClient . setQueryData ( [ key , 'id' ] , 'bar' )
171+ expect ( queryClient . getQueryData ( [ key ] ) ) . toBeUndefined ( )
172+ } )
173+ } )
174+
156175 describe ( 'fetchQuery' , ( ) => {
157176 // https://github.com/tannerlinsley/react-query/issues/652
158177 test ( 'should not retry by default' , async ( ) => {
You can’t perform that action at this time.
0 commit comments