@contember/graphql-builder 1.3.0-alpha.4 → 1.3.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/GraphQlQueryPrinter.cjs +18 -5
- package/dist/development/GraphQlQueryPrinter.cjs.map +1 -1
- package/dist/development/GraphQlQueryPrinter.js +18 -5
- package/dist/development/GraphQlQueryPrinter.js.map +1 -1
- package/dist/production/GraphQlQueryPrinter.cjs +18 -5
- package/dist/production/GraphQlQueryPrinter.cjs.map +1 -1
- package/dist/production/GraphQlQueryPrinter.js +18 -5
- package/dist/production/GraphQlQueryPrinter.js.map +1 -1
- package/dist/types/GraphQlQueryPrinter.d.ts +2 -0
- package/dist/types/GraphQlQueryPrinter.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/GraphQlQueryPrinter.ts +20 -5
|
@@ -14,6 +14,7 @@ class GraphQlQueryPrinter {
|
|
|
14
14
|
__publicField(this, "indentString", " ");
|
|
15
15
|
__publicField(this, "variableCounter", 0);
|
|
16
16
|
__publicField(this, "variables", {});
|
|
17
|
+
__publicField(this, "variableValueToName", {});
|
|
17
18
|
__publicField(this, "usedFragments", /* @__PURE__ */ new Set());
|
|
18
19
|
__publicField(this, "body", "");
|
|
19
20
|
}
|
|
@@ -93,17 +94,13 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
93
94
|
if (arg.value === void 0) {
|
|
94
95
|
continue;
|
|
95
96
|
}
|
|
96
|
-
const variableName =
|
|
97
|
+
const variableName = this.resolveVariableName(arg.graphQlType, arg.value);
|
|
97
98
|
if (i++ === 0) {
|
|
98
99
|
this.body += "(";
|
|
99
100
|
} else {
|
|
100
101
|
this.body += ", ";
|
|
101
102
|
}
|
|
102
103
|
this.body += `${argName}: $${variableName}`;
|
|
103
|
-
this.variables[variableName] = {
|
|
104
|
-
type: arg.graphQlType,
|
|
105
|
-
value: arg.value
|
|
106
|
-
};
|
|
107
104
|
}
|
|
108
105
|
if (i > 0) {
|
|
109
106
|
this.body += ")";
|
|
@@ -115,6 +112,22 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
115
112
|
}
|
|
116
113
|
this.body += "\n";
|
|
117
114
|
}
|
|
115
|
+
resolveVariableName(graphQlType, value) {
|
|
116
|
+
const variableName = this.variableValueToName[graphQlType]?.get(value);
|
|
117
|
+
if (variableName) {
|
|
118
|
+
return variableName;
|
|
119
|
+
}
|
|
120
|
+
const newVariableName = `${graphQlType.replace(/[\W]/g, "")}_${this.variableCounter++}`;
|
|
121
|
+
this.variables[newVariableName] = {
|
|
122
|
+
type: graphQlType,
|
|
123
|
+
value
|
|
124
|
+
};
|
|
125
|
+
if (!this.variableValueToName[graphQlType]) {
|
|
126
|
+
this.variableValueToName[graphQlType] = /* @__PURE__ */ new Map();
|
|
127
|
+
}
|
|
128
|
+
this.variableValueToName[graphQlType].set(value, newVariableName);
|
|
129
|
+
return newVariableName;
|
|
130
|
+
}
|
|
118
131
|
cleanState() {
|
|
119
132
|
this.body = "";
|
|
120
133
|
this.variableCounter = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlQueryPrinter.cjs","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName =
|
|
1
|
+
{"version":3,"file":"GraphQlQueryPrinter.cjs","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate variableValueToName: Record<string, Map<JSONValue, string>> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName = this.resolveVariableName(arg.graphQlType, arg.value)\n\t\t\tif (i++ === 0) {\n\t\t\t\tthis.body += '('\n\t\t\t} else {\n\t\t\t\tthis.body += ', '\n\t\t\t}\n\t\t\tthis.body += `${argName}: $${variableName}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tthis.body += ')'\n\t\t}\n\t\tif (field.selectionSet) {\n\t\t\tthis.body += ' {\\n'\n\t\t\tthis.processSelectionSet(field.selectionSet, indent + 1)\n\t\t\tthis.body += this.indentString.repeat(indent) + '}'\n\t\t}\n\t\tthis.body += '\\n'\n\t}\n\n\tprivate resolveVariableName(graphQlType: string, value: JSONValue): string {\n\t\tconst variableName = this.variableValueToName[graphQlType]?.get(value)\n\t\tif (variableName) {\n\t\t\treturn variableName\n\t\t}\n\t\tconst newVariableName = `${graphQlType.replace(/[\\W]/g, '')}_${this.variableCounter++}`\n\t\tthis.variables[newVariableName] = {\n\t\t\ttype: graphQlType,\n\t\t\tvalue: value,\n\t\t}\n\t\tif (!this.variableValueToName[graphQlType]) {\n\t\t\tthis.variableValueToName[graphQlType] = new Map()\n\t\t}\n\t\tthis.variableValueToName[graphQlType].set(value, newVariableName)\n\t\treturn newVariableName\n\t}\n\n\tprivate cleanState(): void {\n\t\tthis.body = ''\n\t\tthis.variableCounter = 0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AAK,QAAQ;AAAA,MAAA,OACP;AACN,aAAK,QAAQ;AAAA,MACd;AACK,WAAA,QAAQ,GAAG,aAAa;AAAA,IAC9B;AACA,QAAI,IAAI,GAAG;AACV,WAAK,QAAQ;AAAA,IACd;AACA,QAAI,MAAM,cAAc;AACvB,WAAK,QAAQ;AACb,WAAK,oBAAoB,MAAM,cAAc,SAAS,CAAC;AACvD,WAAK,QAAQ,KAAK,aAAa,OAAO,MAAM,IAAI;AAAA,IACjD;AACA,SAAK,QAAQ;AAAA,EACd;AAAA,EAEQ,oBAAoB,aAAqB,OAA0B;AAC1E,UAAM,eAAe,KAAK,oBAAoB,WAAW,GAAG,IAAI,KAAK;AACrE,QAAI,cAAc;AACV,aAAA;AAAA,IACR;AACA,UAAM,kBAAkB,GAAG,YAAY,QAAQ,SAAS,EAAE,KAAK,KAAK;AAC/D,SAAA,UAAU,eAAe,IAAI;AAAA,MACjC,MAAM;AAAA,MACN;AAAA,IAAA;AAED,QAAI,CAAC,KAAK,oBAAoB,WAAW,GAAG;AAC3C,WAAK,oBAAoB,WAAW,IAAI,oBAAI,IAAI;AAAA,IACjD;AACA,SAAK,oBAAoB,WAAW,EAAE,IAAI,OAAO,eAAe;AACzD,WAAA;AAAA,EACR;AAAA,EAEQ,aAAmB;AAC1B,SAAK,OAAO;AACZ,SAAK,kBAAkB;AACvB,SAAK,YAAY;AACZ,SAAA,oCAAoB;EAC1B;AACD;;"}
|
|
@@ -12,6 +12,7 @@ class GraphQlQueryPrinter {
|
|
|
12
12
|
__publicField(this, "indentString", " ");
|
|
13
13
|
__publicField(this, "variableCounter", 0);
|
|
14
14
|
__publicField(this, "variables", {});
|
|
15
|
+
__publicField(this, "variableValueToName", {});
|
|
15
16
|
__publicField(this, "usedFragments", /* @__PURE__ */ new Set());
|
|
16
17
|
__publicField(this, "body", "");
|
|
17
18
|
}
|
|
@@ -91,17 +92,13 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
91
92
|
if (arg.value === void 0) {
|
|
92
93
|
continue;
|
|
93
94
|
}
|
|
94
|
-
const variableName =
|
|
95
|
+
const variableName = this.resolveVariableName(arg.graphQlType, arg.value);
|
|
95
96
|
if (i++ === 0) {
|
|
96
97
|
this.body += "(";
|
|
97
98
|
} else {
|
|
98
99
|
this.body += ", ";
|
|
99
100
|
}
|
|
100
101
|
this.body += `${argName}: $${variableName}`;
|
|
101
|
-
this.variables[variableName] = {
|
|
102
|
-
type: arg.graphQlType,
|
|
103
|
-
value: arg.value
|
|
104
|
-
};
|
|
105
102
|
}
|
|
106
103
|
if (i > 0) {
|
|
107
104
|
this.body += ")";
|
|
@@ -113,6 +110,22 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
113
110
|
}
|
|
114
111
|
this.body += "\n";
|
|
115
112
|
}
|
|
113
|
+
resolveVariableName(graphQlType, value) {
|
|
114
|
+
const variableName = this.variableValueToName[graphQlType]?.get(value);
|
|
115
|
+
if (variableName) {
|
|
116
|
+
return variableName;
|
|
117
|
+
}
|
|
118
|
+
const newVariableName = `${graphQlType.replace(/[\W]/g, "")}_${this.variableCounter++}`;
|
|
119
|
+
this.variables[newVariableName] = {
|
|
120
|
+
type: graphQlType,
|
|
121
|
+
value
|
|
122
|
+
};
|
|
123
|
+
if (!this.variableValueToName[graphQlType]) {
|
|
124
|
+
this.variableValueToName[graphQlType] = /* @__PURE__ */ new Map();
|
|
125
|
+
}
|
|
126
|
+
this.variableValueToName[graphQlType].set(value, newVariableName);
|
|
127
|
+
return newVariableName;
|
|
128
|
+
}
|
|
116
129
|
cleanState() {
|
|
117
130
|
this.body = "";
|
|
118
131
|
this.variableCounter = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlQueryPrinter.js","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName =
|
|
1
|
+
{"version":3,"file":"GraphQlQueryPrinter.js","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate variableValueToName: Record<string, Map<JSONValue, string>> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName = this.resolveVariableName(arg.graphQlType, arg.value)\n\t\t\tif (i++ === 0) {\n\t\t\t\tthis.body += '('\n\t\t\t} else {\n\t\t\t\tthis.body += ', '\n\t\t\t}\n\t\t\tthis.body += `${argName}: $${variableName}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tthis.body += ')'\n\t\t}\n\t\tif (field.selectionSet) {\n\t\t\tthis.body += ' {\\n'\n\t\t\tthis.processSelectionSet(field.selectionSet, indent + 1)\n\t\t\tthis.body += this.indentString.repeat(indent) + '}'\n\t\t}\n\t\tthis.body += '\\n'\n\t}\n\n\tprivate resolveVariableName(graphQlType: string, value: JSONValue): string {\n\t\tconst variableName = this.variableValueToName[graphQlType]?.get(value)\n\t\tif (variableName) {\n\t\t\treturn variableName\n\t\t}\n\t\tconst newVariableName = `${graphQlType.replace(/[\\W]/g, '')}_${this.variableCounter++}`\n\t\tthis.variables[newVariableName] = {\n\t\t\ttype: graphQlType,\n\t\t\tvalue: value,\n\t\t}\n\t\tif (!this.variableValueToName[graphQlType]) {\n\t\t\tthis.variableValueToName[graphQlType] = new Map()\n\t\t}\n\t\tthis.variableValueToName[graphQlType].set(value, newVariableName)\n\t\treturn newVariableName\n\t}\n\n\tprivate cleanState(): void {\n\t\tthis.body = ''\n\t\tthis.variableCounter = 0\n\t\tthis.variables = {}\n\t\tthis.usedFragments = new Set<string>()\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,MAAM,oBAAoB;AAAA,EAA1B;AACE,wCAAe;AAEf,2CAAkB;AAClB,qCAGH,CAAA;AAEG,+CAA8D,CAAA;AAE9D,6DAAoB;AAEpB,gCAAO;AAAA;AAAA,EAGR,cACN,WACA,QACA,WACqB;AACrB,SAAK,WAAW;AACX,SAAA,oBAAoB,QAAQ,CAAC;AAClC,UAAM,OAAO,KAAK;AAClB,SAAK,OAAO;AACZ,SAAK,qBAAqB,SAAS;AACnC,UAAM,eAAe,KAAK;AACpB,UAAA,kBAAkB,KAAK;AACvB,UAAA,QAAQ,GAAG,YAAY;AAAA,EAAsB,QAAQ;AAAA;AACpD,WAAA;AAAA,MACN;AAAA,MACA,WAAW,OAAO,YAAY,OAAO,QAAQ,KAAK,SAAS,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA,IAAA;AAAA,EAExG;AAAA,EAGQ,qBAAqB,WAAkD;AACxE,UAAA,8BAAc;AACb,WAAA,KAAK,cAAc,OAAO,GAAG;AACnC,YAAM,eAAe,KAAK,cAAc,OAAO,EAAE,KAAO,EAAA;AACnD,WAAA,cAAc,OAAO,YAAY;AAClC,UAAA,QAAQ,IAAI,YAAY,GAAG;AAC9B;AAAA,MACD;AACA,cAAQ,IAAI,YAAY;AACpB,UAAA,CAAC,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
__publicField(this, "variableCounter", 0);
|
|
16
16
|
__publicField(this, "variables", {});
|
|
17
|
+
__publicField(this, "variableValueToName", {});
|
|
17
18
|
__publicField(this, "usedFragments", /* @__PURE__ */ new Set());
|
|
18
19
|
__publicField(this, "body", "");
|
|
19
20
|
}
|
|
@@ -93,17 +94,13 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
93
94
|
if (arg.value === void 0) {
|
|
94
95
|
continue;
|
|
95
96
|
}
|
|
96
|
-
const variableName =
|
|
97
|
+
const variableName = this.resolveVariableName(arg.graphQlType, arg.value);
|
|
97
98
|
if (i++ === 0) {
|
|
98
99
|
this.body += "(";
|
|
99
100
|
} else {
|
|
100
101
|
this.body += ", ";
|
|
101
102
|
}
|
|
102
103
|
this.body += `${argName}: $${variableName}`;
|
|
103
|
-
this.variables[variableName] = {
|
|
104
|
-
type: arg.graphQlType,
|
|
105
|
-
value: arg.value
|
|
106
|
-
};
|
|
107
104
|
}
|
|
108
105
|
if (i > 0) {
|
|
109
106
|
this.body += ")";
|
|
@@ -115,6 +112,22 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
115
112
|
}
|
|
116
113
|
this.body += "\n";
|
|
117
114
|
}
|
|
115
|
+
resolveVariableName(graphQlType, value) {
|
|
116
|
+
const variableName = this.variableValueToName[graphQlType]?.get(value);
|
|
117
|
+
if (variableName) {
|
|
118
|
+
return variableName;
|
|
119
|
+
}
|
|
120
|
+
const newVariableName = `${graphQlType.replace(/[\W]/g, "")}_${this.variableCounter++}`;
|
|
121
|
+
this.variables[newVariableName] = {
|
|
122
|
+
type: graphQlType,
|
|
123
|
+
value
|
|
124
|
+
};
|
|
125
|
+
if (!this.variableValueToName[graphQlType]) {
|
|
126
|
+
this.variableValueToName[graphQlType] = /* @__PURE__ */ new Map();
|
|
127
|
+
}
|
|
128
|
+
this.variableValueToName[graphQlType].set(value, newVariableName);
|
|
129
|
+
return newVariableName;
|
|
130
|
+
}
|
|
118
131
|
cleanState() {
|
|
119
132
|
this.body = "";
|
|
120
133
|
this.variableCounter = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlQueryPrinter.cjs","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName =
|
|
1
|
+
{"version":3,"file":"GraphQlQueryPrinter.cjs","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate variableValueToName: Record<string, Map<JSONValue, string>> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName = this.resolveVariableName(arg.graphQlType, arg.value)\n\t\t\tif (i++ === 0) {\n\t\t\t\tthis.body += '('\n\t\t\t} else {\n\t\t\t\tthis.body += ', '\n\t\t\t}\n\t\t\tthis.body += `${argName}: $${variableName}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tthis.body += ')'\n\t\t}\n\t\tif (field.selectionSet) {\n\t\t\tthis.body += ' {\\n'\n\t\t\tthis.processSelectionSet(field.selectionSet, indent + 1)\n\t\t\tthis.body += this.indentString.repeat(indent) + '}'\n\t\t}\n\t\tthis.body += '\\n'\n\t}\n\n\tprivate resolveVariableName(graphQlType: string, value: JSONValue): string {\n\t\tconst variableName = this.variableValueToName[graphQlType]?.get(value)\n\t\tif (variableName) {\n\t\t\treturn variableName\n\t\t}\n\t\tconst newVariableName = `${graphQlType.replace(/[\\W]/g, '')}_${this.variableCounter++}`\n\t\tthis.variables[newVariableName] = {\n\t\t\ttype: graphQlType,\n\t\t\tvalue: value,\n\t\t}\n\t\tif (!this.variableValueToName[graphQlType]) {\n\t\t\tthis.variableValueToName[graphQlType] = new Map()\n\t\t}\n\t\tthis.variableValueToName[graphQlType].set(value, newVariableName)\n\t\treturn newVariableName\n\t}\n\n\tprivate cleanState(): void {\n\t\tthis.body = ''\n\t\tthis.variableCounter = 0\n\t\tthis.variables = {}\n\t\tthis.usedFragments = new Set<string>()\n\t}\n}\n"],"names":["GraphQlField","GraphQlFragmentSpread","GraphQlInlineFragment"],"mappings":";;;;;;;;;;;AAKO,MAAM,oBAAoB;AAAA,EAA1B;AACE,wCAAe;AAEf,2CAAkB;AAClB,qCAGH,CAAA;AAEG,+CAA8D,CAAA;AAE9D,6DAAoB;AAEpB,gCAAO;AAAA;AAAA,EAGR,cACN,WACA,QACA,WACqB;AACrB,SAAK,WAAW;AACX,SAAA,oBAAoB,QAAQ,CAAC;AAClC,UAAM,OAAO,KAAK;AAClB,SAAK,OAAO;AACZ,SAAK,qBAAqB,SAAS;AACnC,UAAM,eAAe,KAAK;AACpB,UAAA,kBAAkB,KAAK;AACvB,UAAA,QAAQ,GAAG,YAAY;AAAA,EAAsB,QAAQ;AAAA;AACpD,WAAA;AAAA,MACN;AAAA,MACA,WAAW,OAAO,YAAY,OAAO,QAAQ,KAAK,SAAS,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,MAAM,KA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AoB,WAAW,IAAI,oBAAI,IAAI;AAAA,IACjD;AACA,SAAK,oBAAoB,WAAW,EAAE,IAAI,OAAO,eAAe;AACzD,WAAA;AAAA,EACR;AAAA,EAEQ,aAAmB;AAC1B,SAAK,OAAO;AACZ,SAAK,kBAAkB;AACvB,SAAK,YAAY;AACZ,SAAA,oCAAoB;EAC1B;AACD;;"}
|
|
@@ -12,6 +12,7 @@ class GraphQlQueryPrinter {
|
|
|
12
12
|
__publicField(this, "indentString", " ");
|
|
13
13
|
__publicField(this, "variableCounter", 0);
|
|
14
14
|
__publicField(this, "variables", {});
|
|
15
|
+
__publicField(this, "variableValueToName", {});
|
|
15
16
|
__publicField(this, "usedFragments", /* @__PURE__ */ new Set());
|
|
16
17
|
__publicField(this, "body", "");
|
|
17
18
|
}
|
|
@@ -91,17 +92,13 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
91
92
|
if (arg.value === void 0) {
|
|
92
93
|
continue;
|
|
93
94
|
}
|
|
94
|
-
const variableName =
|
|
95
|
+
const variableName = this.resolveVariableName(arg.graphQlType, arg.value);
|
|
95
96
|
if (i++ === 0) {
|
|
96
97
|
this.body += "(";
|
|
97
98
|
} else {
|
|
98
99
|
this.body += ", ";
|
|
99
100
|
}
|
|
100
101
|
this.body += `${argName}: $${variableName}`;
|
|
101
|
-
this.variables[variableName] = {
|
|
102
|
-
type: arg.graphQlType,
|
|
103
|
-
value: arg.value
|
|
104
|
-
};
|
|
105
102
|
}
|
|
106
103
|
if (i > 0) {
|
|
107
104
|
this.body += ")";
|
|
@@ -113,6 +110,22 @@ fragment ${fragment.name} on ${fragment.type} {
|
|
|
113
110
|
}
|
|
114
111
|
this.body += "\n";
|
|
115
112
|
}
|
|
113
|
+
resolveVariableName(graphQlType, value) {
|
|
114
|
+
const variableName = this.variableValueToName[graphQlType]?.get(value);
|
|
115
|
+
if (variableName) {
|
|
116
|
+
return variableName;
|
|
117
|
+
}
|
|
118
|
+
const newVariableName = `${graphQlType.replace(/[\W]/g, "")}_${this.variableCounter++}`;
|
|
119
|
+
this.variables[newVariableName] = {
|
|
120
|
+
type: graphQlType,
|
|
121
|
+
value
|
|
122
|
+
};
|
|
123
|
+
if (!this.variableValueToName[graphQlType]) {
|
|
124
|
+
this.variableValueToName[graphQlType] = /* @__PURE__ */ new Map();
|
|
125
|
+
}
|
|
126
|
+
this.variableValueToName[graphQlType].set(value, newVariableName);
|
|
127
|
+
return newVariableName;
|
|
128
|
+
}
|
|
116
129
|
cleanState() {
|
|
117
130
|
this.body = "";
|
|
118
131
|
this.variableCounter = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlQueryPrinter.js","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName =
|
|
1
|
+
{"version":3,"file":"GraphQlQueryPrinter.js","sources":["../../src/GraphQlQueryPrinter.ts"],"sourcesContent":["import { JSONValue } from '@contember/schema'\nimport { GraphQlField, GraphQlFragment, GraphQlFragmentSpread, GraphQlInlineFragment, GraphQlSelectionSet } from './nodes'\n\nexport type GraphQlPrintResult = { query: string; variables: Record<string, JSONValue> }\n\nexport class GraphQlQueryPrinter {\n\tprivate indentString = '\\t'\n\n\tprivate variableCounter = 0\n\tprivate variables: Record<string, {\n\t\ttype: string\n\t\tvalue: JSONValue\n\t}> = {}\n\n\tprivate variableValueToName: Record<string, Map<JSONValue, string>> = {}\n\n\tprivate usedFragments = new Set<string>()\n\n\tprivate body = ''\n\n\n\tpublic printDocument(\n\t\toperation: 'query' | 'mutation',\n\t\tselect: GraphQlSelectionSet,\n\t\tfragments: Record<string, GraphQlFragment>,\n\t): GraphQlPrintResult {\n\t\tthis.cleanState()\n\t\tthis.processSelectionSet(select, 1)\n\t\tconst body = this.body\n\t\tthis.body = ''\n\t\tthis.processUsedFragments(fragments)\n\t\tconst fragmentsStr = this.body\n\t\tconst variablesString = this.printVariables()\n\t\tconst query = `${operation}${variablesString} {\\n${body}}${fragmentsStr}\\n`\n\t\treturn {\n\t\t\tquery: query,\n\t\t\tvariables: Object.fromEntries(Object.entries(this.variables).map(([key, value]) => [key, value.value])),\n\t\t}\n\t}\n\n\n\tprivate processUsedFragments(fragments: Record<string, GraphQlFragment>): void {\n\t\tconst printed = new Set()\n\t\twhile (this.usedFragments.size > 0) {\n\t\t\tconst fragmentName = this.usedFragments.values().next().value\n\t\t\tthis.usedFragments.delete(fragmentName)\n\t\t\tif (printed.has(fragmentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprinted.add(fragmentName)\n\t\t\tif (!fragments[fragmentName]) {\n\t\t\t\tthrow new Error(`Unknown fragment ${fragmentName}`)\n\t\t\t}\n\t\t\tthis.processFragment(fragments[fragmentName])\n\t\t}\n\t}\n\n\tprivate processFragment(fragment: GraphQlFragment): void {\n\t\tthis.body += `\\nfragment ${fragment.name} on ${fragment.type} {\\n`\n\t\tthis.processSelectionSet(fragment.selectionSet, 1)\n\t\tthis.body += '}'\n\t}\n\n\tprivate printVariables(): string {\n\t\tlet variablesString = ''\n\t\tlet i = 0\n\t\tfor (const [variableName, variable] of Object.entries(this.variables)) {\n\t\t\tif (i++ === 0) {\n\t\t\t\tvariablesString += '('\n\t\t\t} else {\n\t\t\t\tvariablesString += ', '\n\t\t\t}\n\t\t\tvariablesString += `$${variableName}: ${variable.type}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tvariablesString += ')'\n\t\t}\n\t\treturn variablesString\n\t}\n\n\tprivate processSelectionSet(selectionSet: GraphQlSelectionSet, indent: number): void {\n\t\tfor (const node of selectionSet) {\n\t\t\tif (node instanceof GraphQlField) {\n\t\t\t\tthis.processField(node, indent)\n\t\t\t} else if (node instanceof GraphQlFragmentSpread) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... ' + node.name + '\\n'\n\t\t\t\tthis.usedFragments.add(node.name)\n\t\t\t} else if (node instanceof GraphQlInlineFragment) {\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '... on ' + node.type + ' {\\n'\n\t\t\t\tthis.processSelectionSet(node.selectionSet, indent + 1)\n\t\t\t\tthis.body += this.indentString.repeat(indent) + '}\\n'\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processField(field: GraphQlField, indent: number): void {\n\t\tconst indentString = this.indentString.repeat(indent)\n\t\tthis.body += indentString + (field.alias && field.alias !== field.name ? (field.alias + ': ' + field.name) : field.name)\n\t\tlet i = 0\n\t\tfor (const [argName, arg] of Object.entries(field.args)) {\n\t\t\tif (arg.value === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst variableName = this.resolveVariableName(arg.graphQlType, arg.value)\n\t\t\tif (i++ === 0) {\n\t\t\t\tthis.body += '('\n\t\t\t} else {\n\t\t\t\tthis.body += ', '\n\t\t\t}\n\t\t\tthis.body += `${argName}: $${variableName}`\n\t\t}\n\t\tif (i > 0) {\n\t\t\tthis.body += ')'\n\t\t}\n\t\tif (field.selectionSet) {\n\t\t\tthis.body += ' {\\n'\n\t\t\tthis.processSelectionSet(field.selectionSet, indent + 1)\n\t\t\tthis.body += this.indentString.repeat(indent) + '}'\n\t\t}\n\t\tthis.body += '\\n'\n\t}\n\n\tprivate resolveVariableName(graphQlType: string, value: JSONValue): string {\n\t\tconst variableName = this.variableValueToName[graphQlType]?.get(value)\n\t\tif (variableName) {\n\t\t\treturn variableName\n\t\t}\n\t\tconst newVariableName = `${graphQlType.replace(/[\\W]/g, '')}_${this.variableCounter++}`\n\t\tthis.variables[newVariableName] = {\n\t\t\ttype: graphQlType,\n\t\t\tvalue: value,\n\t\t}\n\t\tif (!this.variableValueToName[graphQlType]) {\n\t\t\tthis.variableValueToName[graphQlType] = new Map()\n\t\t}\n\t\tthis.variableValueToName[graphQlType].set(value, newVariableName)\n\t\treturn newVariableName\n\t}\n\n\tprivate cleanState(): void {\n\t\tthis.body = ''\n\t\tthis.variableCounter = 0\n\t\tthis.variables = {}\n\t\tthis.usedFragments = new Set<string>()\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,MAAM,oBAAoB;AAAA,EAA1B;AACE,wCAAe;AAEf,2CAAkB;AAClB,qCAGH,CAAA;AAEG,+CAA8D,CAAA;AAE9D,6DAAoB;AAEpB,gCAAO;AAAA;AAAA,EAGR,cACN,WACA,QACA,WACqB;AACrB,SAAK,WAAW;AACX,SAAA,oBAAoB,QAAQ,CAAC;AAClC,UAAM,OAAO,KAAK;AAClB,SAAK,OAAO;AACZ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,WAAW,GAAG,IAAI,KAAK;AACrE,QAAI,cAAc;AACV,aAAA;AAAA,IACR;AACA,UAAM,kBAAkB,GAAG,YAAY,QAAQ,SAAS,EAAE,KAAK,KAAK;AAC/D,SAAA,UAAU,eAAe,IAAI;AAAA,MACjC,MAAM;AAAA,MACN;AAAA,IAAA;AAED,QAAI,CAAC,KAAK,oBAAoB,WAAW,GAAG;AAC3C,WAAK,oBAAoB,WAAW,IAAI,oBAAI,IAAI;AAAA,IACjD;AACA,SAAK,oBAAoB,WAAW,EAAE,IAAI,OAAO,eAAe;AACzD,WAAA;AAAA,EACR;AAAA,EAEQ,aAAmB;AAC1B,SAAK,OAAO;AACZ,SAAK,kBAAkB;AACvB,SAAK,YAAY;AACZ,SAAA,oCAAoB;EAC1B;AACD;"}
|
|
@@ -8,6 +8,7 @@ export declare class GraphQlQueryPrinter {
|
|
|
8
8
|
private indentString;
|
|
9
9
|
private variableCounter;
|
|
10
10
|
private variables;
|
|
11
|
+
private variableValueToName;
|
|
11
12
|
private usedFragments;
|
|
12
13
|
private body;
|
|
13
14
|
printDocument(operation: 'query' | 'mutation', select: GraphQlSelectionSet, fragments: Record<string, GraphQlFragment>): GraphQlPrintResult;
|
|
@@ -16,6 +17,7 @@ export declare class GraphQlQueryPrinter {
|
|
|
16
17
|
private printVariables;
|
|
17
18
|
private processSelectionSet;
|
|
18
19
|
private processField;
|
|
20
|
+
private resolveVariableName;
|
|
19
21
|
private cleanState;
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=GraphQlQueryPrinter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlQueryPrinter.d.ts","sourceRoot":"","sources":["../../src/GraphQlQueryPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAgB,eAAe,EAAgD,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE1H,MAAM,MAAM,kBAAkB,G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CAAC,MAAM,EAAE,eAAe,CAAC,GACxC,kBAAkB;IAgBrB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,YAAY;IA2BpB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,UAAU;CAMlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../../node_modules/typescript/lib/lib.es2023.d.ts","../../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/@types/react/ts5.0/global.d.ts","../../../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../../../node_modules/@types/prop-types/index.d.ts","../../../../node_modules/@types/scheduler/tracing.d.ts","../../../../node_modules/@types/react/ts5.0/index.d.ts","../../../../node_modules/@types/react/ts5.0/jsx-runtime.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/value.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/input.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/json.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/acl.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/actions.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/model.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/result.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/validation.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/settings.d.ts","../../../../node_modules/@contember/schema/dist/src/ProjectRole.d.ts","../../../../node_modules/@contember/schema/dist/src/index.d.ts","../../src/nodes/GraphQlFragmentSpread.ts","../../src/nodes/GraphQlInlineFragment.ts","../../src/nodes/GraphQlField.ts","../../src/nodes/GraphQlFragment.ts","../../src/nodes/index.ts","../../src/GraphQlQueryPrinter.ts","../../src/index.ts","../../../../node_modules/vite/types/hmrPayload.d.ts","../../../../node_modules/vite/types/customEvent.d.ts","../../../../node_modules/vite/types/hot.d.ts","../../../../node_modules/vite/types/importGlob.d.ts","../../../../node_modules/vite/types/importMeta.d.ts","../../../../node_modules/vite/client.d.ts"],"fileInfos":[{"version":"6a6b471e7e43e15ef6f8fe617a22ce4ecb0e34efa6c3dfcfe7cebd392bcca9d2","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec",{"version":"fcd3ecc9f764f06f4d5c467677f4f117f6abf49dee6716283aa204ff1162498b","affectsGlobalScope":true},{"version":"9a60b92bca4c1257db03b349d58e63e4868cfc0d1c8d0ba60c2dbc63f4e6c9f6","affectsGlobalScope":true},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"5114a95689b63f96b957e00216bc04baf9e1a1782aa4d8ee7e5e9acbf768e301","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"b7feb7967c6c6003e11f49efa8f5de989484e0a6ba2e5a6c41b55f8b8bd85dba","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"49a253ec027e56c55c7450a0c331cfe96212b3d1cc215b1710ba94a083404cf3","affectsGlobalScope":true},"1c29793071152b207c01ea1954e343be9a44d85234447b2b236acae9e709a383","6a386ff939f180ae8ef064699d8b7b6e62bc2731a62d7fbf5e02589383838dea","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"278fe30e638dad09488d130287c728f99f61cb315ed86b70c36040e4311f9cf5","affectsGlobalScope":true},"af7fd2870746deed40e130fc0a3966de74e8f52a97ec114d0fbb35876ab05ca9","3ae62be455efcb1874e7fd1f30f2bb83144757d2f349ceb0c6523bb9f7f7a860","be0f711ade459d8e51739f8544a565bc7d2ea56a9dda7ef6d5edd9d864737276","b1296831e111197bd9ebd73f0d15ad0fe2e11fcc51a6302edb23ffd93794db36","5610e8177b34fa50394973f3faba06fd5268b1264a2f4f7daaa71fee1194a94d","4dc29833bfcaa8597097a99fd486d72a0de9c38bb7a6dcd1dadb70e1b9c17282","9869fe612661e4bb3a63b339b3a0d0cdbb6c9e85dd4a59209c86383179e3fbd9","f42116e2e8ad600dc90bdf8ceade9dcf593c35812d8aaba9c03a3f1dbb87330e","dff2fee737ebe5174f549c9f28e114c0cabac4b5fe4e364654465ba528979ba4","86c9954d4c0c270f2952a8695b90fbf4a58210deae10911be98b6c31b84cc8db","466df547af9cf3861658b08baf3ecbd41c0eaad2101378fadfa54ab24db103e6","66b37de2f4b108cf4467570730a30cac8aa7d9ec94a0e335825c9192c1188094",{"version":"1492704513322629439c269bb9a1daf672c9319bff4cb85fb3739a5a53afbbae","signature":"34e5c5b2be8aa1b3f75ccd21529ae8b9163f510dbdabae4caae3fec3010cc33b"},{"version":"17f850d81088adf2bbc979ed59102d9f67f57a4581d24b63886ae4c6b5f79e89","signature":"45fb3525f5c652416e54f91bd8378464d41e22b0ccc108de7db918cf8e92ffd3"},{"version":"75faa8444f3d7281d1ec337213720d738129ef55a9672c7176bf6a949217ed77","signature":"e2402a646d4471b0985495b6bfca6c9c731d335195bf206e8c982d8ca362692f"},{"version":"10b5677a98e54b81f2ebd2661cb5c6cd9df9f210082b50c4281a308ffedbe72f","signature":"08d34fcbf615950f6d3dd6858437159f0c0af08d5af645ec415ebfeaeacf3bd0"},{"version":"ee4207ce0cb680870df58a4f65bc63d22601f63c867a319bf94e1196b9a03c93","signature":"13ce162c8088b92a985e41a2ddf61cbb191101c280214a74dd9e8d2fd3c9c905"},{"version":"a877839bda319a7373935c6d51a1b8dfa20f95b48081b6637f47cf33237f955e","signature":"33a492825bcebd5ef9d6e5dd0e2caf8af102ff57cc28353acdfa1cf5c5039e66"},{"version":"cd017864db761491dd1dca6cf01c70ee66313a662062664ceb01254b61ce64b1","signature":"4b47e095287cc1351b5fa9c5112d1d2d255bd8916ce76347225837b244e97ed5"},"bcb6ea18f23dae2c48459d7b86d3adccd6898f824fcbf9da08b935f559896580","0aa7220845f5f3902fe043f646f9d9218bd7dd6c4046e8471580866ea6b03aa2","4d5fb5d6b35f731b2ae4d9d7c592d48e91d6de531dd130628edf4eba16add893","739c2c46edc112421fc023c24b4898b1f413f792bb6a02b40ba182c648e56c2f",{"version":"df93bb67d5ae7be3d599323de42e12cb8da59f0b490c3186ae91d493632b5e36","affectsGlobalScope":true},{"version":"f8b8b34c4f7651c9f7b126af8affda4139a0499e62e74f0f8dc2be36e9f14b59","affectsGlobalScope":true}],"root":[[79,85]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"experimentalDecorators":true,"jsx":4,"module":99,"noEmitOnError":true,"noImplicitOverride":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"useDefineForClassFields":true},"fileIdsList":[[68,69,70,71,72,73,74,75,76,77],[69,70],[70],[68],[69],[62,63,64,65],[66],[90],[86],[87],[88,89],[67,78,83],[67,83,84],[67,78,79,80],[67,81],[67],[67,79,80,81,82],[78,83],[83,84],[78,79,80],[81],[79,80,81,82]],"referencedMap":[[78,1],[71,2],[72,3],[69,4],[73,5],[74,4],[75,3],[66,6],[67,7],[91,8],[87,9],[88,10],[90,11],[84,12],[85,13],[81,14],[82,15],[79,16],[80,15],[83,17]],"exportedModulesMap":[[78,1],[71,2],[72,3],[69,4],[73,5],[74,4],[75,3],[66,6],[67,7],[91,8],[87,9],[88,10],[90,11],[84,18],[85,19],[81,20],[82,21],[80,21],[83,22]],"semanticDiagnosticsPerFile":[77,78,71,72,69,70,73,74,76,75,68,64,63,62,66,67,65,60,61,12,13,15,14,2,16,17,18,19,20,21,22,23,3,4,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,10,1,11,59,91,87,86,88,89,90,84,85,81,82,79,80,83],"latestChangedDtsFile":"./index.d.ts"},"version":"5.0.4"}
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../../node_modules/typescript/lib/lib.es2023.d.ts","../../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/@types/react/ts5.0/global.d.ts","../../../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../../../node_modules/@types/prop-types/index.d.ts","../../../../node_modules/@types/scheduler/tracing.d.ts","../../../../node_modules/@types/react/ts5.0/index.d.ts","../../../../node_modules/@types/react/ts5.0/jsx-runtime.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/value.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/input.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/json.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/acl.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/actions.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/model.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/result.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/validation.d.ts","../../../../node_modules/@contember/schema/dist/src/schema/settings.d.ts","../../../../node_modules/@contember/schema/dist/src/ProjectRole.d.ts","../../../../node_modules/@contember/schema/dist/src/index.d.ts","../../src/nodes/GraphQlFragmentSpread.ts","../../src/nodes/GraphQlInlineFragment.ts","../../src/nodes/GraphQlField.ts","../../src/nodes/GraphQlFragment.ts","../../src/nodes/index.ts","../../src/GraphQlQueryPrinter.ts","../../src/index.ts","../../../../node_modules/vite/types/hmrPayload.d.ts","../../../../node_modules/vite/types/customEvent.d.ts","../../../../node_modules/vite/types/hot.d.ts","../../../../node_modules/vite/types/importGlob.d.ts","../../../../node_modules/vite/types/importMeta.d.ts","../../../../node_modules/vite/client.d.ts"],"fileInfos":[{"version":"6a6b471e7e43e15ef6f8fe617a22ce4ecb0e34efa6c3dfcfe7cebd392bcca9d2","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec",{"version":"fcd3ecc9f764f06f4d5c467677f4f117f6abf49dee6716283aa204ff1162498b","affectsGlobalScope":true},{"version":"9a60b92bca4c1257db03b349d58e63e4868cfc0d1c8d0ba60c2dbc63f4e6c9f6","affectsGlobalScope":true},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"5114a95689b63f96b957e00216bc04baf9e1a1782aa4d8ee7e5e9acbf768e301","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"b7feb7967c6c6003e11f49efa8f5de989484e0a6ba2e5a6c41b55f8b8bd85dba","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"49a253ec027e56c55c7450a0c331cfe96212b3d1cc215b1710ba94a083404cf3","affectsGlobalScope":true},"1c29793071152b207c01ea1954e343be9a44d85234447b2b236acae9e709a383","6a386ff939f180ae8ef064699d8b7b6e62bc2731a62d7fbf5e02589383838dea","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"278fe30e638dad09488d130287c728f99f61cb315ed86b70c36040e4311f9cf5","affectsGlobalScope":true},"af7fd2870746deed40e130fc0a3966de74e8f52a97ec114d0fbb35876ab05ca9","3ae62be455efcb1874e7fd1f30f2bb83144757d2f349ceb0c6523bb9f7f7a860","be0f711ade459d8e51739f8544a565bc7d2ea56a9dda7ef6d5edd9d864737276","b1296831e111197bd9ebd73f0d15ad0fe2e11fcc51a6302edb23ffd93794db36","5610e8177b34fa50394973f3faba06fd5268b1264a2f4f7daaa71fee1194a94d","4dc29833bfcaa8597097a99fd486d72a0de9c38bb7a6dcd1dadb70e1b9c17282","9869fe612661e4bb3a63b339b3a0d0cdbb6c9e85dd4a59209c86383179e3fbd9","f42116e2e8ad600dc90bdf8ceade9dcf593c35812d8aaba9c03a3f1dbb87330e","dff2fee737ebe5174f549c9f28e114c0cabac4b5fe4e364654465ba528979ba4","86c9954d4c0c270f2952a8695b90fbf4a58210deae10911be98b6c31b84cc8db","466df547af9cf3861658b08baf3ecbd41c0eaad2101378fadfa54ab24db103e6","66b37de2f4b108cf4467570730a30cac8aa7d9ec94a0e335825c9192c1188094",{"version":"1492704513322629439c269bb9a1daf672c9319bff4cb85fb3739a5a53afbbae","signature":"34e5c5b2be8aa1b3f75ccd21529ae8b9163f510dbdabae4caae3fec3010cc33b"},{"version":"17f850d81088adf2bbc979ed59102d9f67f57a4581d24b63886ae4c6b5f79e89","signature":"45fb3525f5c652416e54f91bd8378464d41e22b0ccc108de7db918cf8e92ffd3"},{"version":"75faa8444f3d7281d1ec337213720d738129ef55a9672c7176bf6a949217ed77","signature":"e2402a646d4471b0985495b6bfca6c9c731d335195bf206e8c982d8ca362692f"},{"version":"10b5677a98e54b81f2ebd2661cb5c6cd9df9f210082b50c4281a308ffedbe72f","signature":"08d34fcbf615950f6d3dd6858437159f0c0af08d5af645ec415ebfeaeacf3bd0"},{"version":"ee4207ce0cb680870df58a4f65bc63d22601f63c867a319bf94e1196b9a03c93","signature":"13ce162c8088b92a985e41a2ddf61cbb191101c280214a74dd9e8d2fd3c9c905"},{"version":"41d26b47fa23c6126b4407396799af8a4d5a63be15837f61204beb4d2692209d","signature":"d2689735d2498972d6f02fbaff989b1fa500b5a140af7e7c08a15fbc36c1d3d3"},{"version":"cd017864db761491dd1dca6cf01c70ee66313a662062664ceb01254b61ce64b1","signature":"4b47e095287cc1351b5fa9c5112d1d2d255bd8916ce76347225837b244e97ed5"},"bcb6ea18f23dae2c48459d7b86d3adccd6898f824fcbf9da08b935f559896580","0aa7220845f5f3902fe043f646f9d9218bd7dd6c4046e8471580866ea6b03aa2","4d5fb5d6b35f731b2ae4d9d7c592d48e91d6de531dd130628edf4eba16add893","739c2c46edc112421fc023c24b4898b1f413f792bb6a02b40ba182c648e56c2f",{"version":"df93bb67d5ae7be3d599323de42e12cb8da59f0b490c3186ae91d493632b5e36","affectsGlobalScope":true},{"version":"f8b8b34c4f7651c9f7b126af8affda4139a0499e62e74f0f8dc2be36e9f14b59","affectsGlobalScope":true}],"root":[[79,85]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"experimentalDecorators":true,"jsx":4,"module":99,"noEmitOnError":true,"noImplicitOverride":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"useDefineForClassFields":true},"fileIdsList":[[68,69,70,71,72,73,74,75,76,77],[69,70],[70],[68],[69],[62,63,64,65],[66],[90],[86],[87],[88,89],[67,78,83],[67,83,84],[67,78,79,80],[67,81],[67],[67,79,80,81,82],[78,83],[83,84],[78,79,80],[81],[79,80,81,82]],"referencedMap":[[78,1],[71,2],[72,3],[69,4],[73,5],[74,4],[75,3],[66,6],[67,7],[91,8],[87,9],[88,10],[90,11],[84,12],[85,13],[81,14],[82,15],[79,16],[80,15],[83,17]],"exportedModulesMap":[[78,1],[71,2],[72,3],[69,4],[73,5],[74,4],[75,3],[66,6],[67,7],[91,8],[87,9],[88,10],[90,11],[84,18],[85,19],[81,20],[82,21],[80,21],[83,22]],"semanticDiagnosticsPerFile":[77,78,71,72,69,70,73,74,76,75,68,64,63,62,66,67,65,60,61,12,13,15,14,2,16,17,18,19,20,21,22,23,3,4,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,10,1,11,59,91,87,86,88,89,90,84,85,81,82,79,80,83],"latestChangedDtsFile":"./index.d.ts"},"version":"5.0.4"}
|
package/package.json
CHANGED
|
@@ -12,6 +12,8 @@ export class GraphQlQueryPrinter {
|
|
|
12
12
|
value: JSONValue
|
|
13
13
|
}> = {}
|
|
14
14
|
|
|
15
|
+
private variableValueToName: Record<string, Map<JSONValue, string>> = {}
|
|
16
|
+
|
|
15
17
|
private usedFragments = new Set<string>()
|
|
16
18
|
|
|
17
19
|
private body = ''
|
|
@@ -99,17 +101,13 @@ export class GraphQlQueryPrinter {
|
|
|
99
101
|
if (arg.value === undefined) {
|
|
100
102
|
continue
|
|
101
103
|
}
|
|
102
|
-
const variableName =
|
|
104
|
+
const variableName = this.resolveVariableName(arg.graphQlType, arg.value)
|
|
103
105
|
if (i++ === 0) {
|
|
104
106
|
this.body += '('
|
|
105
107
|
} else {
|
|
106
108
|
this.body += ', '
|
|
107
109
|
}
|
|
108
110
|
this.body += `${argName}: $${variableName}`
|
|
109
|
-
this.variables[variableName] = {
|
|
110
|
-
type: arg.graphQlType,
|
|
111
|
-
value: arg.value,
|
|
112
|
-
}
|
|
113
111
|
}
|
|
114
112
|
if (i > 0) {
|
|
115
113
|
this.body += ')'
|
|
@@ -122,6 +120,23 @@ export class GraphQlQueryPrinter {
|
|
|
122
120
|
this.body += '\n'
|
|
123
121
|
}
|
|
124
122
|
|
|
123
|
+
private resolveVariableName(graphQlType: string, value: JSONValue): string {
|
|
124
|
+
const variableName = this.variableValueToName[graphQlType]?.get(value)
|
|
125
|
+
if (variableName) {
|
|
126
|
+
return variableName
|
|
127
|
+
}
|
|
128
|
+
const newVariableName = `${graphQlType.replace(/[\W]/g, '')}_${this.variableCounter++}`
|
|
129
|
+
this.variables[newVariableName] = {
|
|
130
|
+
type: graphQlType,
|
|
131
|
+
value: value,
|
|
132
|
+
}
|
|
133
|
+
if (!this.variableValueToName[graphQlType]) {
|
|
134
|
+
this.variableValueToName[graphQlType] = new Map()
|
|
135
|
+
}
|
|
136
|
+
this.variableValueToName[graphQlType].set(value, newVariableName)
|
|
137
|
+
return newVariableName
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
private cleanState(): void {
|
|
126
141
|
this.body = ''
|
|
127
142
|
this.variableCounter = 0
|