1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | function filterContextForNode(node, context) {
|
17 | var queue = [node];
|
18 | var filteredContext = new (require("./GraphQLCompilerContext"))(context.serverSchema, context.clientSchema).add(node);
|
19 |
|
20 | var visitFragmentSpread = function visitFragmentSpread(fragmentSpread) {
|
21 | var name = fragmentSpread.name;
|
22 |
|
23 | if (!filteredContext.get(name)) {
|
24 | var fragment = context.getFragment(name);
|
25 | filteredContext = filteredContext.add(fragment);
|
26 | queue.push(fragment);
|
27 | }
|
28 | };
|
29 |
|
30 | var visitorConfig = {
|
31 | FragmentSpread: function FragmentSpread(fragmentSpread) {
|
32 | visitFragmentSpread(fragmentSpread);
|
33 | }
|
34 | };
|
35 |
|
36 | while (queue.length) {
|
37 | require("./GraphQLIRVisitor").visit(queue.pop(), visitorConfig);
|
38 | }
|
39 |
|
40 | return filteredContext;
|
41 | }
|
42 |
|
43 | module.exports = filterContextForNode; |
\ | No newline at end of file |