apollo-map-props
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -25,3 +25,3 @@ 'use strict'; | ||
var DEFAULT_FETCH_POLICY = 'cache-and-network'; | ||
var config = { fetchPolicy: 'cache-and-network' }; | ||
@@ -40,3 +40,3 @@ function getDisplayName(mapProps) { | ||
_reactApollo.Query, | ||
(0, _extends3.default)({ fetchPolicy: DEFAULT_FETCH_POLICY }, mapProps(props)), | ||
(0, _extends3.default)({ fetchPolicy: config.fetchPolicy }, mapProps(props)), | ||
function (result) { | ||
@@ -52,2 +52,7 @@ var mappedProps = mapResultToProps(result, props); | ||
}; | ||
} | ||
} | ||
withQuery.setConfig = function (newConfig) { | ||
config = (0, _extends3.default)({}, config, newConfig); | ||
console.log("config", config); | ||
}; |
{ | ||
"name": "apollo-map-props", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "To help with props mapping when using apollo with React", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -9,2 +9,11 @@ # apollo-map-props | ||
## Configuration | ||
The default fetchPolicy for withQuery is `cache-and-network`. | ||
Add below code to `index.js` for changing default fetchPolicy or adding other configs. | ||
```javascript | ||
import { withQuery } from 'apollo-map-props'; | ||
withQuery.setConfig({ fetchPolicy: 'network-only' }) | ||
``` | ||
## Usage | ||
@@ -11,0 +20,0 @@ |
@@ -5,3 +5,3 @@ import React from 'react'; | ||
const DEFAULT_FETCH_POLICY = 'cache-and-network'; | ||
let config = { fetchPolicy: 'cache-and-network' }; | ||
@@ -18,3 +18,3 @@ function getDisplayName(mapProps) { | ||
const component = props => ( | ||
<Query fetchPolicy={DEFAULT_FETCH_POLICY} {...mapProps(props)}> | ||
<Query fetchPolicy={config.fetchPolicy} {...mapProps(props)}> | ||
{result => { | ||
@@ -31,1 +31,5 @@ const mappedProps = mapResultToProps(result, props); | ||
} | ||
withQuery.setConfig = newConfig => { | ||
config = { ...config, ...newConfig }; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16262
221
113