Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 27x 27x 27x 27x 27x 27x 213x 213x 213x 212x 183x 27x 220x 27x 223x 27x | import * as React from 'react'; import * as PropTypes from 'prop-types'; import { Component } from 'react'; import ApolloClient from 'apollo-client'; import { DocumentNode } from 'graphql'; const invariant = require('invariant'); export interface ApolloProviderProps<TCache> { client: ApolloClient<TCache>; children: React.ReactNode; } export default class ApolloProvider<TCache> extends Component<ApolloProviderProps<TCache>> { static propTypes = { client: PropTypes.object.isRequired, children: PropTypes.node.isRequired, }; static childContextTypes = { client: PropTypes.object.isRequired, operations: PropTypes.object, }; private operations: Map<string, { query: DocumentNode; variables: any }> = new Map(); constructor(props: ApolloProviderProps<TCache>, context: any) { super(props, context); invariant( props.client, 'ApolloClient was not passed a client instance. Make ' + 'sure you pass in your client via the "client" prop.', ); // we have to attach to the client since you could have multiple // providers // XXX this is backwards compat and will be removed in 3.0 if (!(props.client as any).__operations_cache__) { (props.client as any).__operations_cache__ = this.operations; } } getChildContext() { return { client: this.props.client, operations: (this.props.client as any).__operations_cache__, }; } render() { return this.props.children; } } |