MCPcopy
hub / github.com/ardatan/graphql-tools / print

Function print

packages/relay-compiler/lib/core/IRPrinter.js:26–61  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

24 */
25
26function 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
63function printSelections(schema, node, indent, options) {
64 var selections = node.selections;

Calls 5

printDirectivesFunction · 0.85
printSelectionsFunction · 0.85
printArgumentDefinitionsFunction · 0.85
invariantFunction · 0.70

Tested by 5

cleanFunction · 0.68
importDocumentsFunction · 0.68
importSchemaFunction · 0.68
normalizeFunction · 0.68
testSchemaDirFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…