Im getting a weird error after updating from 0.4.12 to 0.4.16
Log:
action @ 10:19:13.762 APOLLO_QUERY_INIT
action @ 10:19:13.777 APOLLO_QUERY_INIT
action @ 10:19:13.869 APOLLO_QUERY_RESULT
action @ 10:19:13.874 APOLLO_QUERY_ERROR
action @ 10:19:13.878 APOLLO_QUERY_RESULT
action @ 10:19:13.881 APOLLO_QUERY_ERROR
Error:
{
type: "APOLLO_QUERY_ERROR",
error: TypeError: Cannot read property 'queries' of undefined at next (http://localhost:3000/packages/m…, queryId: "2", requestId: 3
}
My queries server side and testing them from /graphiql works great
at first i thought it was something to do with my reducer... this is my client, but seems to work fine for other versions:
const client= new ApolloClient({ networkInterface });
const rootReducer = combineReducers({
gestorFiltros,
apollo: client.reducer()
});
//client.middleware(), createLogger() en caso de debugeo
const store = createStore(
rootReducer, {},
applyMiddleware(client.middleware(), createLogger()),
window.devToolsExtension ? window.devToolsExtension() : f => f
);
Meteor.startup(() => {
localStorage.debug = null
ReactDOM.render(
<ApolloProvider store={store} client={client}>
<Rutas />
</ApolloProvider>,
document.getElementById('app')
);
});
i just added the reduxRootKey
const client = new ApolloClient({
networkInterface,
reduxRootKey: 'apollo',
});
just seems that @rricard already posted minutes before me.
We just published a 0.4.17 which is identical to 0.4.15. Use that while we fix the issues.
@cristiandley this should be fixed in 0.4.18 (which contains all the changes from 0.4.16, and fixes for this issue and another one)
I'm still getting this 0.4.18
0.4.17 does work
My ApolloClient config looks like
import ApolloClient, { createNetworkInterface } from 'apollo-client'
const networkInterface = createNetworkInterface('/graphql', {
credentials: 'same-origin' // allows cookies to be passed
})
export const client = new ApolloClient({ networkInterface })
Hmm, ok, let me take another look.
@tim-field I'm trying to reproduce the issue with our example app, but so far I've been unsuccessful. Would you be able to provide a minimal reproduction?
Ha, hmm sorry, not sure if I can provide a minimal reproduction, quite a few moving parts in such a project. I've just locked my package file to 0.4.17 and that definitely fixes it.
Any files that you would like to see ?
I've included some snippets of apollo usage from the app in case that helps.
./helpers/ApolloClient
import ApolloClient, { createNetworkInterface } from 'apollo-client'
const networkInterface = createNetworkInterface('/graphql', {
credentials: 'same-origin' // allows cookies to be passed
})
export const client = new ApolloClient({ networkInterface })
main.js
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import {client} from './helpers/ApolloClient'
import reducer from './reducers'
...
let store = createStore(
reducer, compose(
applyMiddleware(client.middleware(), thunk.withExtraArgument(client)),
window.devToolsExtension ? window.devToolsExtension() : f => f
))
...
document.addEventListener('DOMContentLoaded', () => {
render(
<ApolloProvider client={client} store={store}>
<Router history={history}>
...
component
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
import MenuItems from '../../components/Menu/MenuItems'
import {menuItemFragment} from '../../components/Menu/MenuItem'
const MenuItemsWithData = graphql(gql`
query getProducts($categoryName: String) {
wp_query {
products(posts_per_page: -1, category_name: $categoryName) {
ID
...menuItem
}
}
}
`,{
options: ownProps => ({
variables: {
categoryName: ownProps.category
},
fragments: menuItemFragment
})
})(MenuItems)
export default MenuItemsWithData
@tim-field: are you constructing the store separately somewhere (since you pass the store to ApolloProvider)? In that case I think we don't currently set a default reduxRootKey. I guess if we want to have that backwards-compatibility we need to.
That definitely sounds like the problem here.
Another potential cause could be if react-apollo tried to read the reduxRootKey before the store was initialized, because currently the default gets set in initStore.
Sorry @helfer I've updated my above comment to include the store creation
Thanks @tim-field, I think we're getting closer. It appears that we need to set a default reduxRootKey when apollo is used as a middleware. I didn't realize that was a different path. Should be fixed shortly.
Should be fixed in 0.4.19, can you confirm @tim-field?
@helfer yep 0.4.19 is working. Thanks :)
@helfer working for me ! :+1:
Let's close this then! 😉 🎉