Open dustinfarris opened 7 years ago
i'll need to know all the variables that are used here: https://github.com/mattkrick/cashay/blob/8d9174d478b63883f68b64f82c183b60a3aad0c4/src/normalize/denormalizeStore.js#L75. I'm not sure how fieldState
could be undefined.
I have exactly the same error:
Uncaught TypeError: Cannot read property 'length' of undefined
at visitIterable (denormalizeStore.js:137)
at visitObject (denormalizeStore.js:111)
at denormalizeStore (denormalizeStore.js:178)
at CachedQuery.createResponse (helperClasses.js:89)
at Cashay.query (Cashay.js:443)
at ProxyComponent.mapStateToProps [as finalMapStateToProps] (calendar.jsx:192)
at ProxyComponent.computeStateProps (connect.js:146)
at ProxyComponent.computeStateProps (createPrototypeProxy.js:44)
at ProxyComponent.updateStatePropsIfNeeded (connect.js:204)
at ProxyComponent.updateStatePropsIfNeeded (createPrototypeProxy.js:44)
(with real line numbers)
It happens when the variables are modified, except the first time. If I use "setVariables" returning currentVariables there is no problem. If I return something else, I have the error.
Some code:
const eventsQuery = `
query($from: Date, $to: Date) {
events(from: $from, to: $to) {
id
title
url
start
end
}
}
`
const mapStateToProps = (state) => {
return {
events: cashay.query(eventsQuery, {
op: 'eventList',
})
}
}
class Calendar extends React.Component {
componentDidMount() {
$(this.calendarRef).calendar({
events_source: (from, to) => {
const {setVariables} = this.props.events
setVariables(currentVariables => {
const newVariables = {
from: new Date(from).getTime(),
to: new Date(to).getTime()
}
console.log(currentVariables)
console.log(newVariables)
return newVariables
})
return []
}
})
}
Anything else I could provide?
@dustinfarris : have you found any explanation?
@slaivyn I was not able to get this to work.
I ended up running the query manually:
const { data } = cashay.getTransport().handleQuery({ query, variables });
Thank you @dustinfarris!
I am getting this error on subsequent updates to a query that looks like this:
it's for a search box that updates as you type.
the first hit goes through ok, but the second time around throws the above error.
in visitObject here
leading to visitIterable here where the error is thrown