1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function relaySplitMatchTransform(context) {
|
17 | var splitOperations = new Map();
|
18 |
|
19 | var transformedContext = require("./GraphQLIRTransformer").transform(context, {
|
20 | MatchBranch: visitMatchBranch
|
21 | }, function () {
|
22 | return splitOperations;
|
23 | });
|
24 |
|
25 | return transformedContext.addAll(Array.from(splitOperations.values()));
|
26 | }
|
27 |
|
28 | function visitMatchBranch(node, state) {
|
29 | var transformedNode = this.traverse(node, state);
|
30 | var splitOperation = {
|
31 | kind: 'SplitOperation',
|
32 | name: require("./getNormalizationOperationName")(transformedNode.name),
|
33 | selections: transformedNode.selections,
|
34 | loc: {
|
35 | kind: 'Derived',
|
36 | source: node.loc
|
37 | },
|
38 | metadata: {
|
39 | derivedFrom: transformedNode.name
|
40 | },
|
41 | type: transformedNode.type
|
42 | };
|
43 | state.set(node.name, splitOperation);
|
44 | return transformedNode;
|
45 | }
|
46 |
|
47 | module.exports = {
|
48 | transform: relaySplitMatchTransform
|
49 | }; |
\ | No newline at end of file |