-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide queryRef in a Symbol in useBackgroundQuery
return value
#11010
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ccab651
chore: hide queryRef in a Symbol (closes #10875)
alessbell c775f3e
chore: add changeset
alessbell 561ccab
chore: prettier fixes
alessbell 35b7667
fix: rename useReadQuery parameter to queryRef
alessbell d2c2379
chore: increase size limit
alessbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@apollo/client': patch | ||
--- | ||
|
||
Hide queryRef in a Symbol in `useBackgroundQuery`s return value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ import { | |
import { concatPagination, offsetLimitPagination } from '../../../utilities'; | ||
import { useBackgroundQuery, useReadQuery } from '../useBackgroundQuery'; | ||
import { ApolloProvider } from '../../context'; | ||
import { QUERY_REFERENCE_SYMBOL } from '../../cache/QueryReference'; | ||
import { SuspenseCache } from '../../cache'; | ||
import { InMemoryCache } from '../../../cache'; | ||
import { | ||
|
@@ -617,7 +618,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A note to anyone who'd argue these tests are testing implementation details: I'd agree! The vast majority are integration tests, though we also have a few unit tests that violate this rule in a way that feels like an acceptable tradeoff to keep some tests more compact :) |
||
|
||
expect(_result).toEqual({ | ||
data: { hello: 'world 1' }, | ||
|
@@ -654,7 +655,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
await waitFor(() => { | ||
expect(_result).toEqual({ | ||
|
@@ -739,7 +740,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
await waitFor(() => { | ||
expect(_result).toMatchObject({ | ||
|
@@ -803,7 +804,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
const resultSet = new Set(_result.data.results); | ||
const values = Array.from(resultSet).map((item) => item.value); | ||
|
||
|
@@ -868,7 +869,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
const resultSet = new Set(_result.data.results); | ||
const values = Array.from(resultSet).map((item) => item.value); | ||
|
||
|
@@ -913,7 +914,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
expect(_result).toEqual({ | ||
data: { hello: 'from link' }, | ||
|
@@ -956,7 +957,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
expect(_result).toEqual({ | ||
data: { hello: 'from cache' }, | ||
|
@@ -1006,7 +1007,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
expect(_result).toEqual({ | ||
data: { foo: 'bar', hello: 'from link' }, | ||
|
@@ -1049,7 +1050,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
expect(_result).toEqual({ | ||
data: { hello: 'from link' }, | ||
|
@@ -1095,7 +1096,7 @@ describe('useBackgroundQuery', () => { | |
|
||
const [queryRef] = result.current; | ||
|
||
const _result = await queryRef.promise; | ||
const _result = await queryRef[QUERY_REFERENCE_SYMBOL].promise; | ||
|
||
expect(_result).toEqual({ | ||
data: { hello: 'from link' }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to suggestions/wordsmithing here! I'm not wedded to this language, but wanted something short and that gets at the notion that
QueryReference
should only be passed intouseReadQuery
/its properties should not be accessed directly.