Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function withApollo(
WrappedComponent,
operationOptions: OperationOption = {},
) {
const withDisplayName = `withApollo(${getDisplayName(WrappedComponent)})`;
class WithApollo extends Component {
static displayName = withDisplayName;
static WrappedComponent = WrappedComponent;
static contextTypes = { client: PropTypes.object.isRequired };
// data storage
private client: ApolloClient; // apollo client
constructor(props, context) {
super(props, context);
this.client = context.client;
invariant(!!this.client,
`Could not find "client" in the context of ` +
`"${withDisplayName}". ` +
`Wrap the root component in an `,
);
}
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
}),
client: PropTypes.object.isRequired,
immutable: PropTypes.bool,
children: PropTypes.element.isRequired,
};
static childContextTypes = {
store: PropTypes.object,
client: PropTypes.object.isRequired,
};
static contextTypes = {
store: PropTypes.object,
};
constructor(props, context) {
super(props, context);
console.warn(props);
invariant(
props.client,
'ApolloClient was not passed a client instance. Make ' +
'sure you pass in your client via the "client" prop.',
);
if (!props.store) {
props.client.initStore();
}
export default class ApolloProvider extends Component {
static propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
}),
client: PropTypes.object.isRequired,
immutable: PropTypes.bool,
children: PropTypes.element.isRequired,
};
static childContextTypes = {
store: PropTypes.object,
client: PropTypes.object.isRequired,
};
static contextTypes = {
store: PropTypes.object,
};
constructor(props, context) {
super(props, context);
console.warn(props);
invariant(
props.client,
'ApolloClient was not passed a client instance. Make ' +
'sure you pass in your client via the "client" prop.',
);
import invariant = require('invariant');
export declare interface ProviderProps {
store?: Store;
immutable?: boolean;
client: ApolloClient;
}
export default class ApolloProvider extends Component {
static propTypes = {
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
}),
client: PropTypes.object.isRequired,
immutable: PropTypes.bool,
children: PropTypes.element.isRequired,
};
static childContextTypes = {
store: PropTypes.object,
client: PropTypes.object.isRequired,
};
static contextTypes = {
store: PropTypes.object,
};
constructor(props, context) {
super(props, context);