File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -128,20 +128,28 @@ export class ApolloProvider {
128128 } )
129129 }
130130
131- exportStates ( options ) {
131+ getStates ( options ) {
132132 const finalOptions = Object . assign ( { } , {
133133 exportNamespace : '' ,
134- globalName : '__APOLLO_STATE__' ,
135- attachTo : 'window' ,
136134 } , options )
137-
138- let js = `${ finalOptions . attachTo } .${ finalOptions . globalName } = {`
135+ const states = { }
139136 for ( const key in this . clients ) {
140137 const client = this . clients [ key ]
141138 const state = { [ client . reduxRootKey || 'apollo' ] : client . getInitialState ( ) }
142- js += `[' ${ finalOptions . exportNamespace } ${ key } ']: ${ JSON . stringify ( state ) } ,`
139+ states [ ` ${ finalOptions . exportNamespace } ${ key } ` ] = state
143140 }
144- js += `};`
141+ return states
142+ }
143+
144+ exportStates ( options ) {
145+ const finalOptions = Object . assign ( { } , {
146+ globalName : '__APOLLO_STATE__' ,
147+ attachTo : 'window' ,
148+ } , options )
149+ const states = this . getStates ( {
150+ exportNamespace : options . exportNamespace ,
151+ } )
152+ const js = `${ finalOptions . attachTo } .${ finalOptions . globalName } = ${ JSON . stringify ( states ) } ;`
145153 return js
146154 }
147155}
You can’t perform that action at this time.
0 commit comments