Skip to content

Instantly share code, notes, and snippets.

@lindesvard
Created May 23, 2019 10:43
Show Gist options
  • Save lindesvard/f7094e984352f0549ade82b6388f8b6a to your computer and use it in GitHub Desktop.
Save lindesvard/f7094e984352f0549ade82b6388f8b6a to your computer and use it in GitHub Desktop.
Query.hack.js
// this file is imported by the entry point before any React code runs
import { Query } from 'react-apollo'
/**
* partialRefetch should always be true, but it defaults to false for reasons
* that are totally unimaginable to me. this hacks it on for us.
*
* note: today, Query has no defaultProps but this Object.assign ensures it works either way
* and will explicitly override any current or future value for `partialRefetch`.
*/
Query.defaultProps = Object.assign({}, Query.defaultProps, {
partialRefetch: true,
})
export default Query
if (
process.env.NODE_ENV !== 'production' &&
!Query.defaultProps.partialRefetch
) {
throw new Error(
'Unable to default partialRefetch for Apollo Query component.'
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment