-
Notifications
You must be signed in to change notification settings - Fork 898
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
Fix error caused by undefined "trackedQuery" in QueryManager #8570
Fix error caused by undefined "trackedQuery" in QueryManager #8570
Conversation
🦋 Changeset detectedLatest commit: d4de37a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Vertex AI Mock Responses Check
|
Size Report 1Affected Products
Test Logs |
); | ||
|
||
expect(() => qm.executeQuery(mutationRef)).to.throw(error.message); | ||
expect(() => qm.executeQuery(queryRef)).to.not.throw(error.message); |
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.
You should just be able to call executeQuery(dc, queryRef)
here and similarly the line before, though I'd recommend renaming both of those variables to prevent conflicts with the queryRef
and mutationRef
functions
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.
Accepted in commit a0ecb6f
refType: MUTATION_STR as 'query' | ||
}; | ||
|
||
const queryRef: QueryRef<string, string> = { |
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.
I'd recommend creating a queryRef
the same way that most users do: by calling queryRef(dc, queryName);
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.
Accepted in commit a0ecb6f
}); | ||
|
||
const mutationRef: QueryRef<string, string> = { | ||
name: 'm', |
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.
Call mutationRef
here as well
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.
Accepted in commit a0ecb6f
const rt = new RESTTransport(options, undefined, undefined, authProvider); | ||
const qm = new QueryManager(rt); | ||
const app = initializeApp({ projectId: 'p' }); | ||
const dc = getDataConnect(app, { |
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.
Can you clean these up in an afterEach
, like here:
firebase-js-sdk/packages/data-connect/test/unit/gmpid.test.ts
Lines 43 to 50 in a214691
beforeEach(() => { | |
initializeFetch(fakeFetchImpl); | |
app = initializeApp({ projectId: 'p', appId: APPID }, 'fdsasdf'); // TODO(mtewani): Replace with util function | |
dc = getDataConnect(app, { connector: 'c', location: 'l', service: 's' }); | |
}); | |
afterEach(async () => { | |
await dc._delete(); | |
await deleteApp(app); |
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.
Accepted in commit a0ecb6f
Size Analysis Report 1Affected Products
Test Logs |
…executeQuery-refType-mismatch
…test.ts' test cases
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.
Accepted changes to new unit test proposed by @maneesht in review
const rt = new RESTTransport(options, undefined, undefined, authProvider); | ||
const qm = new QueryManager(rt); | ||
const app = initializeApp({ projectId: 'p' }); | ||
const dc = getDataConnect(app, { |
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.
Accepted in commit a0ecb6f
}); | ||
|
||
const mutationRef: QueryRef<string, string> = { | ||
name: 'm', |
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.
Accepted in commit a0ecb6f
refType: MUTATION_STR as 'query' | ||
}; | ||
|
||
const queryRef: QueryRef<string, string> = { |
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.
Accepted in commit a0ecb6f
); | ||
|
||
expect(() => qm.executeQuery(mutationRef)).to.throw(error.message); | ||
expect(() => qm.executeQuery(queryRef)).to.not.throw(error.message); |
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.
Accepted in commit a0ecb6f
.changeset/beige-roses-cross.md
Outdated
--- | ||
|
||
- Add check for non-query refType in `executeQuery` that throws error on refType mismatch | ||
- Add unit test to check that error is thrown when `executeQuery` receives non-query refType, and not thrown otherwise |
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.
Changelogs get added to release notes, and the unit tests aren't really relevant. Can we say something like:
Throw error when calling
executeQuery with mutations
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.
Accepted in commit d4de37a
executeQuery
that throws error on refType mismatchexecuteQuery
receives non-query refType, and doesn't throw error when receiving query refType