UNPKG

1.21 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 *
8 * @format
9 */
10// flowlint ambiguous-object-type:error
11'use strict';
12
13var invariant = require("fbjs/lib/invariant");
14
15/**
16 * Fail fast if the user supplies invalid fragments as input.
17 */
18function assertFragmentMap(componentName, fragmentSpec) {
19 !(fragmentSpec && typeof fragmentSpec === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not create Relay Container for `%s`. ' + 'Expected a set of GraphQL fragments, got `%s` instead.', componentName, fragmentSpec) : invariant(false) : void 0;
20
21 for (var key in fragmentSpec) {
22 if (fragmentSpec.hasOwnProperty(key)) {
23 var fragment = fragmentSpec[key];
24 !(fragment && (typeof fragment === 'object' || typeof fragment === 'function')) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not create Relay Container for `%s`. ' + 'The value of fragment `%s` was expected to be a fragment, got `%s` instead.', componentName, key, fragment) : invariant(false) : void 0;
25 }
26 }
27}
28
29module.exports = assertFragmentMap;
\No newline at end of file