Skip to content
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

Merged
merged 1 commit into from
Jul 13, 2017
Merged

Conversation

shadaj
Copy link
Contributor

@shadaj shadaj commented Jul 5, 2017

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:

  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change

@shadaj shadaj self-assigned this Jul 5, 2017
@shadaj shadaj force-pushed the no-query-store branch 2 times, most recently from 31def68 to 0d91982 Compare July 7, 2017 17:37
@stubailo stubailo changed the base branch from master to no-mutations-store July 10, 2017 04:34
@stubailo
Copy link
Contributor

@shadaj I changed the target from master to no-mutations-store so this PR has only the changes from that.

Copy link
Contributor

@stubailo stubailo left a 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?

@@ -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,
Copy link
Contributor

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.

this.queryStore.initQuery(queryId, queryString, queryDoc, shouldFetch, variables, fetchType === FetchType.poll,
fetchType === FetchType.refetch, metadata, fetchMoreForQueryId);

this.broadcastQueries();
Copy link
Contributor

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?


this.broadcastQueries = orig;

const { reducerError } = this.getApolloState();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, this sucks.

@@ -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;
Copy link
Contributor

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.


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) {
Copy link
Contributor

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.

@shadaj
Copy link
Contributor Author

shadaj commented Jul 10, 2017

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.

@stubailo
Copy link
Contributor

Any reason the tests aren't passing?

@shadaj
Copy link
Contributor Author

shadaj commented Jul 11, 2017

Looks like the bundle size checker is saying that the built bundle is too large.

@@ -1110,6 +1139,9 @@ export class QueryManager {

// default the lastRequestId to 1
if (requestId >= (this.lastRequestId[queryId] || 1)) {
const orig = this.broadcastQueries;
Copy link
Contributor

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

@shadaj shadaj force-pushed the no-query-store branch 5 times, most recently from 4127a4b to 1756ab3 Compare July 12, 2017 23:16
Copy link
Contributor

@jbaxleyiii jbaxleyiii left a 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!

isPoll: fetchType === FetchType.poll,
isRefetch: fetchType === FetchType.refetch,
fetchMoreForQueryId,
metadata,
metadata, fetchMoreForQueryId,
Copy link
Contributor

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?

@@ -1,12 +1,12 @@
export class MutationStore {
private store: {[mutationId: string]: MutationStoreValue} = {};
public _store: {[mutationId: string]: MutationStoreValue} = {};
Copy link
Contributor

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?

selectionSet: SelectionSetNode;
}
export class QueryStore {
public _store: {[queryId: string]: QueryStoreValue} = {};
Copy link
Contributor

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


const previousQuery = previousState[action.queryId];
public initQuery(query: {queryId: string, queryString: string, document: DocumentNode, storePreviousVariables: boolean,
Copy link
Contributor

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;

Copy link
Contributor

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

@shadaj
Copy link
Contributor Author

shadaj commented Jul 13, 2017

@jbaxleyiii everything should be fixed now!

@jbaxleyiii jbaxleyiii merged commit aa43297 into no-mutations-store Jul 13, 2017
@jbaxleyiii jbaxleyiii deleted the no-query-store branch July 13, 2017 23:05
jbaxleyiii pushed a commit that referenced this pull request Jul 13, 2017
* Remove mutation tracking from the store

* Remove the query store from Redux (#1859)
shadaj added a commit that referenced this pull request Jul 13, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants