next-urql
Advanced tools
Comparing version 0.3.6 to 0.3.7
# Changelog | ||
## 0.3.7 | ||
### Patch Changes | ||
- Ensure that the Next.js context is available during all stages of SSR. Previously a missing check in `useMemo` on the server-side caused `clientConfig` from being called repeatedly, and another issue may have caused the client from being serialized to initial props, by [@parkerziegler](https://github.com/parkerziegler) (See [#719](https://github.com/FormidableLabs/urql/pull/719)) | ||
## 0.3.6 | ||
@@ -4,0 +10,0 @@ |
@@ -50,2 +50,6 @@ import React from "react"; | ||
function _ref2() { | ||
return null; | ||
} | ||
function withUrqlClient(clientConfig, mergeExchanges) { | ||
@@ -69,4 +73,6 @@ if (void 0 === mergeExchanges) { | ||
var client = React.useMemo((function() { | ||
var clientOptions = "function" == typeof clientConfig ? clientConfig() : clientConfig; | ||
return urqlClient || initUrqlClient(clientOptions, mergeExchanges, urqlState)[0]; | ||
if (urqlClient) { | ||
return urqlClient; | ||
} | ||
return initUrqlClient("function" == typeof clientConfig ? clientConfig() : clientConfig, mergeExchanges, urqlState)[0]; | ||
}), [ urqlClient, urqlState ]); | ||
@@ -83,5 +89,7 @@ return React.createElement(Provider, { | ||
withUrql.getInitialProps = function(appOrPageCtx) { | ||
function _ref2() { | ||
function _ref3() { | ||
urqlClient.toJSON = _ref2; | ||
return _extends({}, pageProps, { | ||
urqlState: ssrCache ? ssrCache.extractData() : void 0 | ||
urqlState: ssrCache ? ssrCache.extractData() : void 0, | ||
urqlClient: urqlClient | ||
}); | ||
@@ -100,5 +108,5 @@ } | ||
pageProps: props | ||
})))).then(_ref2); | ||
})))).then(_ref3); | ||
} | ||
function _ref3(_AppOrPage$getInitial) { | ||
function _ref4(_AppOrPage$getInitial) { | ||
pageProps = _AppOrPage$getInitial; | ||
@@ -117,5 +125,5 @@ } | ||
var pageProps = {}; | ||
const _temp = function _ref4() { | ||
const _temp = function _ref5() { | ||
if (AppOrPage.getInitialProps) { | ||
return Promise.resolve(AppOrPage.getInitialProps(appOrPageCtx)).then(_ref3); | ||
return Promise.resolve(AppOrPage.getInitialProps(appOrPageCtx)).then(_ref4); | ||
} | ||
@@ -122,0 +130,0 @@ }(); |
@@ -54,2 +54,6 @@ function _interopDefault(ex) { | ||
function _ref2() { | ||
return null; | ||
} | ||
exports.withUrqlClient = function withUrqlClient(clientConfig, mergeExchanges) { | ||
@@ -73,4 +77,6 @@ if (void 0 === mergeExchanges) { | ||
var client = React.useMemo((function() { | ||
var clientOptions = "function" == typeof clientConfig ? clientConfig() : clientConfig; | ||
return urqlClient || initUrqlClient(clientOptions, mergeExchanges, urqlState)[0]; | ||
if (urqlClient) { | ||
return urqlClient; | ||
} | ||
return initUrqlClient("function" == typeof clientConfig ? clientConfig() : clientConfig, mergeExchanges, urqlState)[0]; | ||
}), [ urqlClient, urqlState ]); | ||
@@ -87,5 +93,7 @@ return React.createElement(urql.Provider, { | ||
withUrql.getInitialProps = function(appOrPageCtx) { | ||
function _ref2() { | ||
function _ref3() { | ||
urqlClient.toJSON = _ref2; | ||
return _extends({}, pageProps, { | ||
urqlState: ssrCache ? ssrCache.extractData() : void 0 | ||
urqlState: ssrCache ? ssrCache.extractData() : void 0, | ||
urqlClient: urqlClient | ||
}); | ||
@@ -104,5 +112,5 @@ } | ||
pageProps: props | ||
})))).then(_ref2); | ||
})))).then(_ref3); | ||
} | ||
function _ref3(_AppOrPage$getInitial) { | ||
function _ref4(_AppOrPage$getInitial) { | ||
pageProps = _AppOrPage$getInitial; | ||
@@ -121,5 +129,5 @@ } | ||
var pageProps = {}; | ||
const _temp = function _ref4() { | ||
const _temp = function _ref5() { | ||
if (AppOrPage.getInitialProps) { | ||
return Promise.resolve(AppOrPage.getInitialProps(appOrPageCtx)).then(_ref3); | ||
return Promise.resolve(AppOrPage.getInitialProps(appOrPageCtx)).then(_ref4); | ||
} | ||
@@ -126,0 +134,0 @@ }(); |
@@ -1,2 +0,2 @@ | ||
import e from"react";import t from"react-ssr-prepass";import{ssrExchange as r,createClient as n,dedupExchange as o,cacheExchange as i,fetchExchange as u,Provider as a}from"urql";function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var c=null,f=null;function p(e){return[o,i,e,u]}function s(e,t,o){void 0===t&&(t=p);var i="undefined"==typeof window;return!i&&c||(f=r({initialState:o}),c=n(l({},e,{suspense:i||e.suspense,exchanges:t(f)}))),[c,f]}function v(e){return[o,i,e,u]}function m(r,n){return void 0===n&&(n=v),function(o){var i,u=function(t){var i=t.urqlClient,u=t.urqlState,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}(t,["urqlClient","urqlState"]),f=e.useMemo((function(){var e="function"==typeof r?r():r;return i||s(e,n,u)[0]}),[i,u]);return e.createElement(a,{value:f},e.createElement(o,l({urqlClient:f},c)))};return u.displayName="withUrqlClient("+((i=o).displayName||i.name||"Component")+")",u.getInitialProps=function(i){function u(){return l({},h,{urqlState:y?y.extractData():void 0})}function a(){if("undefined"!=typeof window)return l({},h,{urqlClient:d});var r=l({},h,{urqlClient:d});return Promise.resolve(t(e.createElement(f,l({},p?r:{pageProps:r})))).then(u)}function c(e){h=e}try{var f=i.AppTree,p=!!i.Component,v=p?i.ctx:i,m=s("function"==typeof r?r(v):r,n),d=m[0],y=m[1];d&&(v.urqlClient=d);var h={};const e=function(){if(o.getInitialProps)return Promise.resolve(o.getInitialProps(i)).then(c)}();return Promise.resolve(e&&e.then?e.then(a):a())}catch(e){return Promise.reject(e)}},u}}export{m as withUrqlClient}; | ||
import t from"react";import e from"react-ssr-prepass";import{ssrExchange as n,createClient as r,dedupExchange as o,cacheExchange as i,fetchExchange as u,Provider as l}from"urql";function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var c=null,f=null;function p(t){return[o,i,t,u]}function s(t,e,o){void 0===e&&(e=p);var i="undefined"==typeof window;return!i&&c||(f=n({initialState:o}),c=r(a({},t,{suspense:i||t.suspense,exchanges:e(f)}))),[c,f]}function m(t){return[o,i,t,u]}function v(){return null}function d(n,r){return void 0===r&&(r=m),function(o){var i,u=function(e){var i=e.urqlClient,u=e.urqlState,c=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["urqlClient","urqlState"]),f=t.useMemo((function(){return i||s("function"==typeof n?n():n,r,u)[0]}),[i,u]);return t.createElement(l,{value:f},t.createElement(o,a({urqlClient:f},c)))};return u.displayName="withUrqlClient("+((i=o).displayName||i.name||"Component")+")",u.getInitialProps=function(i){function u(){return q.toJSON=v,a({},h,{urqlState:y?y.extractData():void 0,urqlClient:q})}function l(){if("undefined"!=typeof window)return a({},h,{urqlClient:q});var n=a({},h,{urqlClient:q});return Promise.resolve(e(t.createElement(f,a({},p?n:{pageProps:n})))).then(u)}function c(t){h=t}try{var f=i.AppTree,p=!!i.Component,m=p?i.ctx:i,d=s("function"==typeof n?n(m):n,r),q=d[0],y=d[1];q&&(m.urqlClient=q);var h={};const t=function(){if(o.getInitialProps)return Promise.resolve(o.getInitialProps(i)).then(c)}();return Promise.resolve(t&&t.then?t.then(l):l())}catch(t){return Promise.reject(t)}},u}}export{d as withUrqlClient}; | ||
//# sourceMappingURL=next-urql.min.es.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("react")),n=e(require("react-ssr-prepass")),r=require("urql");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var u=null,a=null;function o(e){return[r.dedupExchange,r.cacheExchange,e,r.fetchExchange]}function c(e,t,n){void 0===t&&(t=o);var c="undefined"==typeof window;return!c&&u||(a=r.ssrExchange({initialState:n}),u=r.createClient(i({},e,{suspense:c||e.suspense,exchanges:t(a)}))),[u,a]}function l(e){return[r.dedupExchange,r.cacheExchange,e,r.fetchExchange]}exports.withUrqlClient=function(e,u){return void 0===u&&(u=l),function(a){var o,l=function(n){var o=n.urqlClient,l=n.urqlState,f=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===t.indexOf(r)&&(n[r]=e[r]);return n}(n,["urqlClient","urqlState"]),s=t.useMemo((function(){var t="function"==typeof e?e():e;return o||c(t,u,l)[0]}),[o,l]);return t.createElement(r.Provider,{value:s},t.createElement(a,i({urqlClient:s},f)))};return l.displayName="withUrqlClient("+((o=a).displayName||o.name||"Component")+")",l.getInitialProps=function(r){function o(){return i({},g,{urqlState:q?q.extractData():void 0})}function l(){if("undefined"!=typeof window)return i({},g,{urqlClient:d});var e=i({},g,{urqlClient:d});return Promise.resolve(n(t.createElement(s,i({},p?e:{pageProps:e})))).then(o)}function f(e){g=e}try{var s=r.AppTree,p=!!r.Component,h=p?r.ctx:r,v=c("function"==typeof e?e(h):e,u),d=v[0],q=v[1];d&&(h.urqlClient=d);var g={};const t=function(){if(a.getInitialProps)return Promise.resolve(a.getInitialProps(r)).then(f)}();return Promise.resolve(t&&t.then?t.then(l):l())}catch(e){return Promise.reject(e)}},l}}; | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var n=e(require("react")),t=e(require("react-ssr-prepass")),r=require("urql");function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var u=null,o=null;function a(e){return[r.dedupExchange,r.cacheExchange,e,r.fetchExchange]}function c(e,n,t){void 0===n&&(n=a);var c="undefined"==typeof window;return!c&&u||(o=r.ssrExchange({initialState:t}),u=r.createClient(i({},e,{suspense:c||e.suspense,exchanges:n(o)}))),[u,o]}function l(e){return[r.dedupExchange,r.cacheExchange,e,r.fetchExchange]}function f(){return null}exports.withUrqlClient=function(e,u){return void 0===u&&(u=l),function(o){var a,l=function(t){var a=t.urqlClient,l=t.urqlState,f=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===n.indexOf(r)&&(t[r]=e[r]);return t}(t,["urqlClient","urqlState"]),s=n.useMemo((function(){return a||c("function"==typeof e?e():e,u,l)[0]}),[a,l]);return n.createElement(r.Provider,{value:s},n.createElement(o,i({urqlClient:s},f)))};return l.displayName="withUrqlClient("+((a=o).displayName||a.name||"Component")+")",l.getInitialProps=function(r){function a(){return q.toJSON=f,i({},m,{urqlState:g?g.extractData():void 0,urqlClient:q})}function l(){if("undefined"!=typeof window)return i({},m,{urqlClient:q});var e=i({},m,{urqlClient:q});return Promise.resolve(t(n.createElement(p,i({},h?e:{pageProps:e})))).then(a)}function s(e){m=e}try{var p=r.AppTree,h=!!r.Component,v=h?r.ctx:r,d=c("function"==typeof e?e(v):e,u),q=d[0],g=d[1];q&&(v.urqlClient=q);var m={};const n=function(){if(o.getInitialProps)return Promise.resolve(o.getInitialProps(r)).then(s)}();return Promise.resolve(n&&n.then?n.then(l):l())}catch(e){return Promise.reject(e)}},l}}; | ||
//# sourceMappingURL=next-urql.min.js.map |
{ | ||
"name": "next-urql", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Convenience wrappers for using urql with NextJS.", | ||
@@ -44,3 +44,3 @@ "sideEffects": false, | ||
"enzyme-adapter-react-16": "^1.15.2", | ||
"graphql": "^14.6.0", | ||
"graphql": "^15.0.0", | ||
"graphql-tag": "^2.10.3", | ||
@@ -47,0 +47,0 @@ "isomorphic-unfetch": "^3.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63037
329