{"version":3,"sources":["graphql/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,eAAe,CA04B9H;AAED,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAChC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC;CAC3B","file":"compiler.d.ts","sourcesContent":["import { FormatResponse } from '@src/formatter/formatter';\nimport {\n\tformattedInputField,\n\tFormattedInputNode,\n\tFormattedInputObject,\n\tformattedOutputField,\n\tFormattedOutputNode,\n\tFormattedOutputObject\n} from '@src/formatter/formatter-model';\nimport {\n\tFieldType,\n\tGqlObjectNode,\n\tInputField,\n\tList,\n\tMethodDescriptor,\n\tModelKind,\n\tParam,\n\tReference,\n\tUnion\n} from 'tt-model';\nimport {\n\tGraphQLEnumTypeConfig,\n\tGraphQLEnumValueConfig,\n\tGraphQLFieldConfig,\n\tGraphQLInputFieldConfig,\n\tGraphQLInputObjectTypeConfig,\n\tGraphQLObjectTypeConfig,\n\tGraphQLScalarTypeConfig,\n\tGraphQLSchemaConfig\n} from 'graphql';\nimport ts from 'typescript';\nimport { relative } from 'path';\nimport { compileAsserts } from '@src/validator/compile-asserts';\n/** Compile Model into Graphql */\nexport function toGraphQL(\n\troot: FormatResponse,\n\tf: ts.NodeFactory,\n\tpretty: boolean,\n\ttargetSrcFilePath: string\n): GqlCompilerResp {\n\t/** Validation schema declarations by the API */\n\tconst validationDeclarations: ts.VariableDeclaration[] = [];\n\t/** Graphql types declaration */\n\tconst graphqlDeclarations: ts.VariableDeclaration[] = [];\n\t//* Graphql imports\n\tconst GraphQLScalarType = f.createUniqueName('GraphQLScalarType');\n\tconst GraphQLSchema = f.createUniqueName('GraphQLSchema');\n\tconst GraphQLEnumType = f.createUniqueName('GraphQLEnumType');\n\tconst GraphQLObjectType = f.createUniqueName('GraphQLObjectType');\n\tconst GraphQLInputObjectType = f.createUniqueName('GraphQLInputObjectType');\n\tconst GraphQLList = f.createUniqueName('GraphQLList');\n\tconst GraphQLNonNull = f.createUniqueName('GraphQLNonNull');\n\tconst GraphQLUnionType = f.createUniqueName('GraphQLUnionType');\n\tconst GraphQLFieldResolver = f.createUniqueName('GraphQLFieldResolver');\n\t//* GQL Imports\n\tconst gqlImports: (string | ts.Identifier)[] = [\n\t\t'GraphQLScalarType',\n\t\tGraphQLScalarType,\n\t\t'GraphQLSchema',\n\t\tGraphQLSchema,\n\t\t'GraphQLEnumType',\n\t\tGraphQLEnumType,\n\t\t'GraphQLObjectType',\n\t\tGraphQLObjectType,\n\t\t'GraphQLInputObjectType',\n\t\tGraphQLInputObjectType,\n\t\t'GraphQLList',\n\t\tGraphQLList,\n\t\t'GraphQLNonNull',\n\t\tGraphQLNonNull,\n\t\t'GraphQLUnionType',\n\t\tGraphQLUnionType,\n\t\t'GraphQLFieldResolver',\n\t\tGraphQLFieldResolver\n\t];\n\t//* tt-model imports\n\tconst validateObj = f.createUniqueName('validateObj');\n\tconst ttModelImports: (string | ts.Identifier)[] = [\n\t\t'validateObj',\n\t\tvalidateObj\n\t];\n\t//* Other imports\n\tconst srcImports: Map<\n\t\tstring,\n\t\tMap<string, { varName: ts.Identifier; isClass: boolean }>\n\t> = new Map();\n\t//* Go through Model\n\tconst { input: rootInput, output: rootOutput } = root;\n\tconst queue: QueueInterface[] = [];\n\tif (rootOutput.has('Subscription'))\n\t\tqueue.push({\n\t\t\tentity: rootOutput.get('Subscription')!,\n\t\t\tisInput: false,\n\t\t\tindex: 0,\n\t\t\tcircles: undefined\n\t\t});\n\tif (rootOutput.has('Mutation'))\n\t\tqueue.push({\n\t\t\tentity: rootOutput.get('Mutation')!,\n\t\t\tisInput: false,\n\t\t\tindex: 0,\n\t\t\tcircles: undefined\n\t\t});\n\tif (rootOutput.has('Query'))\n\t\tqueue.push({\n\t\t\tentity: rootOutput.get('Query')!,\n\t\t\tisInput: false,\n\t\t\tindex: 0,\n\t\t\tcircles: undefined\n\t\t});\n\tvar queueLen: number;\n\t/** Map entities to their variables */\n\tconst mapEntities: Map<QueueInterface['entity'], ts.Identifier> = new Map();\n\t/** Map entities to their validation variables */\n\tconst mapVldEntities: Map<QueueInterface['entity'], ParamItem> = new Map();\n\tconst PATH: Set<QueueInterface['entity']> = new Set();\n\t/** Circle fields from previous iterations */\n\tvar fieldHasCircle = false;\n\tconst mapCircles: CircleEntities[] = [];\n\tconst mapVldCircles: CircleEntities[] = [];\n\tconst namesSet: Set<string> = new Set();\n\ttry {\n\t\t/** Generate uniquely named entities */\n\t\trootLoop: while ((queueLen = queue.length) > 0) {\n\t\t\tlet currentNode = queue[queueLen - 1];\n\t\t\tlet { entity, isInput, index } = currentNode;\n\t\t\tlet entityVar: ts.Identifier;\n\t\t\tswitch (entity.kind) {\n\t\t\t\tcase ModelKind.FORMATTED_INPUT_OBJECT:\n\t\t\t\tcase ModelKind.FORMATTED_OUTPUT_OBJECT:\n\t\t\t\t\t// Resolve each\n\t\t\t\t\tisInput = entity.kind === ModelKind.FORMATTED_INPUT_OBJECT;\n\t\t\t\t\tif (index < entity.fields.length) {\n\t\t\t\t\t\tPATH.add(entity);\n\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\tentity: entity.fields[index++],\n\t\t\t\t\t\t\tisInput,\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcurrentNode.index = index;\n\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t}\n\t\t\t\t\t// Entity name\n\t\t\t\t\tlet entityName = _getEntityName(entity.escapedName);\n\t\t\t\t\t// Create entity var\n\t\t\t\t\tPATH.delete(entity);\n\t\t\t\t\tentityVar = f.createUniqueName(entityName);\n\t\t\t\t\tmapEntities.set(entity, entityVar);\n\t\t\t\t\tlet gqlObjet = isInput\n\t\t\t\t\t\t? GraphQLInputObjectType\n\t\t\t\t\t\t: GraphQLObjectType;\n\t\t\t\t\t// Create entity object\n\t\t\t\t\tif (currentNode.circles != null) {\n\t\t\t\t\t\tlet circles = currentNode.circles;\n\t\t\t\t\t\t// Create fields with no circles\n\t\t\t\t\t\tlet fieldsVar = f.createUniqueName(\n\t\t\t\t\t\t\tentityName + '_fields'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlet expFields: Record<string, ts.Expression> = {};\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tlet i = 0,\n\t\t\t\t\t\t\tfields = entity.fields,\n\t\t\t\t\t\t\tlen = fields.length;\n\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlet field = fields[i];\n\t\t\t\t\t\t\tif (circles.indexOf(field) === -1) {\n\t\t\t\t\t\t\t\texpFields[field.alias ?? field.name] =\n\t\t\t\t\t\t\t\t\t_compileField(field);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmapCircles.push({\n\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\tvarname: fieldsVar,\n\t\t\t\t\t\t\tcircles: circles\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// Create obj\n\t\t\t\t\t\tlet entityDesc: {\n\t\t\t\t\t\t\t[k in keyof (\n\t\t\t\t\t\t\t\t| GraphQLInputObjectTypeConfig\n\t\t\t\t\t\t\t\t| GraphQLObjectTypeConfig<any, any>\n\t\t\t\t\t\t\t)]: any;\n\t\t\t\t\t\t} = {\n\t\t\t\t\t\t\tname: entityName,\n\t\t\t\t\t\t\tfields: fieldsVar\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (entity.jsDoc.length > 0)\n\t\t\t\t\t\t\tentityDesc.description = entity.jsDoc.join('\\n');\n\t\t\t\t\t\tgraphqlDeclarations.push(\n\t\t\t\t\t\t\t// Field var\n\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\tfieldsVar,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createTypeReferenceNode(\n\t\t\t\t\t\t\t\t\tf.createIdentifier('Record'),\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t_serializeObject(expFields)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// Object\n\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createNewExpression(gqlObjet, undefined, [\n\t\t\t\t\t\t\t\t\t_serializeObject(entityDesc)\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\t//* Compile input data validation\n\t\t\t\t\t\tlet vfields: ts.Expression[] = [];\n\t\t\t\t\t\tlet vldVar = f.createUniqueName(entityName);\n\t\t\t\t\t\tlet vldFieldsVar = f.createUniqueName(\n\t\t\t\t\t\t\tentityName + '_fields'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tlet i = 0,\n\t\t\t\t\t\t\tfields = entity.fields,\n\t\t\t\t\t\t\tlen = fields.length;\n\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlet fld = fields[i];\n\t\t\t\t\t\t\tif (circles.indexOf(fld) === -1) {\n\t\t\t\t\t\t\t\tlet f = _compileValidateFields(\n\t\t\t\t\t\t\t\t\tentity as FormattedInputObject,\n\t\t\t\t\t\t\t\t\tfields[i] as formattedInputField\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (f != null) vfields.push(f);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmapVldEntities.set(entity, {\n\t\t\t\t\t\t\tvar: vldVar,\n\t\t\t\t\t\t\tlen: vfields.length\n\t\t\t\t\t\t});\n\t\t\t\t\t\tmapVldCircles.push({\n\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\tvarname: vldFieldsVar,\n\t\t\t\t\t\t\tcircles\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// add object definition\n\t\t\t\t\t\tvalidationDeclarations.push(\n\t\t\t\t\t\t\t// Fields\n\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\tvldFieldsVar,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tf.createArrayLiteralExpression(vfields, pretty)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t// Add object definition\n\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\tvldVar,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t_serializeObject({\n\t\t\t\t\t\t\t\t\tkind: ModelKind.PLAIN_OBJECT,\n\t\t\t\t\t\t\t\t\tfields: vldFieldsVar\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t//*  Object without any circles\n\t\t\t\t\t\tlet expFields: Record<string, ts.Expression> = {};\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tlet i = 0,\n\t\t\t\t\t\t\tfields = entity.fields,\n\t\t\t\t\t\t\tlen = fields.length;\n\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlet field = fields[i];\n\t\t\t\t\t\t\texpFields[field.alias ?? field.name] =\n\t\t\t\t\t\t\t\t_compileField(field);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Create obj\n\t\t\t\t\t\tlet entityDesc: {\n\t\t\t\t\t\t\t[k in keyof (\n\t\t\t\t\t\t\t\t| GraphQLInputObjectTypeConfig\n\t\t\t\t\t\t\t\t| GraphQLObjectTypeConfig<any, any>\n\t\t\t\t\t\t\t)]: any;\n\t\t\t\t\t\t} = {\n\t\t\t\t\t\t\tname: entityName,\n\t\t\t\t\t\t\tfields: _serializeObject(expFields)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (entity.jsDoc.length > 0)\n\t\t\t\t\t\t\tentityDesc.description = entity.jsDoc.join('\\n');\n\t\t\t\t\t\tgraphqlDeclarations.push(\n\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createNewExpression(gqlObjet, undefined, [\n\t\t\t\t\t\t\t\t\t_serializeObject(entityDesc)\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\t//* Compile input data validation\n\t\t\t\t\t\tif (isInput) {\n\t\t\t\t\t\t\tlet vfields: ts.Expression[] = [];\n\t\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\t\tlet i = 0,\n\t\t\t\t\t\t\t\tfields = entity.fields,\n\t\t\t\t\t\t\t\tlen = fields.length;\n\t\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet f = _compileValidateFields(\n\t\t\t\t\t\t\t\t\tentity as FormattedInputObject,\n\t\t\t\t\t\t\t\t\tfields[i] as formattedInputField\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (f != null) vfields.push(f);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// add object definition\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tvfields.length ||\n\t\t\t\t\t\t\t\t(entity as FormattedInputObject).validate !=\n\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet entityDsc = mapVldEntities.get(entity);\n\t\t\t\t\t\t\t\tlet vldVar: ts.Identifier;\n\t\t\t\t\t\t\t\tif (entityDsc != null) {\n\t\t\t\t\t\t\t\t\tvldVar = entityDsc.var;\n\t\t\t\t\t\t\t\t\tentityDsc.len += vfields.length;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tvldVar = f.createUniqueName(entityName);\n\t\t\t\t\t\t\t\t\tmapVldEntities.set(entity, {\n\t\t\t\t\t\t\t\t\t\tvar: vldVar,\n\t\t\t\t\t\t\t\t\t\tlen: vfields.length\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tlet objD: { [k in keyof GqlObjectNode]: any } = {\n\t\t\t\t\t\t\t\t\t\tkind: ModelKind.PLAIN_OBJECT,\n\t\t\t\t\t\t\t\t\t\tfields: f.createArrayLiteralExpression(\n\t\t\t\t\t\t\t\t\t\t\tvfields,\n\t\t\t\t\t\t\t\t\t\t\tpretty\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tbefore: undefined,\n\t\t\t\t\t\t\t\t\t\tafter: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Input validation\n\t\t\t\t\t\t\t\t\tlet entityF = entity as FormattedInputObject;\n\t\t\t\t\t\t\t\t\tif (entityF.validate != null) {\n\t\t\t\t\t\t\t\t\t\tobjD.before = _getMethodCall(entityF.validate, 'before');\n\t\t\t\t\t\t\t\t\t\tobjD.after = _getMethodCall(entityF.validate, 'after');\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Add declaration\n\t\t\t\t\t\t\t\t\tvalidationDeclarations.push(\n\t\t\t\t\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\t\t\t\t\tvldVar,\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t_serializeObject(objD)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.UNION:\n\t\t\t\t\t// Check for circles in previous type check\n\t\t\t\t\tif (fieldHasCircle) {\n\t\t\t\t\t\tfieldHasCircle = false;\n\t\t\t\t\t\tif (index === 0)\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Unexpected circle before starting union!`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t(currentNode.circles ??= []).push(\n\t\t\t\t\t\t\tentity.types[index - 1]\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t// Resolve each type\n\t\t\t\t\tif (index < entity.types.length) {\n\t\t\t\t\t\tPATH.add(entity);\n\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\tentity: entity.types[index++],\n\t\t\t\t\t\t\tisInput: false,\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcurrentNode.index = index;\n\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t}\n\t\t\t\t\t// Resolved\n\t\t\t\t\tPATH.delete(entity);\n\t\t\t\t\t// Entity name\n\t\t\t\t\tlet unionName = _getEntityName(entity.name);\n\t\t\t\t\tentityVar = f.createUniqueName(unionName);\n\t\t\t\t\tmapEntities.set(entity, entityVar);\n\t\t\t\t\t// create types\n\t\t\t\t\tlet typesVar = f.createUniqueName(unionName + 'Types');\n\t\t\t\t\tlet types: ts.Identifier[] = [];\n\t\t\t\t\tif (currentNode.circles == null) {\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tlet i = 0, tps = entity.types, len = tps.length;\n\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlet t = tps[i];\n\t\t\t\t\t\t\ttypes.push(\n\t\t\t\t\t\t\t\tmapEntities.get(rootOutput.get(t.name!)!)!\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet circles = currentNode.circles;\n\t\t\t\t\t\tfor (\n\t\t\t\t\t\t\tlet i = 0, tps = entity.types, len = tps.length;\n\t\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t\t++i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlet t = tps[i];\n\t\t\t\t\t\t\tif (circles.includes(t) === false)\n\t\t\t\t\t\t\t\ttypes.push(\n\t\t\t\t\t\t\t\t\tmapEntities.get(rootOutput.get(t.name!)!)!\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmapCircles.push({ entity, varname: typesVar, circles });\n\t\t\t\t\t}\n\t\t\t\t\t// Create object\n\t\t\t\t\tlet unionImportedDescVar = _getLocalImport(entity.parser);\n\t\t\t\t\tlet unionDesc = [\n\t\t\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t\t\t'name',\n\t\t\t\t\t\t\tf.createStringLiteral(unionName)\n\t\t\t\t\t\t),\n\t\t\t\t\t\tf.createPropertyAssignment('types', typesVar),\n\t\t\t\t\t\t_createMethod(\n\t\t\t\t\t\t\t'resolveType',\n\t\t\t\t\t\t\t['value', 'ctx', 'info'],\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tf.createReturnStatement(\n\t\t\t\t\t\t\t\t\tf.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\ttypesVar,\n\t\t\t\t\t\t\t\t\t\tf.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\tf.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tunionImportedDescVar,\n\t\t\t\t\t\t\t\t\t\t\t\tf.createIdentifier(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'resolveType'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\tf.createIdentifier('value'),\n\t\t\t\t\t\t\t\t\t\t\t\tf.createIdentifier('ctx'),\n\t\t\t\t\t\t\t\t\t\t\t\tf.createIdentifier('info')\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t];\n\t\t\t\t\tif (entity.jsDoc.length > 0)\n\t\t\t\t\t\tunionDesc.push(\n\t\t\t\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t\t\t\t'description',\n\t\t\t\t\t\t\t\tf.createStringLiteral(entity.jsDoc.join('\\n'))\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\tgraphqlDeclarations.push(\n\t\t\t\t\t\t// types\n\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\ttypesVar,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\t\t\tf.createArrayLiteralExpression(types, pretty)\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// var\n\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.createNewExpression(GraphQLUnionType, undefined, [\n\t\t\t\t\t\t\t\tf.createObjectLiteralExpression(\n\t\t\t\t\t\t\t\t\tunionDesc,\n\t\t\t\t\t\t\t\t\tpretty\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.INPUT_FIELD:\n\t\t\t\t\tif (index === 0) {\n\t\t\t\t\t\t++currentNode.index;\n\t\t\t\t\t\t//* Resolve field\n\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\tentity: entity.type,\n\t\t\t\t\t\t\tisInput: true,\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t} else if (fieldHasCircle) {\n\t\t\t\t\t\t// Circle detected\n\t\t\t\t\t\tfieldHasCircle = false;\n\t\t\t\t\t\t// Push as circle to parent object\n\t\t\t\t\t\t(queue[queueLen - 2].circles ??= []).push(entity);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.OUTPUT_FIELD:\n\t\t\t\t\t// circles\n\t\t\t\t\tif (fieldHasCircle) {\n\t\t\t\t\t\tif (index === 0)\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Unexpected circles before visiting output field!`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t// Circle detected\n\t\t\t\t\t\tfieldHasCircle = false;\n\t\t\t\t\t\t(queue[queueLen - 2].circles ??= []).push(entity);\n\t\t\t\t\t}\n\t\t\t\t\t// visited field\n\t\t\t\t\tswitch (index) {\n\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\t// Resolve type\n\t\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\t\tentity: entity.type,\n\t\t\t\t\t\t\t\tisInput: false,\n\t\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t++currentNode.index;\n\t\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\t// Resolve param\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tentity.param != null &&\n\t\t\t\t\t\t\t\tentity.param.type != null\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\t\t\tentity: entity.param.type,\n\t\t\t\t\t\t\t\t\tisInput: true,\n\t\t\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t++currentNode.index;\n\t\t\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.LIST:\n\t\t\t\t\tif (index === 0) {\n\t\t\t\t\t\t++currentNode.index;\n\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\tentity: entity.type,\n\t\t\t\t\t\t\tisInput,\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.REF:\n\t\t\t\t\tif (index === 0) {\n\t\t\t\t\t\t++currentNode.index;\n\t\t\t\t\t\tlet refNode = isInput\n\t\t\t\t\t\t\t? rootInput.get(entity.name)\n\t\t\t\t\t\t\t: rootOutput.get(entity.name);\n\t\t\t\t\t\tif (refNode == null)\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Unexpected Missing Entity \"${entity.name}\"`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (mapEntities.has(refNode)) {\n\t\t\t\t\t\t} else if (PATH.has(refNode)) {\n\t\t\t\t\t\t\t//* Circle\n\t\t\t\t\t\t\tfieldHasCircle = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t//* Parse new entity\n\t\t\t\t\t\t\tqueue.push({\n\t\t\t\t\t\t\t\tentity: refNode,\n\t\t\t\t\t\t\t\tisInput,\n\t\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\t\tcircles: undefined\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue rootLoop;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.ENUM:\n\t\t\t\t\t//* ENUM\n\t\t\t\t\tlet enumName = _getEntityName(entity.name);\n\t\t\t\t\tentityVar = f.createUniqueName(enumName);\n\t\t\t\t\tmapEntities.set(entity, entityVar);\n\t\t\t\t\tlet enumValues: ts.PropertyAssignment[] = [];\n\t\t\t\t\tfor (\n\t\t\t\t\t\tlet i = 0,\n\t\t\t\t\t\tmembers = entity.members,\n\t\t\t\t\t\tlen = members.length;\n\t\t\t\t\t\ti < len;\n\t\t\t\t\t\t++i\n\t\t\t\t\t) {\n\t\t\t\t\t\tlet member = members[i];\n\t\t\t\t\t\tlet obj: { [k in keyof GraphQLEnumValueConfig]: any } =\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvalue: member.value\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (member.jsDoc.length > 0)\n\t\t\t\t\t\t\tobj.description = member.jsDoc.join('\\n');\n\t\t\t\t\t\tif (member.deprecated)\n\t\t\t\t\t\t\tobj.deprecationReason = member.deprecated;\n\t\t\t\t\t\tenumValues.push(\n\t\t\t\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t\t\t\tmember.name,\n\t\t\t\t\t\t\t\t_serializeObject(obj)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tlet entityDesc: {\n\t\t\t\t\t\t[k in keyof GraphQLEnumTypeConfig]: any;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tname: enumName,\n\t\t\t\t\t\tvalues: f.createObjectLiteralExpression(\n\t\t\t\t\t\t\tenumValues,\n\t\t\t\t\t\t\tpretty\n\t\t\t\t\t\t)\n\t\t\t\t\t};\n\t\t\t\t\tif (entity.jsDoc.length > 0)\n\t\t\t\t\t\tentityDesc.description = entity.jsDoc.join('\\n');\n\t\t\t\t\tgraphqlDeclarations.push(\n\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.createNewExpression(GraphQLEnumType, undefined, [\n\t\t\t\t\t\t\t\t_serializeObject(entityDesc)\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.SCALAR:\n\t\t\t\t\tlet scalarName = _getEntityName(entity.name);\n\t\t\t\t\t//* Scalar\n\t\t\t\t\tentityVar = f.createUniqueName(scalarName);\n\t\t\t\t\tmapEntities.set(entity, entityVar);\n\t\t\t\t\tlet scalardesc: {\n\t\t\t\t\t\t[k in keyof GraphQLScalarTypeConfig<any, any>]: any;\n\t\t\t\t\t} = {\n\t\t\t\t\t\tname: scalarName,\n\t\t\t\t\t\tparseValue: _getMethodCall(entity.parser, 'parse'),\n\t\t\t\t\t\tserialize: _getMethodCall(entity.parser, 'serialize')\n\t\t\t\t\t};\n\t\t\t\t\tif (entity.jsDoc.length > 0)\n\t\t\t\t\t\tscalardesc.description = entity.jsDoc.join('\\n');\n\t\t\t\t\tgraphqlDeclarations.push(\n\t\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tf.createNewExpression(\n\t\t\t\t\t\t\t\tGraphQLScalarType,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t[_serializeObject(scalardesc)]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase ModelKind.BASIC_SCALAR:\n\t\t\t\t\tlet bScalarName = _getEntityName(entity.name);\n\t\t\t\t\tentityVar = f.createUniqueName(bScalarName);\n\t\t\t\t\tmapEntities.set(entity, entityVar);\n\t\t\t\t\tswitch (entity.name) {\n\t\t\t\t\t\t// Graphql basic scalars\n\t\t\t\t\t\tcase 'Int':\n\t\t\t\t\t\t\tgqlImports.push('GraphQLInt', entityVar);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\t\tgqlImports.push('GraphQLString', entityVar);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\tgqlImports.push('GraphQLFloat', entityVar);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tgqlImports.push('GraphQLBoolean', entityVar);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t// tt-model basic scalars\n\t\t\t\t\t\tcase 'uInt':\n\t\t\t\t\t\t\tlet uIntScalar = f.createUniqueName('uIntScalar');\n\t\t\t\t\t\t\tttModelImports.push('uIntScalar', uIntScalar);\n\t\t\t\t\t\t\t_createBasicScalar(\n\t\t\t\t\t\t\t\tbScalarName,\n\t\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\t\tuIntScalar\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'uFloat':\n\t\t\t\t\t\t\tlet uFloatScalar =\n\t\t\t\t\t\t\t\tf.createUniqueName('uFloatScalar');\n\t\t\t\t\t\t\tttModelImports.push('uFloatScalar', uFloatScalar);\n\t\t\t\t\t\t\t_createBasicScalar(\n\t\t\t\t\t\t\t\tbScalarName,\n\t\t\t\t\t\t\t\tentityVar,\n\t\t\t\t\t\t\t\tuFloatScalar\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Unknown basic scalar: ${entity.name}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tlet neverCase: never = entity;\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t`Unexpected kind: ${ModelKind[neverCase.kind]}`\n\t\t\t\t\t);\n\t\t\t}\n\t\t\t// Entity resolved\n\t\t\tqueue.pop();\n\t\t}\n\t} catch (error: any) {\n\t\tthrow new Error(\n\t\t\t`GQL Compile Failed at ${_printStack()}.\\nCaused by: ${error?.stack ?? error\n\t\t\t}`\n\t\t);\n\t}\n\n\t//* Create block statement\n\tconst statementsBlock: ts.Statement[] = [];\n\t// Validation\n\tif (validationDeclarations.length > 0) {\n\t\tstatementsBlock.push(\n\t\t\tf.createVariableStatement(\n\t\t\t\tundefined,\n\t\t\t\tf.createVariableDeclarationList(validationDeclarations)\n\t\t\t)\n\t\t);\n\t}\n\t// Graphql schema\n\tif (graphqlDeclarations.length > 0) {\n\t\tstatementsBlock.push(\n\t\t\tf.createVariableStatement(\n\t\t\t\tundefined,\n\t\t\t\tf.createVariableDeclarationList(graphqlDeclarations)\n\t\t\t)\n\t\t);\n\t}\n\t//* Imports\n\tvar gqlImportsF: ts.ImportSpecifier[] = [];\n\tfor (let i = 0, len = gqlImports.length; i < len;) {\n\t\tgqlImportsF.push(\n\t\t\tf.createImportSpecifier(\n\t\t\t\tf.createIdentifier(gqlImports[i++] as string),\n\t\t\t\tgqlImports[i++] as ts.Identifier\n\t\t\t)\n\t\t);\n\t}\n\tvar ttImportsF: ts.ImportSpecifier[] = [];\n\tfor (let i = 0, len = ttModelImports.length; i < len;) {\n\t\tttImportsF.push(\n\t\t\tf.createImportSpecifier(\n\t\t\t\tf.createIdentifier(ttModelImports[i++] as string),\n\t\t\t\tttModelImports[i++] as ts.Identifier\n\t\t\t)\n\t\t);\n\t}\n\tconst imports: ts.ImportDeclaration[] = [\n\t\t// Graphql imports\n\t\tf.createImportDeclaration(\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tf.createImportClause(\n\t\t\t\tfalse,\n\t\t\t\tundefined,\n\t\t\t\tf.createNamedImports(gqlImportsF)\n\t\t\t),\n\t\t\tf.createStringLiteral('graphql')\n\t\t),\n\t\t// tt-model imports\n\t\tf.createImportDeclaration(\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tf.createImportClause(\n\t\t\t\tfalse,\n\t\t\t\tundefined,\n\t\t\t\tf.createNamedImports(ttImportsF)\n\t\t\t),\n\t\t\tf.createStringLiteral('tt-model')\n\t\t)\n\t];\n\t//* Resolve circles\n\tfor (let i = 0, len = mapCircles.length; i < len; ++i) {\n\t\tlet { entity, circles, varname } = mapCircles[i];\n\t\tswitch (entity.kind) {\n\t\t\tcase ModelKind.FORMATTED_INPUT_OBJECT:\n\t\t\tcase ModelKind.FORMATTED_OUTPUT_OBJECT:\n\t\t\t\tfor (let j = 0, jlen = circles.length; j < jlen; ++j) {\n\t\t\t\t\tlet field = circles[j] as\n\t\t\t\t\t\t| formattedInputField\n\t\t\t\t\t\t| formattedOutputField;\n\t\t\t\t\tstatementsBlock.push(\n\t\t\t\t\t\tf.createExpressionStatement(\n\t\t\t\t\t\t\tf.createBinaryExpression(\n\t\t\t\t\t\t\t\tf.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\tvarname,\n\t\t\t\t\t\t\t\t\tf.createIdentifier(\n\t\t\t\t\t\t\t\t\t\tfield.alias ?? field.name\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tf.createToken(ts.SyntaxKind.EqualsToken),\n\t\t\t\t\t\t\t\t_compileField(field)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase ModelKind.UNION:\n\t\t\t\tfor (let j = 0, jlen = circles.length; j < jlen; ++j) {\n\t\t\t\t\tlet ref = circles[j] as Reference;\n\t\t\t\t\tlet refNode = rootOutput.get(ref.name);\n\t\t\t\t\tif (refNode == null)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Missing entity \"${ref.name}\" for union \"${entity.name}\" at ${entity.fileName}`\n\t\t\t\t\t\t);\n\t\t\t\t\tlet refNodeVar = mapEntities.get(refNode);\n\t\t\t\t\tif (refNodeVar == null)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unexpected missing entity var \"${ref.name}\" for union \"${entity.name}\" at ${entity.fileName}`\n\t\t\t\t\t\t);\n\t\t\t\t\tstatementsBlock.push(\n\t\t\t\t\t\tf.createExpressionStatement(\n\t\t\t\t\t\t\tf.createCallExpression(\n\t\t\t\t\t\t\t\tf.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\tvarname,\n\t\t\t\t\t\t\t\t\tf.createIdentifier('push')\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t[refNodeVar]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tlet n: never = entity;\n\t\t}\n\t}\n\t//* Resolve validation circles\n\tfor (let i = 0, len = mapVldCircles.length; i < len; ++i) {\n\t\tlet { entity, varname, circles } = mapVldCircles[i];\n\t\tlet desc = mapVldEntities.get(entity)!;\n\t\tif (desc == null)\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected missing var for entity validation for: ${entity.name}`\n\t\t\t);\n\t\tfor (let j = 0, jlen = circles.length; j < jlen; ++j) {\n\t\t\tlet field = circles[j] as formattedInputField;\n\t\t\tlet vField = _compileValidateFields(\n\t\t\t\tentity as FormattedInputObject,\n\t\t\t\tfield\n\t\t\t);\n\t\t\tif (vField != null) {\n\t\t\t\t++desc.len;\n\t\t\t\tstatementsBlock.push(\n\t\t\t\t\tf.createExpressionStatement(\n\t\t\t\t\t\tf.createCallExpression(\n\t\t\t\t\t\t\tf.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\tvarname,\n\t\t\t\t\t\t\t\tf.createIdentifier('push')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[vField]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\t//* Add other imports\n\tvar importIt = srcImports.entries();\n\tconst importCreateObjects: ts.VariableDeclaration[] = [];\n\twhile (true) {\n\t\tlet n = importIt.next();\n\t\tif (n.done) break;\n\t\tlet [filename, mp] = n.value;\n\t\tlet sbIt = mp.entries();\n\t\tlet specifiers: ts.ImportSpecifier[] = [];\n\t\twhile (true) {\n\t\t\tlet n2 = sbIt.next();\n\t\t\tif (n2.done) break;\n\t\t\tlet [className, tmpVar] = n2.value;\n\n\t\t\t// Add import specifier\n\t\t\tif (tmpVar.isClass) {\n\t\t\t\tlet isp = f.createUniqueName(className);\n\t\t\t\tspecifiers.push(\n\t\t\t\t\tf.createImportSpecifier(f.createIdentifier(className), isp)\n\t\t\t\t);\n\t\t\t\t// Create var\n\t\t\t\timportCreateObjects.push(\n\t\t\t\t\tf.createVariableDeclaration(\n\t\t\t\t\t\ttmpVar.varName,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createNewExpression(isp, undefined, [])\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tspecifiers.push(\n\t\t\t\t\tf.createImportSpecifier(\n\t\t\t\t\t\tf.createIdentifier(className),\n\t\t\t\t\t\ttmpVar.varName\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// imports\n\t\timports.push(\n\t\t\tf.createImportDeclaration(\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tf.createImportClause(\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined,\n\t\t\t\t\tf.createNamedImports(specifiers)\n\t\t\t\t),\n\t\t\t\tf.createStringLiteral(\n\t\t\t\t\t_relative(targetSrcFilePath, filename.replace(/\\.ts$/, ''))\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\t//* Add return statement\n\tvar gqlSchema: { [k in keyof GraphQLSchemaConfig]: ts.Identifier } = {};\n\t// Query\n\tvar q: ts.Identifier | undefined = mapEntities.get(\n\t\trootOutput.get('Query')!\n\t);\n\tif (q != null) gqlSchema.query = q;\n\t// Mutation\n\tvar q: ts.Identifier | undefined = mapEntities.get(\n\t\trootOutput.get('Mutation')!\n\t);\n\tif (q != null) gqlSchema.mutation = q;\n\t// Subscription\n\tvar q: ts.Identifier | undefined = mapEntities.get(\n\t\trootOutput.get('Subscription')!\n\t);\n\tif (q != null) gqlSchema.subscription = q;\n\tstatementsBlock.push(\n\t\tf.createReturnStatement(\n\t\t\tf.createNewExpression(GraphQLSchema, undefined, [\n\t\t\t\t_serializeObject(gqlSchema)\n\t\t\t])\n\t\t)\n\t);\n\t//* Create vars for imported classes\n\tif (importCreateObjects.length)\n\t\tstatementsBlock.unshift(\n\t\t\tf.createVariableStatement(\n\t\t\t\tundefined,\n\t\t\t\tf.createVariableDeclarationList(importCreateObjects)\n\t\t\t)\n\t\t);\n\t//* RETURN\n\treturn {\n\t\timports,\n\t\tnode: f.createCallExpression(\n\t\t\tf.createParenthesizedExpression(\n\t\t\t\tf.createFunctionExpression(\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\t[],\n\t\t\t\t\tundefined,\n\t\t\t\t\tf.createBlock(statementsBlock, pretty)\n\t\t\t\t)\n\t\t\t),\n\t\t\tundefined,\n\t\t\t[]\n\t\t)\n\t};\n\t/** Create basic scalar */\n\tfunction _createBasicScalar(\n\t\tscalarName: string,\n\t\tscalarVar: ts.Identifier,\n\t\tscalarDescVar: ts.Identifier\n\t) {\n\t\tlet uIntConf: { [k in keyof GraphQLScalarTypeConfig<any, any>]: any } =\n\t\t{\n\t\t\tname: scalarName,\n\t\t\tparseValue: f.createPropertyAccessExpression(\n\t\t\t\tscalarDescVar,\n\t\t\t\tf.createIdentifier('parse')\n\t\t\t),\n\t\t\tserialize: f.createPropertyAccessExpression(\n\t\t\t\tscalarDescVar,\n\t\t\t\tf.createIdentifier('serialize')\n\t\t\t)\n\t\t};\n\t\t// if(comment!=null) uIntConf.description= comment;\n\t\tgraphqlDeclarations.push(\n\t\t\tf.createVariableDeclaration(\n\t\t\t\tscalarVar,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tf.createNewExpression(GraphQLScalarType, undefined, [\n\t\t\t\t\t_serializeObject(uIntConf)\n\t\t\t\t])\n\t\t\t)\n\t\t);\n\t}\n\t/** serialize object */\n\tfunction _serializeObject(\n\t\tobj: Record<\n\t\t\tstring,\n\t\t\tts.Expression | string | number | boolean | undefined\n\t\t>\n\t) {\n\t\tvar fieldArr: ts.ObjectLiteralElementLike[] = [];\n\t\tfor (let k in obj) {\n\t\t\tlet v = obj[k];\n\t\t\tif (v == null) v = f.createIdentifier('undefined');\n\t\t\telse if (typeof v === 'string') v = f.createStringLiteral(v);\n\t\t\telse if (typeof v === 'number') v = f.createNumericLiteral(v);\n\t\t\telse if (typeof v === 'boolean')\n\t\t\t\tv = v === true ? f.createTrue() : f.createFalse();\n\t\t\tfieldArr.push(f.createPropertyAssignment(f.createIdentifier(k), v));\n\t\t}\n\t\treturn f.createObjectLiteralExpression(fieldArr, pretty);\n\t}\n\t/** Generate method call */\n\tfunction _getMethodCall(method: MethodDescriptor, methodName?: string) {\n\t\tvar varId = _getLocalImport(method);\n\t\tmethodName ??= method.name!;\n\t\treturn f.createPropertyAccessExpression(\n\t\t\tvarId,\n\t\t\tmethod.isClass\n\t\t\t\t? f.createIdentifier(methodName)\n\t\t\t\t: f.createIdentifier(\n\t\t\t\t\tmethod.isStatic === true\n\t\t\t\t\t\t? methodName\n\t\t\t\t\t\t: `prototype.${methodName}`\n\t\t\t\t)\n\t\t);\n\t}\n\t/** Get import var from locale source */\n\tfunction _getLocalImport(method: MethodDescriptor) {\n\t\tvar fl = srcImports.get(method.fileName);\n\t\tif (fl == null) {\n\t\t\tfl = new Map();\n\t\t\tsrcImports.set(method.fileName, fl);\n\t\t}\n\t\tvar vr = fl.get(method.className);\n\t\tif (vr == null) {\n\t\t\tvr = {\n\t\t\t\tvarName: f.createUniqueName(method.className),\n\t\t\t\tisClass: method.isClass\n\t\t\t};\n\t\t\tfl.set(method.className, vr);\n\t\t}\n\t\treturn vr.varName;\n\t}\n\t/** Compile field */\n\tfunction _compileField(\n\t\tfield: formattedInputField | formattedOutputField\n\t): ts.Expression {\n\t\tif (field.kind === ModelKind.INPUT_FIELD) {\n\t\t\tlet obj: { [k in keyof GraphQLInputFieldConfig]: any } = {\n\t\t\t\ttype: _compileFieldPart(field, true)\n\t\t\t};\n\t\t\tif (field.defaultValue != null)\n\t\t\t\tobj.defaultValue = field.defaultValue;\n\t\t\tif (field.deprecated != null)\n\t\t\t\tobj.deprecationReason = field.deprecated;\n\t\t\tif (field.jsDoc.length > 0)\n\t\t\t\tobj.description = field.jsDoc.join('\\n');\n\t\t\treturn _serializeObject(obj);\n\t\t} else {\n\t\t\tlet obj: { [k in keyof GraphQLFieldConfig<any, any, any>]: any } = {\n\t\t\t\ttype: _compileFieldPart(field, false)\n\t\t\t};\n\t\t\tif (field.deprecated != null)\n\t\t\t\tobj.deprecationReason = field.deprecated;\n\t\t\tif (field.jsDoc.length > 0)\n\t\t\t\tobj.description = field.jsDoc.join('\\n');\n\t\t\tif (field.param != null && field.param.type != null) {\n\t\t\t\tlet ref = field.param.type;\n\t\t\t\tlet refNode = rootInput.get(ref.name);\n\t\t\t\tif (refNode == null)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected missing entity \"${ref.name\n\t\t\t\t\t\t}\" at ${_printStack()}`\n\t\t\t\t\t);\n\t\t\t\tif (refNode.kind !== ModelKind.FORMATTED_INPUT_OBJECT)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected kind \"${ModelKind[refNode.kind]}\" of ${field.name\n\t\t\t\t\t\t}. Expected \"FormattedInputObject\" at ${_printStack()}`\n\t\t\t\t\t);\n\t\t\t\tlet param: Record<string, any> = {};\n\t\t\t\tfor (\n\t\t\t\t\tlet i = 0, flds = refNode.fields, len = flds.length;\n\t\t\t\t\ti < len;\n\t\t\t\t\t++i\n\t\t\t\t) {\n\t\t\t\t\tlet f = flds[i];\n\t\t\t\t\tparam[f.alias ?? f.name] = _compileField(f);\n\t\t\t\t}\n\t\t\t\tobj.args = _serializeObject(param);\n\t\t\t}\n\t\t\tif (field.method != null) {\n\t\t\t\tobj.resolve = _wrapResolver(\n\t\t\t\t\t_getMethodCall(field.method),\n\t\t\t\t\tfield.param\n\t\t\t\t);\n\t\t\t} else if (field.alias != null) {\n\t\t\t\tobj.resolve = _wrapResolver(\n\t\t\t\t\tf.createFunctionExpression(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t'parent',\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tf.createKeywordTypeNode(\n\t\t\t\t\t\t\t\t\tts.SyntaxKind.AnyKeyword\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createBlock(\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tf.createReturnStatement(\n\t\t\t\t\t\t\t\t\tf.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\tf.createIdentifier('parent'),\n\t\t\t\t\t\t\t\t\t\tf.createIdentifier(field.name)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tpretty\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn _serializeObject(obj);\n\t\t}\n\t}\n\t/** Compile field's type or param */\n\tfunction _compileFieldPart(\n\t\tpart: formattedInputField | formattedOutputField | Reference | List,\n\t\tisInput: boolean\n\t) {\n\t\t// Get wrappers (List, Optional)\n\t\tlet wrappers: number[] = [];\n\t\t// let wrappers= field.required ? [1] : [];\n\t\twhile (part.kind !== ModelKind.REF) {\n\t\t\tif (part.kind === ModelKind.LIST) wrappers.push(0);\n\t\t\tif (part.required) wrappers.push(1);\n\t\t\tpart = part.type;\n\t\t\tif (part == null)\n\t\t\t\tthrow new Error(`Unexpected empty list! at: ${_printStack()}`);\n\t\t}\n\t\tvar refNode = isInput\n\t\t\t? rootInput.get(part.name)\n\t\t\t: rootOutput.get(part.name);\n\t\tif (refNode == null)\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected missing entity \"${part.name}\" at ${_printStack()}`\n\t\t\t);\n\t\tvar refNodeVar: ts.Expression | undefined = mapEntities.get(refNode);\n\t\tif (refNodeVar == null)\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected missing entity var \"${part.name\n\t\t\t\t}\" at ${_printStack()}`\n\t\t\t);\n\t\t// Add wrappers: List & NonNullable\n\t\twrappers.reverse();\n\t\tfor (let i = 0, len = wrappers.length; i < len; ++i) {\n\t\t\tif (wrappers[i] === 0)\n\t\t\t\trefNodeVar = f.createNewExpression(GraphQLList, undefined, [\n\t\t\t\t\trefNodeVar\n\t\t\t\t]);\n\t\t\telse\n\t\t\t\trefNodeVar = f.createNewExpression(GraphQLNonNull, undefined, [\n\t\t\t\t\trefNodeVar\n\t\t\t\t]);\n\t\t}\n\t\treturn refNodeVar;\n\t}\n\t/** Generate method */\n\tfunction _createMethod(name: string, args: string[], body: ts.Statement[]) {\n\t\tvar params = [];\n\t\tfor (let i = 0, len = args.length; i < len; ++i) {\n\t\t\tparams.push(\n\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\tf.createIdentifier(args[i]),\n\t\t\t\t\tundefined,\n\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\tundefined\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn f.createMethodDeclaration(\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tf.createIdentifier(name),\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tparams,\n\t\t\tundefined,\n\t\t\tf.createBlock(body, pretty)\n\t\t);\n\t}\n\t/** Print stack */\n\tfunction _printStack() {\n\t\tvar stack = [];\n\t\tfor (let i = 0, len = queue.length; i < len; ++i) {\n\t\t\tlet entity = queue[i].entity;\n\t\t\tlet entityName = (entity as FormattedInputNode)?.name;\n\t\t\tif (entityName != null)\n\t\t\t\tstack.push(`\\n\\t=> ${entityName}:\\t${ModelKind[entity.kind]}`);\n\t\t}\n\t\treturn 'STACK: ' + stack.join('');\n\t}\n\t/** Generate unique entity name */\n\tfunction _getEntityName(entityName: string): string {\n\t\tif (namesSet.has(entityName)) {\n\t\t\tlet i = 1;\n\t\t\tlet t = entityName;\n\t\t\tdo {\n\t\t\t\tentityName = `${t}_${i++}`;\n\t\t\t} while (namesSet.has(entityName));\n\t\t}\n\t\tnamesSet.add(entityName);\n\t\treturn entityName;\n\t}\n\t/** Compile validation fields */\n\ttype compileTargetTypes = formattedInputField | List | Reference;\n\tfunction _compileValidateFields(\n\t\tentity: FormattedInputObject,\n\t\tfield: formattedInputField\n\t): ts.Expression | undefined {\n\t\tvar fieldProperties: ts.ObjectLiteralElementLike[] = [];\n\t\t//* Asserts\n\t\tlet assertTs: ts.MethodDeclaration | undefined;\n\t\tif (\n\t\t\tfield.asserts != null &&\n\t\t\t(assertTs = compileAsserts(\n\t\t\t\t`${entity.name}.${field.name}`,\n\t\t\t\tfield.asserts,\n\t\t\t\tfield.type,\n\t\t\t\tf,\n\t\t\t\tpretty\n\t\t\t)) != null\n\t\t) {\n\t\t\tfieldProperties.push(assertTs);\n\t\t}\n\t\t//* Input field validation\n\t\tif (field.validate != null) {\n\t\t\tfieldProperties.push(\n\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t'input',\n\t\t\t\t\t_getMethodCall(field.validate)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\t//* Sub document\n\t\t// Resolve list\n\t\t/** Create step of all embed lists & store if each step has \"required\" flag */\n\t\tlet lstFlags: boolean[] = [];\n\t\tlet child: compileTargetTypes = field.type;\n\t\twhile (child.kind === ModelKind.LIST) {\n\t\t\tlstFlags.push(child.required);\n\t\t\tchild = child.type;\n\t\t\tif (child == null)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Validation>> Unexpected empty list! at ${entity.name}.${field.name}`\n\t\t\t\t);\n\t\t}\n\t\t// Resolve reference\n\t\tlet refNode = rootInput.get(child.name);\n\t\tif (refNode == null)\n\t\t\tthrow new Error(\n\t\t\t\t`Missing entity: ${child.name}. Found at: ${entity.name}.${field.name}`\n\t\t\t);\n\t\tlet refNodeTs: ts.Expression | undefined =\n\t\t\tmapVldEntities.get(refNode)?.var;\n\t\tif (refNodeTs != null) {\n\t\t\tlstFlags.reverse();\n\t\t\tfor (let i = 0, len = lstFlags.length; i < len; ++i) {\n\t\t\t\trefNodeTs = f.createObjectLiteralExpression(\n\t\t\t\t\t[\n\t\t\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t\t\t'kind',\n\t\t\t\t\t\t\tf.createNumericLiteral(ModelKind.LIST)\n\t\t\t\t\t\t),\n\t\t\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t\t\t'required',\n\t\t\t\t\t\t\tlstFlags[i] ? f.createTrue() : f.createFalse()\n\t\t\t\t\t\t),\n\t\t\t\t\t\tf.createPropertyAssignment('type', refNodeTs)\n\t\t\t\t\t],\n\t\t\t\t\tpretty\n\t\t\t\t);\n\t\t\t}\n\t\t\tfieldProperties.push(f.createPropertyAssignment('type', refNodeTs));\n\t\t}\n\n\t\t//* RETURN RESULT\n\t\tlet refNodeKind = refNode.kind;\n\t\tif (\n\t\t\tfieldProperties.length > 0 ||\n\t\t\tfield.alias != null ||\n\t\t\trefNodeKind === ModelKind.BASIC_SCALAR ||\n\t\t\trefNodeKind === ModelKind.ENUM ||\n\t\t\trefNodeKind === ModelKind.SCALAR ||\n\t\t\trefNodeKind === ModelKind.UNION\n\t\t) {\n\t\t\tfieldProperties.push(\n\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t'kind',\n\t\t\t\t\tf.createNumericLiteral(ModelKind.INPUT_FIELD)\n\t\t\t\t),\n\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t'name',\n\t\t\t\t\tf.createStringLiteral(field.name)\n\t\t\t\t),\n\t\t\t\tf.createPropertyAssignment(\n\t\t\t\t\t'targetName',\n\t\t\t\t\tf.createStringLiteral(field.alias ?? field.name)\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn f.createObjectLiteralExpression(fieldProperties, pretty);\n\t\t}\n\t}\n\t/** Generate resolver with validation & input wrapper */\n\tfunction _wrapResolver(\n\t\tresolveCb: ts.Expression,\n\t\tparam?: Param | undefined\n\t): ts.Expression {\n\t\t//* Resolve input entity\n\t\tlet inputEntity: FormattedInputObject | undefined;\n\t\tif (param != null && param.type != null) {\n\t\t\tinputEntity = rootInput.get(\n\t\t\t\tparam.type.name\n\t\t\t) as FormattedInputObject;\n\t\t\tif (inputEntity.kind !== ModelKind.FORMATTED_INPUT_OBJECT)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expected kind \"FORMATTED_INPUT_OBJECT\", received \"${ModelKind[inputEntity.kind]\n\t\t\t\t\t}\". ${_printStack()}`\n\t\t\t\t);\n\t\t}\n\t\t//* Resolver\n\t\tif (ts.isFunctionLike(resolveCb)) {\n\t\t} else {\n\t\t\t//* Input validation\n\t\t\tlet blk: ts.Statement[] = [];\n\t\t\tlet vldInfo = inputEntity && mapVldEntities.get(inputEntity);\n\t\t\t// Validate input\n\t\t\tif (vldInfo?.len! > 0) {\n\t\t\t\tblk.push(\n\t\t\t\t\tf.createExpressionStatement(\n\t\t\t\t\t\tf.createBinaryExpression(\n\t\t\t\t\t\t\tf.createIdentifier('args'),\n\t\t\t\t\t\t\tf.createToken(ts.SyntaxKind.EqualsToken),\n\t\t\t\t\t\t\tf.createAwaitExpression(\n\t\t\t\t\t\t\t\tf.createCallExpression(validateObj, undefined, [\n\t\t\t\t\t\t\t\t\tvldInfo!.var,\n\t\t\t\t\t\t\t\t\tf.createIdentifier('parent'),\n\t\t\t\t\t\t\t\t\tf.createIdentifier('args'),\n\t\t\t\t\t\t\t\t\tf.createIdentifier('ctx'),\n\t\t\t\t\t\t\t\t\tf.createIdentifier('info')\n\t\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Return resolver value\n\t\t\tblk.push(\n\t\t\t\tf.createExpressionStatement(f.createIdentifier('//@ts-ignore')),\n\t\t\t\tf.createReturnStatement(\n\t\t\t\t\tf.createCallExpression(resolveCb, undefined, [\n\t\t\t\t\t\tf.createIdentifier('parent'),\n\t\t\t\t\t\tf.createIdentifier('args'),\n\t\t\t\t\t\tf.createIdentifier('ctx'),\n\t\t\t\t\t\tf.createIdentifier('info')\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t);\n\t\t\tresolveCb = f.createFunctionExpression(\n\t\t\t\tvldInfo?.len! > 0\n\t\t\t\t\t? [f.createModifier(ts.SyntaxKind.AsyncKeyword)]\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t[\n\t\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createIdentifier('parent'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t),\n\t\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createIdentifier('args'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t),\n\t\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createIdentifier('ctx'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t),\n\t\t\t\t\tf.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createIdentifier('info'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t)\n\t\t\t\t],\n\t\t\t\tundefined,\n\t\t\t\tf.createBlock(blk, pretty)\n\t\t\t);\n\t\t}\n\t\t//* Return\n\t\treturn resolveCb;\n\t\t// f.createAsExpression(\n\t\t// \tresolveCb,\n\t\t// \tf.createTypeReferenceNode(GraphQLFieldResolver, [\n\t\t// \t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n\t\t// \t\tf.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)\n\t\t// \t])\n\t\t// );\n\t}\n}\n\n/** Compiler response */\nexport interface GqlCompilerResp {\n\timports: ts.ImportDeclaration[];\n\tnode: ts.CallExpression;\n}\n/** Queue interface */\ninterface QueueInterface {\n\tentity:\n\t| FormattedOutputNode\n\t| FormattedInputNode\n\t| formattedInputField\n\t| formattedOutputField\n\t| FieldType;\n\tisInput: boolean;\n\t/** Current field index (plain_object) */\n\tindex: number;\n\t/** Fields with circles */\n\tcircles:\n\t| (formattedInputField | formattedOutputField | Reference)[]\n\t| undefined;\n\t// /** Parent node in case of Plain_object */\n\t// parent?:\t\tQueueInterface\n}\n\n/** Map circle entities */\ninterface CircleEntities {\n\tentity: FormattedInputObject | FormattedOutputObject | Union;\n\tvarname: ts.Identifier;\n\t/** Fields with circles */\n\tcircles: (formattedInputField | formattedOutputField | Reference)[];\n}\n\n/** Relative path */\nfunction _relative(from: string, to: string) {\n\tvar p = relative(from, to);\n\tp = p.replace(/\\\\/g, '/');\n\tvar c = p.charAt(0);\n\tif (c !== '.' && c !== '/') p = './' + p;\n\treturn p;\n}\n\ninterface ParamItem {\n\t/** Validation entity variable */\n\tvar: ts.Identifier;\n\t/** Count of validated fields */\n\tlen: number;\n\t/** Has entity validation */\n\t//TODO complete this\n}\n"]}