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

@8base/apollo-provider

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@8base/apollo-provider - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

24

es/ApolloProvider.js

@@ -40,3 +40,3 @@ import _regeneratorRuntime from 'babel-runtime/regenerator';

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ApolloProvider.__proto__ || Object.getPrototypeOf(ApolloProvider)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
client: null
apolloClient: null
}, _temp), _possibleConstructorReturn(_this, _ret);

@@ -49,3 +49,3 @@ }

var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _props, uri, getClient, schemaJson, client;
var _props, uri, getClient, schemaJson, apolloClient;

@@ -62,6 +62,6 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

schemaJson = _context.sent;
client = getClient(schemaJson);
apolloClient = getClient(schemaJson);
this.setState({ client: client });
this.setState({ apolloClient: apolloClient });

@@ -85,15 +85,19 @@ case 6:

value: function render() {
var client = this.state.client;
var apolloClient = this.state.apolloClient;
var children = this.props.children;
var isClientCreated = !R.isNil(client);
var isClientCreated = !R.isNil(apolloClient);
var isLoading = !isClientCreated;
var rendered = typeof children === 'function' ? children({ isLoading: isLoading }) : children;
var rendered = typeof children === 'function' ? children({ isLoading: isLoading, apolloClient: apolloClient }) : children;
return isClientCreated ? React.createElement(
if (isLoading) {
return rendered;
}
return React.createElement(
DefaultApolloProvider,
{ client: client },
{ client: apolloClient },
rendered
) : rendered;
);
}

@@ -100,0 +104,0 @@ }]);

@@ -21,3 +21,4 @@ import _regeneratorRuntime from 'babel-runtime/regenerator';

body: JSON.stringify({
query: '\n {\n __schema {\n types {\n kind\n name\n possibleTypes {\n name\n }\n }\n }\n }\n '
operationName: 'FragmentsSchema',
query: '\n query FragmentsSchema {\n __schema {\n types {\n kind\n name\n possibleTypes {\n name\n }\n }\n }\n }\n '
})

@@ -24,0 +25,0 @@ }).then(function (result) {

{
"name": "@8base/apollo-provider",
"version": "0.1.4",
"version": "0.1.5",
"main": "es/index.js",

@@ -5,0 +5,0 @@ "module": "es/index.js",

// @flow
import React, { PureComponent } from 'react';
import * as R from 'ramda';
import { ApolloProvider as DefaultApolloProvider } from 'react-apollo';
import { ApolloProvider as DefaultApolloProvider, type ApolloClient } from 'react-apollo';
import { getFragmentsSchema } from './schemaLoader';
type ApolloClient = *;
type ApolloProviderState = {
client: ?ApolloClient,
apolloClient: ?ApolloClient,
}
type ApolloProviderProps = {
children: React$Node | ({ isLoading: boolean }) => React$Node,
children: React$Node | ({ isLoading: boolean, apolloClient: ApolloClient }) => React$Node,
uri: string,

@@ -28,3 +26,3 @@ getClient: (schema?: ?Object) => ?ApolloClient,

state = {
client: null,
apolloClient: null,
};

@@ -35,24 +33,26 @@

const schemaJson = await getFragmentsSchema(uri);
const client = getClient(schemaJson);
const apolloClient = getClient(schemaJson);
this.setState({ client });
this.setState({ apolloClient });
}
render() {
const { client } = this.state;
const { apolloClient } = this.state;
const { children } = this.props;
const isClientCreated = !R.isNil(client);
const isClientCreated = !R.isNil(apolloClient);
const isLoading = !isClientCreated;
const rendered = typeof children === 'function'
? children({ isLoading })
? children({ isLoading, apolloClient })
: children;
return isClientCreated
? (
<DefaultApolloProvider client={ client }>
{ rendered }
</DefaultApolloProvider>
)
: rendered;
if (isLoading) {
return rendered;
}
return (
<DefaultApolloProvider client={ apolloClient }>
{ rendered }
</DefaultApolloProvider>
);
}

@@ -59,0 +59,0 @@ }

@@ -10,4 +10,5 @@ // @flow

body: JSON.stringify({
operationName: 'FragmentsSchema',
query: `
{
query FragmentsSchema {
__schema {

@@ -14,0 +15,0 @@ types {

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