UNPKG

1.32 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @emails oncall+relay
8 *
9 * @format
10 */
11// flowlint ambiguous-object-type:error
12'use strict';
13
14var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
15
16var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
17
18var _require = require('./loadQuery'),
19 useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
20
21function useLazyLoadQuery(gqlQuery, variables, options) {
22 // We need to use this hook in order to be able to track if
23 // loadQuery was called during render
24 useTrackLoadQueryInRender();
25 var query = useMemoOperationDescriptor(gqlQuery, variables);
26 var data = useLazyLoadQueryNode({
27 componentDisplayName: 'useLazyLoadQuery()',
28 fetchKey: options === null || options === void 0 ? void 0 : options.fetchKey,
29 fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30 networkCacheConfig: options === null || options === void 0 ? void 0 : options.networkCacheConfig,
31 query: query,
32 renderPolicy: options === null || options === void 0 ? void 0 : options.UNSTABLE_renderPolicy
33 });
34 return data;
35}
36
37module.exports = useLazyLoadQuery;
\No newline at end of file