* Converts an IR node into a GraphQL string. Custom Relay * extensions (directives) are not supported; to print fragments with * variables or fragment spreads with arguments, transform the node * prior to printing.
(schema, node)
| 24 | */ |
| 25 | |
| 26 | function print(schema, node) { |
| 27 | switch (node.kind) { |
| 28 | case 'Fragment': |
| 29 | return ( |
| 30 | 'fragment '.concat(node.name, ' on ').concat(schema.getTypeString(node.type)) + |
| 31 | printFragmentArgumentDefinitions(schema, node.argumentDefinitions) + |
| 32 | printDirectives(schema, node.directives) + |
| 33 | printSelections(schema, node, '', {}) + |
| 34 | '\n' |
| 35 | ); |
| 36 | |
| 37 | case 'Root': |
| 38 | return ( |
| 39 | ''.concat(node.operation, ' ').concat(node.name) + |
| 40 | printArgumentDefinitions(schema, node.argumentDefinitions) + |
| 41 | printDirectives(schema, node.directives) + |
| 42 | printSelections(schema, node, '', {}) + |
| 43 | '\n' |
| 44 | ); |
| 45 | |
| 46 | case 'SplitOperation': |
| 47 | return ( |
| 48 | 'SplitOperation '.concat(node.name, ' on ').concat(schema.getTypeString(node.type)) + |
| 49 | printSelections(schema, node, '', {}) + |
| 50 | '\n' |
| 51 | ); |
| 52 | |
| 53 | default: |
| 54 | node; |
| 55 | !false |
| 56 | ? process.env.NODE_ENV !== 'production' |
| 57 | ? invariant(false, 'IRPrinter: Unsupported IR node `%s`.', node.kind) |
| 58 | : invariant(false) |
| 59 | : void 0; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | function printSelections(schema, node, indent, options) { |
| 64 | var selections = node.selections; |
searching dependent graphs…