Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-react

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-react - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

18

changelog.md
# graphql-react changelog
## 6.0.0
### Major
- Made `preload` reject upon render errors instead of throwing.
### Minor
- Made `Query` component throw a helpful render error if the GraphQL context is missing.
### Patch
- Updated dev dependencies.
- Improved [`size-limit`](https://npm.im/size-limit) tests:
- Drop the CJS entrypoint; modern bundlers don’t use it and nested module imports revert resolve ESM anyway.
- Ignore [`prop-types`](https://npm.im/prop-types) since it’s likely to already be present in a React project, and most frameworks strip it out in production bundles anyway.
- Separately limit and test server and client bundles.
## 5.0.0

@@ -4,0 +22,0 @@

1

lib/components.js

@@ -158,2 +158,3 @@ 'use strict'

return _react.default.createElement(Consumer, null, function(graphql) {
if (!graphql) throw new Error('GraphQL context provider missing.')
return _react.default.createElement(

@@ -160,0 +161,0 @@ GraphQLQuery,

185

lib/preload.js

@@ -6,3 +6,3 @@ 'use strict'

exports.__esModule = true
exports.preload = preload
exports.preload = void 0

@@ -14,104 +14,113 @@ var _objectAssign = _interopRequireDefault(require('object-assign'))

function preload(element) {
var recursePreload = function recursePreload(
rootElement,
rootLegacyContext,
rootNewContext,
loadRoot
) {
if (rootLegacyContext === void 0) {
rootLegacyContext = {}
}
var preload = function preload(element) {
return new Promise(function(resolve) {
var recursePreload = function recursePreload(
rootElement,
rootLegacyContext,
rootNewContext,
loadRoot
) {
if (rootLegacyContext === void 0) {
rootLegacyContext = {}
}
if (rootNewContext === void 0) {
rootNewContext = new Map()
}
if (rootNewContext === void 0) {
rootNewContext = new Map()
}
if (loadRoot === void 0) {
loadRoot = true
}
if (loadRoot === void 0) {
loadRoot = true
}
var loading = []
var loading = []
var recurse = function recurse(element, legacyContext, newContext) {
if (!element) return
var recurse = function recurse(element, legacyContext, newContext) {
if (!element) return
if (Array.isArray(element)) {
element.forEach(function(item) {
return recurse(item, legacyContext, newContext)
})
return
}
if (Array.isArray(element)) {
element.forEach(function(item) {
return recurse(item, legacyContext, newContext)
})
return
}
if (
element.type &&
(element.type.$$typeof === REACT_CONTEXT_TYPE ||
typeof element.type === 'function')
) {
var props = (0, _objectAssign.default)(
{},
element.type.defaultProps,
element.props
)
if (element.type.$$typeof === REACT_CONTEXT_TYPE) {
var value = element.type._currentValue
var Provider = element.type._context
? element.type._context.Provider
: element.type.Provider
if (newContext && newContext.has(Provider))
value = newContext.get(Provider)
recurse(element.props.children(value), legacyContext, newContext)
} else if (
element.type.prototype &&
(element.type.prototype.isReactComponent ||
element.type.prototype.isPureReactComponent)
if (
element.type &&
(element.type.$$typeof === REACT_CONTEXT_TYPE ||
typeof element.type === 'function')
) {
var instance = new element.type(props, legacyContext)
instance.state = instance.state || null
var props = (0, _objectAssign.default)(
{},
element.type.defaultProps,
element.props
)
instance.setState = function(newState) {
if (typeof newState === 'function')
newState = newState(instance.state, instance.props)
instance.state = (0, _objectAssign.default)(
{},
instance.state,
newState
if (element.type.$$typeof === REACT_CONTEXT_TYPE) {
var value = element.type._currentValue
var Provider = element.type._context
? element.type._context.Provider
: element.type.Provider
if (newContext && newContext.has(Provider))
value = newContext.get(Provider)
recurse(element.props.children(value), legacyContext, newContext)
} else if (
element.type.prototype &&
(element.type.prototype.isReactComponent ||
element.type.prototype.isPureReactComponent)
) {
var instance = new element.type(props, legacyContext)
instance.state = instance.state || null
instance.setState = function(newState) {
if (typeof newState === 'function')
newState = newState(instance.state, instance.props)
instance.state = (0, _objectAssign.default)(
{},
instance.state,
newState
)
}
if (instance.componentWillMount) instance.componentWillMount()
if (instance.getChildContext)
legacyContext = (0, _objectAssign.default)(
{},
legacyContext,
instance.getChildContext()
)
if (
instance.constructor.name === 'GraphQLQuery' &&
element.props.loadOnMount &&
(element !== rootElement || loadRoot)
)
loading.push(
instance.load().then(function() {
return recursePreload(
element,
legacyContext,
newContext,
false
)
})
)
else recurse(instance.render(), legacyContext, newContext)
} else recurse(element.type(props), legacyContext, newContext)
} else if (element.props && element.props.children) {
if (element.type._context) {
newContext = new Map(newContext)
newContext.set(element.type, element.props.value)
}
if (instance.componentWillMount) instance.componentWillMount()
if (instance.getChildContext)
legacyContext = (0, _objectAssign.default)(
{},
legacyContext,
instance.getChildContext()
)
if (
instance.constructor.name === 'GraphQLQuery' &&
element.props.loadOnMount &&
(element !== rootElement || loadRoot)
)
loading.push(
instance.load().then(function() {
return recursePreload(element, legacyContext, newContext, false)
})
)
else recurse(instance.render(), legacyContext, newContext)
} else recurse(element.type(props), legacyContext, newContext)
} else if (element.props && element.props.children) {
if (element.type._context) {
newContext = new Map(newContext)
newContext.set(element.type, element.props.value)
recurse(element.props.children, legacyContext, newContext)
}
}
recurse(element.props.children, legacyContext, newContext)
}
recurse(rootElement, rootLegacyContext, rootNewContext)
return Promise.all(loading).then(function() {})
}
recurse(rootElement, rootLegacyContext, rootNewContext)
return Promise.all(loading)
}
recursePreload(element).then(resolve)
})
}
return recursePreload(element)
}
exports.preload = preload
{
"name": "graphql-react",
"version": "5.0.0",
"version": "6.0.0",
"description": "A lightweight GraphQL client for React.",

@@ -49,8 +49,8 @@ "license": "MIT",

"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",

@@ -61,3 +61,3 @@ "babel-eslint": "^10.0.1",

"cross-fetch": "^3.0.0",
"eslint": "^5.10.0",
"eslint": "^5.11.1",
"eslint-config-env": "^2.0.0",

@@ -78,5 +78,5 @@ "eslint-config-prettier": "^3.3.0",

"prettier": "^1.15.3",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"size-limit": "^0.21.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"size-limit": "^0.21.1",
"tap": "^12.1.1",

@@ -127,15 +127,17 @@ "watch": "^1.0.2"

{
"name": "ESM",
"path": "lib/index.mjs",
"limit": "3.5 KB",
"name": "Server",
"path": "size-limit-entries/server.mjs",
"limit": "3 KB",
"ignore": [
"object-assign"
"object-assign",
"prop-types"
]
},
{
"name": "CJS",
"path": "lib/index.js",
"limit": "3.5 KB",
"name": "Client",
"path": "size-limit-entries/client.mjs",
"limit": "2.5 KB",
"ignore": [
"object-assign"
"object-assign",
"prop-types"
]

@@ -142,0 +144,0 @@ }

@@ -247,3 +247,3 @@ ![graphql-react logo](https://cdn.jsdelivr.net/gh/jaydenseric/graphql-react@0.1.0/graphql-react-logo.svg)

**Returns:** [Promise](https://mdn.io/promise) — Resolves once loading is done and cache is ready to be exported from the [`GraphQL`](#class-graphql) instance. Cache can be imported when constructing new [`GraphQL`](#class-graphql) instances.
**Returns:** [Promise](https://mdn.io/promise)<void> — Resolves once loading is done and cache is ready to be exported from the [`GraphQL`](#class-graphql) instance. Cache can be imported when constructing new [`GraphQL`](#class-graphql) instances.

@@ -250,0 +250,0 @@ #### Examples

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc