1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function inlineFragmentsTransform(context) {
|
16 | return require("./GraphQLIRTransformer").transform(context, {
|
17 | Fragment: visitFragment,
|
18 | FragmentSpread: visitFragmentSpread
|
19 | });
|
20 | }
|
21 |
|
22 | function visitFragment(fragment) {
|
23 | return null;
|
24 | }
|
25 |
|
26 | function visitFragmentSpread(fragmentSpread) {
|
27 | !(fragmentSpread.args.length === 0) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'InlineFragmentsTransform: Cannot flatten fragment spread `%s` with ' + 'arguments. Use the `ApplyFragmentArgumentTransform` before flattening', fragmentSpread.name) : require("fbjs/lib/invariant")(false) : void 0;
|
28 | var fragment = this.getContext().getFragment(fragmentSpread.name);
|
29 | var result = {
|
30 | kind: 'InlineFragment',
|
31 | directives: fragmentSpread.directives,
|
32 | loc: {
|
33 | kind: 'Derived',
|
34 | source: fragmentSpread.loc
|
35 | },
|
36 | metadata: fragmentSpread.metadata,
|
37 | selections: fragment.selections,
|
38 | typeCondition: fragment.type
|
39 | };
|
40 | return this.traverse(result);
|
41 | }
|
42 |
|
43 | module.exports = {
|
44 | transform: inlineFragmentsTransform
|
45 | }; |
\ | No newline at end of file |