1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | 'use strict';
|
13 |
|
14 | var preloadQuery = require('./preloadQuery_DEPRECATED');
|
15 |
|
16 | function prepareEntryPoint(environmentProvider, entryPoint, entryPointParams) {
|
17 |
|
18 | if (entryPoint.root.getModuleIfRequired() == null) {
|
19 | entryPoint.root.load();
|
20 | }
|
21 |
|
22 | var preloadProps = entryPoint.getPreloadProps(entryPointParams);
|
23 | var queries = preloadProps.queries,
|
24 | entryPoints = preloadProps.entryPoints;
|
25 | var preloadedQueries = {};
|
26 | var preloadedEntryPoints = {};
|
27 |
|
28 | if (queries != null) {
|
29 | var queriesPropNames = Object.keys(queries);
|
30 | queriesPropNames.forEach(function (queryPropName) {
|
31 | var _queries$queryPropNam = queries[queryPropName],
|
32 | environmentProviderOptions = _queries$queryPropNam.environmentProviderOptions,
|
33 | options = _queries$queryPropNam.options,
|
34 | parameters = _queries$queryPropNam.parameters,
|
35 | variables = _queries$queryPropNam.variables;
|
36 | var environment = environmentProvider.getEnvironment(environmentProviderOptions);
|
37 | preloadedQueries[queryPropName] = preloadQuery(environment, parameters, variables, options, environmentProviderOptions);
|
38 | });
|
39 | }
|
40 |
|
41 | if (entryPoints != null) {
|
42 | var entryPointPropNames = Object.keys(entryPoints);
|
43 | entryPointPropNames.forEach(function (entryPointPropName) {
|
44 | var entryPointDescription = entryPoints[entryPointPropName];
|
45 |
|
46 | if (entryPointDescription == null) {
|
47 | return;
|
48 | }
|
49 |
|
50 | var nestedEntryPoint = entryPointDescription.entryPoint,
|
51 | nestedParams = entryPointDescription.entryPointParams;
|
52 | preloadedEntryPoints[entryPointPropName] = prepareEntryPoint(environmentProvider, nestedEntryPoint, nestedParams);
|
53 | });
|
54 | }
|
55 | }
|
56 |
|
57 | module.exports = prepareEntryPoint; |
\ | No newline at end of file |