-
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
apollo-client is producing a massive state for just a few queries #660
Comments
It looks like most of the size comes from the |
@gajus the problem is that you are serializing an object that has recursive/self-referential data. The Do you want to submit a PR to strip out the The parsing is handled here, in the |
Are you suggesting that |
Yeah, it's actually not used anywhere (even when printing). It's just something that the GraphQL parser returns, and we didn't bother removing it. |
You could use a function similar to this: https://github.com/apollostack/apollo-client/blob/364bd3612b1f2f987764dcefc7123df01c142a08/src/data/debug.ts#L8 |
@stubailo I think this was closed too early. The Here is how the state looks at the moment, https://gist.github.com/gajus/33797f17781259697ce03a58ad788ab0. Thats a lot better (12587 characters). However, it could be easily cut down to less.
|
For (1), we definitely need the parsed query. All of Apollo's internal logic depends on being able to execute the queries against the store, and you need to parse it to do that. For (2), we currently do use it, but we will remove it as soon as we resolve #615, which will hopefully be this week. If you have any additional ideas, let's open then as new issues? I'm sure there will always be some optimizations to be made in terms of store size, and so this issue would be open basically forever. |
But you can parse it on the client-side. |
Oh, are you referring specifically to serializing the state on the server for store hydration? |
Yes. |
OK, perhaps let's open another issue - identify state that can be eliminated from the server-side hydration. I'm sure there is a lot more stuff that is used on the client side but doesn't need to be in the intial payload. |
I making just two simple queries and that produces state object that takes 88867 characters to represent.
Here is a beautified version of the latter state, https://gist.github.com/gajus/6b73c75d88ec8e72c5f6d28976ddd612.
The text was updated successfully, but these errors were encountered: