Skip to content

Commit

Permalink
feat: add useBackgroundQuery and useReadQuery hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed May 8, 2023
1 parent 35f36c5 commit 4438ab7
Show file tree
Hide file tree
Showing 7 changed files with 732 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ src/react/hooks/*
!src/react/hooks/internal
!src/react/hooks/useSuspenseCache.ts
!src/react/hooks/useSuspenseQuery.ts
!src/react/hooks/useBackgroundQuery.ts

## Allowed React hook tests
!src/react/hooks/__tests__/
src/react/hooks/__tests__/*
!src/react/hooks/__tests__/useSuspenseQuery.test.tsx
!src/react/hooks/__tests__/useBackgroundQuery.test.tsx
3 changes: 2 additions & 1 deletion config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const react17TestFileIgnoreList = [
ignoreTSFiles,
// For now, we only support useSuspenseQuery with React 18, so no need to test
// it with React 17
'src/react/hooks/__tests__/useSuspenseQuery.test.tsx'
'src/react/hooks/__tests__/useSuspenseQuery.test.tsx',
'src/react/hooks/__tests__/useBackgroundQuery.test.tsx'
]

const tsStandardConfig = {
Expand Down
1 change: 1 addition & 0 deletions src/react/cache/QuerySubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class QuerySubscription<TData = unknown> {
public result: ApolloQueryResult<TData>;
public readonly observable: ObservableQuery<TData>;

public version: 'main' | 'network' = 'main';
public promises: {
main: Promise<ApolloQueryResult<TData>>;
network?: Promise<ApolloQueryResult<TData>>;
Expand Down
2 changes: 1 addition & 1 deletion src/react/cache/SuspenseCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export class SuspenseCache {

return this.subscriptions.get(stableCacheKey)! as QuerySubscription<TData>;
}
}
}
Loading

0 comments on commit 4438ab7

Please sign in to comment.