-
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
Remove the query store from Redux #1859
Conversation
31def68
to
0d91982
Compare
@shadaj I changed the target from |
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 have a few comments, but I also seem to recall we wanted to put all this stuff inside ObservableQuery
. This can be a fine intermediate step I guess, but did we want to just go straight for that?
src/core/QueryManager.ts
Outdated
@@ -445,6 +447,12 @@ export class QueryManager { | |||
|
|||
// Initialize query in store with unique requestId | |||
this.queryDocuments[queryId] = queryDoc; | |||
|
|||
this.queryStore.initQuery(queryId, queryString, queryDoc, shouldFetch, variables, fetchType === FetchType.poll, |
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 we make this take keyword arguments? Lists of positional arguments with more than 2 items freak me out since it's so easy to get the order wrong.
src/core/QueryManager.ts
Outdated
this.queryStore.initQuery(queryId, queryString, queryDoc, shouldFetch, variables, fetchType === FetchType.poll, | ||
fetchType === FetchType.refetch, metadata, fetchMoreForQueryId); | ||
|
||
this.broadcastQueries(); |
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.
Should this go after the dispatch
?
src/core/QueryManager.ts
Outdated
|
||
this.broadcastQueries = orig; | ||
|
||
const { reducerError } = this.getApolloState(); |
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.
Oh man, this sucks.
src/core/QueryManager.ts
Outdated
@@ -1110,6 +1129,9 @@ export class QueryManager { | |||
|
|||
// default the lastRequestId to 1 | |||
if (requestId >= (this.lastRequestId[queryId] || 1)) { | |||
const orig = this.broadcastQueries; | |||
this.broadcastQueries = () => undefined; |
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 really want to find some way to not have to turn off query broadcasting in this way, like if we could maybe update the query status first?
However, if we really have to I'd prefer a flag like disableBroadcasting = true
rather than overwriting the function like this.
src/queries/store.ts
Outdated
|
||
const previousQuery = previousState[action.queryId]; | ||
public initQuery(queryId: string, queryString: string, document: DocumentNode, storePreviousVariables: boolean, | ||
variables: Object, isPoll: boolean, isRefetch: boolean, metadata: any, fetchMoreForQueryId: string | undefined) { |
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.
Def switch this to a single object argument.
3e81ea4
to
fd1017d
Compare
I think this can be put in as an intermediate change because it maintains the shape of the original Redux store, which eases the transition for people who were directly reading from the store in Redux before. |
Any reason the tests aren't passing? |
Looks like the bundle size checker is saying that the built bundle is too large. |
fd1017d
to
db5d7a2
Compare
src/core/QueryManager.ts
Outdated
@@ -1110,6 +1139,9 @@ export class QueryManager { | |||
|
|||
// default the lastRequestId to 1 | |||
if (requestId >= (this.lastRequestId[queryId] || 1)) { | |||
const orig = this.broadcastQueries; |
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.
This line is not used anymore
4127a4b
to
1756ab3
Compare
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.
@shadaj a few minor changes and questions here. This is looking great! Excited to alpha it asap!
src/core/QueryManager.ts
Outdated
isPoll: fetchType === FetchType.poll, | ||
isRefetch: fetchType === FetchType.refetch, | ||
fetchMoreForQueryId, | ||
metadata, | ||
metadata, fetchMoreForQueryId, |
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 we new line this?
src/mutations/store.ts
Outdated
@@ -1,12 +1,12 @@ | |||
export class MutationStore { | |||
private store: {[mutationId: string]: MutationStoreValue} = {}; | |||
public _store: {[mutationId: string]: MutationStoreValue} = {}; |
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.
If this is public, why the underscore prefix? Would it be better to have this behind a getter?
src/queries/store.ts
Outdated
selectionSet: SelectionSetNode; | ||
} | ||
export class QueryStore { | ||
public _store: {[queryId: string]: QueryStoreValue} = {}; |
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.
Same question as the mutation store access level
src/queries/store.ts
Outdated
|
||
const previousQuery = previousState[action.queryId]; | ||
public initQuery(query: {queryId: string, queryString: string, document: DocumentNode, storePreviousVariables: boolean, |
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.
*nit: can we reformat this to make it more legible?
process.env.NODE_ENV = 'test'; | ||
QueryManager.EMIT_REDUX_ACTIONS = false; | ||
|
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.
@shadaj can we add a test to make sure that actions are still emitted when this is true? I'd like to make sure both cases work
@jbaxleyiii everything should be fixed now! |
a8b1675
to
1e6e7e2
Compare
1e6e7e2
to
e0a93dc
Compare
e0a93dc
to
05f1aaa
Compare
* Remove mutation tracking from the store * Remove the query store from Redux (#1859)
Depends on #1846
This moves out the query store out from Redux into a separate class. Many now unused Redux actions are still dispatched for compatibility with applications that depend on those actions.
TODO: