1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var tslib = require('tslib');
|
6 | var PropTypes = require('prop-types');
|
7 | var hooks = require('../hooks');
|
8 |
|
9 | function _interopNamespace(e) {
|
10 | if (e && e.__esModule) return e;
|
11 | var n = Object.create(null);
|
12 | if (e) {
|
13 | for (var k in e) {
|
14 | n[k] = e[k];
|
15 | }
|
16 | }
|
17 | n["default"] = e;
|
18 | return Object.freeze(n);
|
19 | }
|
20 |
|
21 | var PropTypes__namespace = _interopNamespace(PropTypes);
|
22 |
|
23 | function Query(props) {
|
24 | var children = props.children, query = props.query, options = tslib.__rest(props, ["children", "query"]);
|
25 | var result = hooks.useQuery(query, options);
|
26 | return result ? children(result) : null;
|
27 | }
|
28 | Query.propTypes = {
|
29 | client: PropTypes__namespace.object,
|
30 | children: PropTypes__namespace.func.isRequired,
|
31 | fetchPolicy: PropTypes__namespace.string,
|
32 | notifyOnNetworkStatusChange: PropTypes__namespace.bool,
|
33 | onCompleted: PropTypes__namespace.func,
|
34 | onError: PropTypes__namespace.func,
|
35 | pollInterval: PropTypes__namespace.number,
|
36 | query: PropTypes__namespace.object.isRequired,
|
37 | variables: PropTypes__namespace.object,
|
38 | ssr: PropTypes__namespace.bool,
|
39 | partialRefetch: PropTypes__namespace.bool,
|
40 | returnPartialData: PropTypes__namespace.bool
|
41 | };
|
42 |
|
43 | function Mutation(props) {
|
44 | var _a = hooks.useMutation(props.mutation, props), runMutation = _a[0], result = _a[1];
|
45 | return props.children ? props.children(runMutation, result) : null;
|
46 | }
|
47 | Mutation.propTypes = {
|
48 | mutation: PropTypes__namespace.object.isRequired,
|
49 | variables: PropTypes__namespace.object,
|
50 | optimisticResponse: PropTypes__namespace.oneOfType([PropTypes__namespace.object, PropTypes__namespace.func]),
|
51 | refetchQueries: PropTypes__namespace.oneOfType([
|
52 | PropTypes__namespace.arrayOf(PropTypes__namespace.oneOfType([PropTypes__namespace.string, PropTypes__namespace.object])),
|
53 | PropTypes__namespace.func
|
54 | ]),
|
55 | awaitRefetchQueries: PropTypes__namespace.bool,
|
56 | update: PropTypes__namespace.func,
|
57 | children: PropTypes__namespace.func.isRequired,
|
58 | onCompleted: PropTypes__namespace.func,
|
59 | onError: PropTypes__namespace.func,
|
60 | fetchPolicy: PropTypes__namespace.string,
|
61 | };
|
62 |
|
63 | function Subscription(props) {
|
64 | var result = hooks.useSubscription(props.subscription, props);
|
65 | return props.children && result ? props.children(result) : null;
|
66 | }
|
67 | Subscription.propTypes = {
|
68 | subscription: PropTypes__namespace.object.isRequired,
|
69 | variables: PropTypes__namespace.object,
|
70 | children: PropTypes__namespace.func,
|
71 | onSubscriptionData: PropTypes__namespace.func,
|
72 | onData: PropTypes__namespace.func,
|
73 | onSubscriptionComplete: PropTypes__namespace.func,
|
74 | onComplete: PropTypes__namespace.func,
|
75 | shouldResubscribe: PropTypes__namespace.oneOfType([PropTypes__namespace.func, PropTypes__namespace.bool])
|
76 | };
|
77 |
|
78 | exports.Mutation = Mutation;
|
79 | exports.Query = Query;
|
80 | exports.Subscription = Subscription;
|
81 |
|