Created
May 23, 2019 10:43
-
-
Save lindesvard/f7094e984352f0549ade82b6388f8b6a to your computer and use it in GitHub Desktop.
Query.hack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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