diff --git a/.gitignore b/.gitignore index aa59ab8..3da4c8c 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ typings/ haxelib/gql2hx.zip .tmp +.last_build.json diff --git a/.vscode/debug.hxml b/.vscode/debug.hxml index c8926d4..ed078e9 100644 --- a/.vscode/debug.hxml +++ b/.vscode/debug.hxml @@ -9,6 +9,8 @@ -resource test.gql@injected_gql +-lib hxnodejs + # Test -debug -cp . diff --git a/README-DEBUG.md b/README-DEBUG.md new file mode 100644 index 0000000..a6f4ea5 --- /dev/null +++ b/README-DEBUG.md @@ -0,0 +1,15 @@ +#### Debug + +``` +# vscode from project root +code -n . +``` + +The 'Launch via NPM' debug configuration will run the code in test/manual_debug/Test.hx + +You can change the GQL you are attempting to generate code for by linking `test/manual_debug/test.gql` to the desired file. This GQL text is available as a Resource in Haxe land by the hidden build file `${projectRoot}.vscode/debug.hxml` + +``` +# snip from debug.html .. note test.gql maps to the symbol is injected_gql +-resource test.gql@injected_gql +``` \ No newline at end of file diff --git a/bit.yaml b/bit.yaml new file mode 100644 index 0000000..c04c0a4 --- /dev/null +++ b/bit.yaml @@ -0,0 +1,7 @@ +--- +name: haxe-graphql +build_ver: BW2 +builder: NullBuilder +dependencies: + bit: + - gql2hx diff --git a/package.json b/package.json index 14e7610..ed4c71b 100644 --- a/package.json +++ b/package.json @@ -2,5 +2,8 @@ "scripts": { "build": "cd test/manual_debug && haxe ../../.vscode/debug.hxml", "debug": "cd test/manual_debug && npm run build && node --nolazy --inspect-brk=13729 test.js" + }, + "dependencies": { + "commander": "^11.1.0" } } diff --git a/proj/gql2hx-npm/bit.yaml b/proj/gql2hx-npm/bit.yaml new file mode 100644 index 0000000..ed73324 --- /dev/null +++ b/proj/gql2hx-npm/bit.yaml @@ -0,0 +1,8 @@ +--- +name: gql2hx +build_ver: BW2 +builder: ShellCmdBuilder +type: in-house +steps: + - cmd: npm install + - cmd: npm run-script build diff --git a/proj/gql2hx-npm/package-lock.json b/proj/gql2hx-npm/package-lock.json index f9a1428..98275d0 100644 --- a/proj/gql2hx-npm/package-lock.json +++ b/proj/gql2hx-npm/package-lock.json @@ -1,29 +1,47 @@ { "name": "gql2hx", "version": "0.0.23", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@types/node": { + "packages": { + "": { + "name": "gql2hx", + "version": "0.0.23", + "license": "MIT", + "dependencies": { + "commander": "^2.15.1", + "graphql": "^14.3.0" + }, + "bin": { + "gql2hx": "dist/index.js" + }, + "devDependencies": { + "@types/node": "^10.1.2" + } + }, + "node_modules/@types/node": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.1.3.tgz", "integrity": "sha512-GiCx7dRvta0hbxXoJFAUxz+CKX6bZSCKjM5slq2vPp/5zwK01T4ibYZkGr6EN4F2QmxDQR76/ZHg6q+7iFWCWw==", "dev": true }, - "commander": { + "node_modules/commander": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" }, - "graphql": { + "node_modules/graphql": { "version": "14.3.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.3.0.tgz", "integrity": "sha512-MdfI4v7kSNC3NhB7cF8KNijDsifuWO2XOtzpyququqaclO8wVuChYv+KogexDwgP5sp7nFI9Z6N4QHgoLkfjrg==", - "requires": { + "dependencies": { "iterall": "^1.2.2" + }, + "engines": { + "node": ">= 6.x" } }, - "iterall": { + "node_modules/iterall": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz", "integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA==" diff --git a/proj/hxgen/src/graphql/HaxeGenerator.hx b/proj/hxgen/src/graphql/HaxeGenerator.hx index 81486e3..eb3fb8d 100644 --- a/proj/hxgen/src/graphql/HaxeGenerator.hx +++ b/proj/hxgen/src/graphql/HaxeGenerator.hx @@ -512,9 +512,15 @@ class HaxeGenerator case TBasic(tname) | TScalar(tname) | TEnum(tname, _): error('${ err_prefix }Expecting type ${ tname } to have field ${ name }!', true); case TStruct(tname, fields): - var field = fields[name]; - if (field==null) error('${ err_prefix }Expecting type ${ tname } to have field ${ name }!', true); - if (path.length==0) { + var field:GQLFieldType; + // Issue 43 - support __typename instrinsic + if(name == '__typename') { + field = { type:TPath('String'), is_array:false, is_optional:true }; + } else { + field = fields[name]; + } + if (field==null) error('${ err_prefix }Expecting type ${ tname } to have field ${ name }!', true); + if (path.length==0) { resolve_type(field.type, err_prefix); return field; } @@ -764,7 +770,6 @@ class HaxeGenerator next_type_path.push(name); var resolved = resolve_field(next_type_path, gt_info); var type = resolve_type(resolved.type); - switch type { case TBasic(tname) | TScalar(tname) | TEnum(tname, _): if (has_sub_selections) { @@ -776,14 +781,17 @@ class HaxeGenerator error('Must specify sub-fields of ${ tname } at ${ type_path.join(".") } of operation ${ gt_info.debug_name }', true); } if (is_union(tname)) { - if (field_node.selectionSet.selections.find(function(sn) return sn.kind==Kind.FIELD)!=null) { + if (field_node.selectionSet.selections.find(function(sn) { + // Issue 43 - support __typename instrinsic + return sn.kind==Kind.FIELD && Reflect.field(cast sn, 'name').value!='__typename'; + })!=null) { error('Can only specify fragment selections of union ${ tname } at ${ type_path.join(".") } of operation ${ gt_info.debug_name }', true); } } var sub_type_name = (depth==0 && StringTools.endsWith(type_name, OP_OUTER_SUFFIX)) ? StringTools.replace(type_name, OP_OUTER_SUFFIX, OP_INNER_SUFFIX) : type_name+DEFAULT_SEPARATOR+name; - + var sub_type = generate_type_based_on_selection_set(sub_type_name, gt_info, field_node.selectionSet, tname, depth+1); var f = { type:null, is_array:resolved.is_array, is_optional:resolved.is_optional }; fields[alias] = f; @@ -809,7 +817,7 @@ class HaxeGenerator } else { return _types_by_name[type_name]; } - + } // Per the discussion at https://github.com/facebook/graphql/issues/204, the operation @@ -876,7 +884,8 @@ abstract ID(String) to String from String {\n // Relaxed safety -- allow implic for (name in _types_by_name.keys()) { if (_basic_types.indexOf(name)>=0) continue; var type = _types_by_name[name]; - stdout_writer.append( GQLTypeTools.type_to_string(type) ); + // Issue #43 - inject type map so we can use __typename for unions + stdout_writer.append( GQLTypeTools.type_to_string(type, _types_by_name) ); stdout_writer.append(''); } @@ -967,12 +976,11 @@ class GQLTypeTools var field = { name:field_name, kind:FVar(ct, null), meta:[], pos:FAKE_POS }; if (gql_f.is_optional) field.meta.push({ name:":optional", pos:FAKE_POS }); return field; - case TAnon(any): throw 'Non-struct types are not supported in TAnon: ${ any }'; } } - public static function type_to_string(td:GQLTypeDefinition):String { + public static function type_to_string(td:GQLTypeDefinition, types_by_name:StringMapAA):String { var p = new CustomPrinter(" ", true); switch td { case TBasic(tname): return ''; @@ -991,23 +999,79 @@ class GQLTypeTools return p.printTypeDefinition( haxe_td ); case TUnion(tname, type_paths): var writer = new StringWriter(); - var union_types_note = type_paths.map(function(t) return t).join(" | "); - writer.append('/* union '+tname+' = ${ union_types_note } */'); - writer.append('abstract '+tname+'(Dynamic) {'); - for (type_name in type_paths) { - writer.append(' @:from static inline function from${ type_name }(v:${ type_name }):${ tname } return cast v;'); - var as_name = type_name; - var sep:String = HaxeGenerator.UNION_SELECTION_SEPARATOR; - if (as_name.indexOf(sep)>=0) { - as_name = as_name.substr(as_name.indexOf(sep)+sep.length); - } - writer.append(' public inline function as${ HaxeGenerator.DEFAULT_SEPARATOR }${ as_name }():${ type_name } return cast this;'); + if(union_has_typename(types_by_name, type_paths)) { + generate_union_with_typename(tname, type_paths, types_by_name, writer); + } else { + generate_union(tname, type_paths, types_by_name, writer); } - writer.append('}'); return writer.toString(); } } + private static function generate_union_with_typename(tname:String, type_paths:Array, types_by_name:StringMapAA, writer:StringWriter) { + + // Generate the enum definition + var enum_val_names= []; + var enum_vals = type_paths.map(function(type_path) { + var r = ~/(ON_.*$)/; + r.match(type_path); + var name = r.matched(1); + enum_val_names.push(name); + return {name:'${name}(v:${type_path});'}; + }); + var union_enum_template_str = + 'enum ${ tname }Enum {\n::foreach enum_vals:: ::name::\n::end::}'; + var enum_template = new haxe.Template(union_enum_template_str); + var union_enum_str = enum_template.execute({enum_vals:enum_vals}); + writer.append(union_enum_str); + var union_types_note = type_paths.map(function(t) return t).join(" | "); + writer.append('/* union '+tname+' = ${ union_types_note } */'); + writer.append('abstract '+tname+'(Dynamic) {'); + + // Generate the tname abstract with the as_enum() method + var paths = []; + for(i in 0...type_paths.length) { + paths.push({index:i, path:type_paths[i], enum_val_name:enum_val_names[i]}); + } + var as_enum_template_str = ' public function as_enum():::tname::Enum { + var re = new EReg(this.__typename, ""); + ::foreach paths::if(re.match("::path::")) { return ::enum_val_name::(this);} + ::end::throw "invalid type"; + }'; + var as_enum_template = new haxe.Template(as_enum_template_str); + var as_enum_str = as_enum_template.execute({paths:paths, tname:tname}); + writer.append(as_enum_str); + writer.append('}'); + } + + private static function generate_union(tname:String, type_paths:Array, types_by_name:StringMapAA, writer:StringWriter) { + var union_types_note = type_paths.map(function(t) return t).join(" | "); + writer.append('/* union '+tname+' = ${ union_types_note } */'); + writer.append('abstract '+tname+'(Dynamic) {'); + for (type_name in type_paths) { + writer.append(' @:from static inline function from${ type_name }(v:${ type_name }):${ tname } return cast v;'); + var as_name = type_name; + var sep:String = HaxeGenerator.UNION_SELECTION_SEPARATOR; + if (as_name.indexOf(sep)>=0) { + as_name = as_name.substr(as_name.indexOf(sep)+sep.length); + } + writer.append(' public inline function as${ HaxeGenerator.DEFAULT_SEPARATOR }${ as_name }():${ type_name } return cast this;'); + } + writer.append('}'); + return writer.toString(); + } + + private static function union_has_typename(types_by_name:StringMapAA, type_paths:Array) { + // __typename on the union is reflected in all the type_paths so we only have to check the first one + var union_type = types_by_name[type_paths[0]]; + switch union_type { + case TStruct(name, fields): + return fields.exists('__typename'); + default: + return false; + } + } + private static var FAKE_POS = { min:0, max:0, file:'Untitled' }; } diff --git a/proj/webdemo/gql2hx_demo.js b/proj/webdemo/gql2hx_demo.js index ec56782..b1fddda 100644 --- a/proj/webdemo/gql2hx_demo.js +++ b/proj/webdemo/gql2hx_demo.js @@ -1,3 +1 @@ -(function(e){"use strict";e["graphql"]=e["graphql"]||{};var t=function(){return K.__string_rec(this,"")},r=r||{},n;function i(e,t){var r=Object.create(e);for(var n in t)r[n]=t[n];if(t.toString!==Object.prototype.toString)r.toString=t.toString;return r}var a=e["Demo"]=function(){};a.__name__=true;a.main=function(){};a.parse=function(e){var t=new b(e,{noLocation:true});return t.document};a.hxgen=function(e){return c.parse(e)};var s=function(e,t){this.r=new RegExp(e,t.split("u").join(""))};s.__name__=true;s.prototype={split:function(e){var t="#__delim__#";return e.replace(this.r,t).split(t)}};var o=function(){};o.__name__=true;o.cca=function(e,t){var r=e.charCodeAt(t);if(r!=r){return undefined}return r};o.substr=function(e,t,r){if(r==null){r=e.length}else if(r<0){if(t==0){r=e.length+r}else{return""}}return e.substr(t,r)};o.remove=function(e,t){var r=e.indexOf(t);if(r==-1){return false}e.splice(r,1);return true};o.iter=function(e){return{cur:0,arr:e,hasNext:function(){return this.cur=r){return o.substr(e,n-r,r)==t}else{return false}};h.replace=function(e,t,r){return e.split(t).join(r)};var p=function(e,t){if(t==null){t=false}if(e==null){e=" "}this.tabs="";this.fieldDelimiter=t?",":";";this.shortTypedefs=t;this.tabString=e};p.__name__=true;p.prototype={printUnop:function(e){switch(e._hx_index){case 0:return"++";case 1:return"--";case 2:return"!";case 3:return"-";case 4:return"~"}},printBinop:function(e){switch(e._hx_index){case 0:return"+";case 1:return"*";case 2:return"/";case 3:return"-";case 4:return"=";case 5:return"==";case 6:return"!=";case 7:return">";case 8:return">=";case 9:return"<";case 10:return"<=";case 11:return"&";case 12:return"|";case 13:return"^";case 14:return"&&";case 15:return"||";case 16:return"<<";case 17:return">>";case 18:return">>>";case 19:return"%";case 20:var t=e.op;return this.printBinop(t)+"=";case 21:return"...";case 22:return"=>";case 23:return"in"}},escapeString:function(e,t){return t+h.replace(h.replace(h.replace(h.replace(e,"\n","\\n")," ","\\t"),"'","\\'"),'"','\\"')+t},printString:function(e){return this.escapeString(e,'"')},printConstant:function(e){switch(e._hx_index){case 0:var t=e.v;return t;case 1:var r=e.f;return r;case 2:var n=e.s;return this.printString(n);case 3:var i=e.s;return i;case 4:var a=e.opt;var s=e.r;return"~/"+s+"/"+a}},printTypeParam:function(e){switch(e._hx_index){case 0:var t=e.t;return this.printComplexType(t);case 1:var r=e.e;return this.printExpr(r)}},printTypePath:function(e){return(e.pack.length>0?e.pack.join(".")+".":"")+e.name+(e.sub!=null?"."+e.sub:"")+(e.params==null?"":e.params.length>0?"<"+e.params.map(G(this,this.printTypeParam)).join(", ")+">":"")},printComplexType:function(e){var t=this;switch(e._hx_index){case 0:var r=e.p;return this.printTypePath(r);case 1:var n=e.ret;var i=e.args;var a=function(e){if(e._hx_index==1){return"("+t.printComplexType(e)+")"}else{return t.printComplexType(e)}};return(i.length>0?i.map(a).join(" -> "):"Void")+" -> "+this.printComplexType(n);case 2:var s=e.fields;var o=[];var u=0;while(u "+p.map(G(this,this.printTypePath)).join(" >, ")+", "+h.map(G(this,this.printField)).join(", ")+" }";case 5:var c=e.t;return"?"+this.printComplexType(c);default:return""}},printMetadata:function(e){return"@"+e.name+(e.params!=null&&e.params.length>0?"("+this.printExprs(e.params,", ")+")":"")},printAccess:function(e){switch(e._hx_index){case 0:return"public";case 1:return"private";case 2:return"static";case 3:return"override";case 4:return"dynamic";case 5:return"inline";case 6:return"macro";case 7:return"final";case 8:return"extern"}},printField:function(e){var t=this.shortTypedefs&&e.kind._hx_index==0;var r=e.meta!=null&&e.meta.length>0&&u.exists(e.meta,function(e){return e.name==":optional"});var n=e.meta.filter(function(e){if(t){return e.name!=":optional"}else{return false}});var i=(e.doc!=null&&e.doc!=""?"/**\n"+this.tabs+this.tabString+h.replace(e.doc,"\n","\n"+this.tabs+this.tabString)+"\n"+this.tabs+"**/\n"+this.tabs:"")+(n!=null&&n.length>0?n.map(G(this,this.printMetadata)).join("\n"+this.tabs)+("\n"+this.tabs):"")+(e.access!=null&&e.access.length>0?e.access.map(G(this,this.printAccess)).join(" ")+" ":"");var a=e.kind;var s;switch(a._hx_index){case 0:var o=a.e;var _=a.t;s=this.shortTypedefs?""+(r?"?":"")+e.name+this.opt(_,G(this,this.printComplexType)," : ")+this.opt(o,G(this,this.printExpr)," = "):"var "+e.name+this.opt(_,G(this,this.printComplexType)," : ")+this.opt(o,G(this,this.printExpr)," = ");break;case 1:var l=a.f;s="function "+e.name+this.printFunction(l);break;case 2:var p=a.e;var c=a.t;var f=a.set;var v=a.get;s="var "+e.name+"("+v+", "+f+")"+this.opt(c,G(this,this.printComplexType)," : ")+this.opt(p,G(this,this.printExpr)," = ");break}return i+s},printTypeParamDecl:function(e){return e.name+(e.params!=null&&e.params.length>0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+(e.constraints!=null&&e.constraints.length>0?":("+e.constraints.map(G(this,this.printComplexType)).join(", ")+")":"")},printFunctionArg:function(e){return(e.opt?"?":"")+e.name+this.opt(e.type,G(this,this.printComplexType),":")+this.opt(e.value,G(this,this.printExpr)," = ")},printFunction:function(e){return(e.params==null?"":e.params.length>0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+"("+e.args.map(G(this,this.printFunctionArg)).join(", ")+")"+this.opt(e.ret,G(this,this.printComplexType),":")+this.opt(e.expr,G(this,this.printExpr)," ")},printVar:function(e){return e.name+this.opt(e.type,G(this,this.printComplexType),":")+this.opt(e.expr,G(this,this.printExpr)," = ")},printExpr:function(e){var t=this;if(e==null){return"#NULL"}else{var r=e.expr;switch(r._hx_index){case 0:var n=r.c;return this.printConstant(n);case 1:var i=r.e2;var a=r.e1;return""+this.printExpr(a)+"["+this.printExpr(i)+"]";case 2:var s=r.e2;var o=r.e1;var u=r.op;return""+this.printExpr(o)+" "+this.printBinop(u)+" "+this.printExpr(s);case 3:var _=r.field;var l=r.e;return""+this.printExpr(l)+"."+_;case 4:var h=r.e;return"("+this.printExpr(h)+")";case 5:var p=r.fields;return"{ "+p.map(function(e){return""+e.field+" : "+t.printExpr(e.expr)}).join(", ")+" }";case 6:var c=r.values;return"["+this.printExprs(c,", ")+"]";case 7:var f=r.params;var v=r.e;return""+this.printExpr(v)+"("+this.printExprs(f,", ")+")";case 8:var m=r.params;var d=r.t;return"new "+this.printTypePath(d)+"("+this.printExprs(m,", ")+")";case 9:switch(r.postFix){case false:var x=r.e;var g=r.op;return this.printUnop(g)+this.printExpr(x);case true:var y=r.e;var T=r.op;return this.printExpr(y)+this.printUnop(T)}break;case 10:var k=r.vars;return"var "+k.map(G(this,this.printVar)).join(", ");case 11:var E=r.f;var S=r.name;if(S!=null){return"function "+S+this.printFunction(E)}else{var b=r.f;return"function"+this.printFunction(b)}break;case 12:if(r.exprs.length==0){return"{ }"}else{var D=r.exprs;var w=this.tabs;this.tabs+=this.tabString;var O="{\n"+this.tabs+this.printExprs(D,";\n"+this.tabs);this.tabs=w;return O+(";\n"+this.tabs+"}")}break;case 13:var N=r.expr;var C=r.it;return"for ("+this.printExpr(C)+") "+this.printExpr(N);case 14:if(r.eelse==null){var F=r.econd;var A=r.eif;return"if ("+this.printExpr(F)+") "+this.printExpr(A)}else{var I=r.econd;var R=r.eif;var P=r.eelse;return"if ("+this.printExpr(I)+") "+this.printExpr(R)+" else "+this.printExpr(P)}break;case 15:switch(r.normalWhile){case false:var j=r.econd;var U=r.e;return"do "+this.printExpr(U)+" while ("+this.printExpr(j)+")";case true:var B=r.econd;var L=r.e;return"while ("+this.printExpr(B)+") "+this.printExpr(L)}break;case 16:var V=r.edef;var K=r.cases;var M=r.e;var q=this.tabs;this.tabs+=this.tabString;var X="switch "+this.printExpr(M)+" {\n"+this.tabs+K.map(function(e){return"case "+t.printExprs(e.values,", ")+(e.guard!=null?" if ("+t.printExpr(e.guard)+"):":":")+(e.expr!=null?t.opt(e.expr,G(t,t.printExpr))+";":"")}).join("\n"+this.tabs);if(V!=null){X+="\n"+this.tabs+"default:"+(V.expr==null?"":this.printExpr(V)+";")}this.tabs=q;return X+("\n"+this.tabs+"}");case 17:var Q=r.catches;var W=r.e;return"try "+this.printExpr(W)+Q.map(function(e){return" catch("+e.name+":"+t.printComplexType(e.type)+") "+t.printExpr(e.expr)}).join("");case 18:var H=r.e;return"return"+this.opt(H,G(this,this.printExpr)," ");case 19:return"break";case 20:return"continue";case 21:var J=r.e;return"untyped "+this.printExpr(J);case 22:var Y=r.e;return"throw "+this.printExpr(Y);case 23:var $=r.t;var z=r.e;if($!=null){return"cast("+this.printExpr(z)+", "+this.printComplexType($)+")"}else{var Z=r.e;return"cast "+this.printExpr(Z)}break;case 24:var ee=r.e;return"#DISPLAY("+this.printExpr(ee)+")";case 25:var te=r.t;return"#DISPLAY("+this.printTypePath(te)+")";case 26:var re=r.eelse;var ne=r.eif;var ie=r.econd;return""+this.printExpr(ie)+" ? "+this.printExpr(ne)+" : "+this.printExpr(re);case 27:var ae=r.t;var se=r.e;return"("+this.printExpr(se)+" : "+this.printComplexType(ae)+")";case 28:var oe=r.e;var ue=r.s;return this.printMetadata(ue)+" "+this.printExpr(oe)}}},printExprs:function(e,t){return e.map(G(this,this.printExpr)).join(t)},printExtension:function(e,t){return"{\n"+this.tabs+">"+e.map(G(this,this.printTypePath)).join(",\n"+this.tabs+">")+","+(t.length>0?"\n"+this.tabs+t.map(G(this,this.printField)).join(";\n"+this.tabs)+";\n}":"\n}")},printStructure:function(e){if(e.length==0){return"{ }"}else{return"{\n"+this.tabs+e.map(G(this,this.printField)).join(this.fieldDelimiter+("\n"+this.tabs))+";\n}"}},printTypeDefinition:function(e,t){if(t==null){t=true}var r=this.tabs;this.tabs=this.tabString;var n;if(e==null){n="#NULL"}else{var i=(t&&e.pack.length>0&&e.pack[0]!=""?"package "+e.pack.join(".")+";\n":"")+(e.meta!=null&&e.meta.length>0?e.meta.map(G(this,this.printMetadata)).join(" ")+" ":"")+(e.isExtern?"extern ":"");var a=e.kind;var s;switch(a._hx_index){case 0:var o="enum "+e.name+(e.params!=null&&e.params.length>0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+" {\n";var u=[];var _=0;var l=e.fields;while(_0?p.meta.map(G(this,this.printMetadata)).join(" ")+" ":"");var f=p.kind;var v;switch(f._hx_index){case 0:var m=f.t;v=p.name+this.opt(m,G(this,this.printComplexType),":");break;case 1:var d=f.f;v=p.name+this.printFunction(d);break;case 2:throw new V("FProp is invalid for TDEnum.")}u.push(c+v+";")}s=o+u.join("\n")+"\n}";break;case 1:var x="typedef "+e.name+(e.params!=null&&e.params.length>0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+" = {\n";var g=[];var y=0;var T=e.fields;while(y0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+(b!=null?" extends "+this.printTypePath(b):"");var w;if(S!=null){var O;if(E){var N=[];var C=0;while(C0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+" = ";var q;switch(K._hx_index){case 2:var X=K.fields;q=this.printStructure(X);break;case 4:var Q=K.fields;var W=K.p;q=this.printExtension(W,Q);break;default:q=this.printComplexType(K)}s=M+q+";";break;case 4:var H=a.to;var J=a.from;var Y=a.tthis;var $="abstract "+e.name+(e.params!=null&&e.params.length>0?"<"+e.params.map(G(this,this.printTypeParamDecl)).join(", ")+">":"")+(Y==null?"":"("+this.printComplexType(Y)+")");var z;if(J==null){z=""}else{var Z=[];var ee=0;while(ee0){throw new V(n.stderr)}return n};c.prototype={get_stderr:function(){return this._stderr_writer.toString()},init_options:function(e){this._options=e==null?{}:e;if(this._options.generate==null){this._options.generate="typedefs"}if(this._options.disable_null_wrappers==null){this._options.disable_null_wrappers=false}},handle_args:function(e,t){if(t==null||t.length==0){return}var r=0;while(r0){var a=_.field(r,n);if(a==null){a=[];r[n]=a}var s=0;while(s0){var p=_.field(r,l);if(p==null){p=[];r[l]=p}var c=0;while(c0){var x=_.field(r,m);if(x==null){x=[];r[m]=x}var g=0;while(g0){t.push({field:d,arguments:f["arguments"]})}}return t},ingest_enum_type_def:function(e){var t=[];this.define_type(m.TEnum(e.name.value,t));var r=0;var n=e.values;while(rt){return 1}else{return-1}});t=c.GENERATED_UNION_PREFIX+e.join("__");if(this._defined_types.indexOf(t)>=0){this.error("Cannot redefine union "+t)}}var r=this._map_of_union_types;if(X[t]!=null){r.setReserved(t,e)}else{r.h[t]=e}this.define_type(m.TUnion(t,e));return t},ingest_schema_def:function(e){var t={query_type:null,mutation_type:null};var r=0;var n=e.operationTypes;while(r0){var a=e.shift();if(r==null){var s=this._types_by_name;r=X[a]!=null?s.getReserved(a):s.h[a];if(r==null){this.error(""+n+"Didn't find root type "+a+" while resolving "+i,true)}if(e.length==0){return{is_array:false,is_optional:false,type:v.TPath(a)}}}else{switch(r._hx_index){case 0:var o=r.name;this.error(""+n+"Expecting type "+o+" to have field "+a+"!",true);break;case 1:var u=r.name;this.error(""+n+"Expecting type "+u+" to have field "+a+"!",true);break;case 2:var _=r.name;this.error(""+n+"Expecting type "+_+" to have field "+a+"!",true);break;case 3:var h=r.name;this.error("TODO: deterimne if graphql lets you poke down into common fields of unions...",true);break;case 4:var p=r.fields;var c=r.name;var f=X[a]!=null?p.getReserved(a):p.h[a];if(f==null){this.error(""+n+"Expecting type "+c+" to have field "+a+"!",true)}if(e.length==0){this.resolve_type(f.type,n);return f}r=this.resolve_type(f.type,n);if(r==null){this.error(""+n+"Did not find type "+l.string(f.type)+" referenced by "+c+"."+a+"!",true)}break}}}this.error(""+n+"couldn't resolve path: "+i,true);return null},get_fragment_info:function(e){var t=null;if(e.kind=="FragmentSpread"){var r=c.FRAGMENT_PREFIX+e.name.value;var n=null;var i=0;var a=this._fragment_defs;while(i=0},is_object_type:function(e){var t=this._types_by_name;var r=X[e]!=null?t.getReserved(e):t.h[e];if(r==null){return false}else if(r._hx_index==4){return!this.is_interface(e)}else{return false}},implements_interface:function(e,t){var r;if(this.is_interface(t)){var n=this._interfaces_implemented;r=X[e]!=null?n.existsReserved(e):n.h.hasOwnProperty(e)}else{r=false}if(r){var i=this._interfaces_implemented;return(X[e]!=null?i.getReserved(e):i.h[e]).indexOf(t)>=0}else{return false}},is_member_of_union:function(e,t){if(!this.is_union(t)){return false}var r=0;var n=this._map_of_union_types;var i=X[t]!=null?n.getReserved(t):n.h[t];while(r=0}return false},resolve_fragment_nodes:function(e,t,r){if(e==null||e.length==0){return}var n=0;while(n=0){t.push(n)}}if(t.length==0){this.error("Query or fragment on interface "+e+", did not find any Object types that implement it!")}return t}if(this.is_union(e)){var s=[];var o=0;var u=this._map_of_union_types;var _=X[e]!=null?u.getReserved(e):u.h[e];while(o<_.length){var l=_[o];++o;if(!this.is_object_type(l)){this.error("Union "+e+" may not contain any type ("+l+") other than object types, per GraphQL spec")}else{s.push(l)}}return s}var h=this._types_by_name;var p=X[e]!=null?h.getReserved(e):h.h[e];if(p==null){this.error("Cannot create fragment or operation on non-Object type "+e,true);return null}else if(p._hx_index==4){return[e]}else{this.error("Cannot create fragment or operation on non-Object type "+e,true);return null}},generate_type_based_on_selection_set:function(e,t,r,n,i){if(i==null){i=0}if(c._basic_types.indexOf(n)>=0){this.error("Cannot create a fragment or operation "+t.debug_name+" on a basic type, "+n,true)}var a=this.get_possible_object_types_from(n);var s=[];this.resolve_fragment_nodes(r.selections,[],s);var _=x._new();var l=0;while(l0;var M=V.name.value;var q=V.alias==null?M:V.alias.value;if(t.is_operation){this.validate_directives(V,t)}var G=""+M+" -> "+q;if(j.indexOf(G)>=0){continue}j.push(G);var Q=R.slice(0);Q.push(M);var W=this.resolve_field(Q,t);var H=this.resolve_type(W.type);switch(H._hx_index){case 0:var J=H.name;if(K){this.error("Cannot specify sub-fields of "+J+" at "+R.join(".")+" of operation "+t.debug_name,true)}if(X[q]!=null){I.setReserved(q,W)}else{I.h[q]=W}break;case 1:var Y=H.name;if(K){this.error("Cannot specify sub-fields of "+Y+" at "+R.join(".")+" of operation "+t.debug_name,true)}if(X[q]!=null){I.setReserved(q,W)}else{I.h[q]=W}break;case 2:var $=H.name;if(K){this.error("Cannot specify sub-fields of "+$+" at "+R.join(".")+" of operation "+t.debug_name,true)}if(X[q]!=null){I.setReserved(q,W)}else{I.h[q]=W}break;case 3:var z=H.name;if(!K){this.error("Must specify sub-fields of "+z+" at "+R.join(".")+" of operation "+t.debug_name,true)}if(this.is_union(z)){if(u.find(V.selectionSet.selections,function(e){return e.kind=="Field"})!=null){this.error("Can only specify fragment selections of union "+z+" at "+R.join(".")+" of operation "+t.debug_name,true)}}var Z=i==0&&h.endsWith(e,c.OP_OUTER_SUFFIX)?h.replace(e,c.OP_OUTER_SUFFIX,c.OP_INNER_SUFFIX):e+"__"+M;var ee=this.generate_type_based_on_selection_set(Z,t,V.selectionSet,z,i+1);var te={type:null,is_array:W.is_array,is_optional:W.is_optional};if(X[q]!=null){I.setReserved(q,te)}else{I.h[q]=te}if(this.is_union(Z)){te.type=v.TPath(Z)}else if(i==0){te.type=v.TPath(Z)}else{this._types_by_name.remove(Z);o.remove(this._defined_types,Z);te.type=v.TAnon(ee)}break;case 4: -var re=H.name;if(!K){this.error("Must specify sub-fields of "+re+" at "+R.join(".")+" of operation "+t.debug_name,true)}if(this.is_union(re)){if(u.find(V.selectionSet.selections,function(e){return e.kind=="Field"})!=null){this.error("Can only specify fragment selections of union "+re+" at "+R.join(".")+" of operation "+t.debug_name,true)}}var ne=i==0&&h.endsWith(e,c.OP_OUTER_SUFFIX)?h.replace(e,c.OP_OUTER_SUFFIX,c.OP_INNER_SUFFIX):e+"__"+M;var ie=this.generate_type_based_on_selection_set(ne,t,V.selectionSet,re,i+1);var ae={type:null,is_array:W.is_array,is_optional:W.is_optional};if(X[q]!=null){I.setReserved(q,ae)}else{I.h[q]=ae}if(this.is_union(ne)){ae.type=v.TPath(ne)}else if(i==0){ae.type=v.TPath(ne)}else{this._types_by_name.remove(ne);o.remove(this._defined_types,ne);ae.type=v.TAnon(ie)}break}break;case"FragmentSpread":case"InlineFragment":this.error("Should not get fragment nodes here...",true);break;default:this.error("Unhandled sel_node kind "+L.kind,true)}}}if(a.length>1){this.generate_union_of_types(C,e);var se=this._types_by_name;return X[e]!=null?se.getReserved(e):se.h[e]}else{var oe=this._types_by_name;return X[e]!=null?oe.getReserved(e):oe.h[e]}},validate_directives:function(e,t){if(e.directives!=null){var r=0;var n=e.directives;while(r=0){continue}var i=this._types_by_name;var a=X[n]!=null?i.getReserved(n):i.h[n];e.append(d.type_to_string(a));e.append("")}e.append("\n\n/* - - - - - - - - - - - - - - - - - - - - - - - - - */\n\n");return e.toString()},init_base_types:function(){var e=0;var t=c._basic_types;while(e=0){v=o.substr(v,v.indexOf(m)+m.length,null)}_.append(" public inline function as"+"__"+v+"():"+c+" return cast this;")}_.append("}");return _.toString();case 4:var x=e.fields;var g=e.name;var y={pack:[],name:d.gql_to_haxe_type_name_transforms(g),pos:d.FAKE_POS,kind:L.TDStructure,fields:[]};var T=x.keys();while(T.hasNext()){var k=T.next();y.fields.push(d.to_haxe_field(k,X[k]!=null?x.getReserved(k):x.h[k]))}return t.printTypeDefinition(y)}};var x={};x.__name__=true;x._new=function(){var e;return new N};var g=function(){};g.__name__=true;g.dedentBlockStringValue=function(e){var t=new s("\r\n|[\n\r]","g");var r=t.split(e);var n=g.getBlockStringIndentation(r);if(n!=0){var i=1;var a=r.length;while(i0&&g.isBlank(r[0]))r.shift();while(r.length>0&&g.isBlank(r[r.length-1]))r.pop();return r.join("\n")};g.getBlockStringIndentation=function(e){var t=null;var r=1;var n=e.length;while(r",0,0,0,0,null);var n=new y(t);n.source=e;n.lastToken=r;n.token=r;return n};y.prototype={advanceLexer:function(){this.lastToken=this.token;var e=this.token=this.lookahead();return e},lookahead:function(){var e=this.token;if(e.kind!=""){while(true){e=e.next!=null?e.next:e.next=this.readToken(this,e);if(!(e.kind=="Comment")){break}}}return e},printCharCode:function(e){if(e<127){return JSON.stringify(String.fromCodePoint(e))}else{return"ESCMAD"}},readToken:function(e,t){var r=e.source;var n=r;var i=n.length;var a=this.positionAfterWhitespace(n,t.end,e);var s=e.line;var o=1+a-e.lineStart;if(a>=i){return T.asToken("",i,i,s,o,t)}var u=n.charCodeAt(a);switch(u){case 33:return T.asToken("!",a,a+1,s,o,t);case 34:if(n.charCodeAt(a+1)==34&&n.charCodeAt(a+2)==34){return this.readBlockString(r,a,s,o,t,e)}return this.readString(r,a,s,o,t);case 35:return this.readComment(r,a,s,o,t);case 36:return T.asToken("$",a,a+1,s,o,t);case 38:return T.asToken("&",a,a+1,s,o,t);case 40:return T.asToken("(",a,a+1,s,o,t);case 41:return T.asToken(")",a,a+1,s,o,t);case 46:if(n.charCodeAt(a+1)==46&&n.charCodeAt(a+2)==46){return T.asToken("...",a,a+3,s,o,t)}break;case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(r,a,u,s,o,t);case 58:return T.asToken(":",a,a+1,s,o,t);case 61:return T.asToken("=",a,a+1,s,o,t);case 64:return T.asToken("@",a,a+1,s,o,t);case 91:return T.asToken("[",a,a+1,s,o,t);case 93:return T.asToken("]",a,a+1,s,o,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return this.readName(r,a,s,o,t);case 123:return T.asToken("{",a,a+1,s,o,t);case 124:return T.asToken("|",a,a+1,s,o,t);case 125:return T.asToken("}",a,a+1,s,o,t)}throw new V(this.syntaxError(r,s,this.lineStart,a,this.unexpectedCharacterMessage(u)))},unexpectedCharacterMessage:function(e){if(e<32&&e!=9&&e!=10&&e!=13){return"Cannot contain the invalid character "+this.printCharCode(e)+"."}if(e==39){return"Unexpected single quote character ('), did you mean to use "+'a double quote (")?'}return"Cannot parse the unexpected character "+this.printCharCode(e)+"."},positionAfterWhitespace:function(e,t,r){var n=e.length;var i=t;while(i31||s==9)){break}}var u=t+1;var _=o;return T.asToken("Comment",t,o,r,n,i,w._new(a.string,w.wrap(a,u)+a.start,w.clamp(a,_)+a.start).toString())},readNumber:function(e,t,r,n,i,a){var s=e;var o=r;var u=t;var _=false;if(o==45){o=s.charCodeAt(++u)}if(o==48){o=s.charCodeAt(++u);if(o>=48&&o<=57){throw new V(this.syntaxError(e,n,this.lineStart,u,"Invalid number, unexpected digit after 0: "+this.printCharCode(o)+"."))}}else{u=this.readDigits(e,u,o);o=s.charCodeAt(u)}if(o==46){_=true;o=s.charCodeAt(++u);u=this.readDigits(e,u,o);o=s.charCodeAt(u)}if(o==69||o==101){_=true;o=s.charCodeAt(++u);if(o==43||o==45){o=s.charCodeAt(++u)}u=this.readDigits(e,u,o)}var l=t;var h=u;return T.asToken(_?"Float":"Int",t,u,n,i,a,w._new(s.string,w.wrap(s,l)+s.start,w.clamp(s,h)+s.start).toString())},readDigits:function(e,t,r){var n=e;var i=t;var a=r;if(a>=48&&a<=57){while(true){a=n.charCodeAt(++i);if(!(a>=48&&a<=57)){break}}return i}throw new V(this.syntaxError(e,this.line,this.lineStart,i,"Invalid number, expected digit but got: "+this.printCharCode(a)+"."))},readString:function(e,t,r,n,i){var a=e;var s=t+1;var o=s;var u=0;var _="";while(true){var l;if(s=48&&e<=57){return e-48}else if(e>=65&&e<=70){return e-55}else if(e>=97&&e<=102){return e-87}else{return-1}},readName:function(e,t,r,n,i){var a=e;var s=a.length;var o=t+1;var u=0;while(true){var _;if(o!=s){u=a.charCodeAt(o);_=!isNaN(u)}else{_=false}if(!(_&&(u==95||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122))){break}++o}var l=t;var h=o;return T.asToken("Name",t,o,r,n,i,w._new(a.string,w.wrap(a,l)+a.start,w.clamp(a,h)+a.start).toString())},syntaxError:function(e,t,r,n,i){return b.syntaxError(e,t,r,n,i)}};var T=function(){};T.__name__=true;T.asToken=function(e,t,r,n,i,a,s){return{kind:e,start:t,end:r,line:n,column:i,value:s,prev:a,next:null}};var k=function(){};k.__name__=true;k.prototype={parseName:function(e){var t=this.expectToken(e,"Name");return{kind:"Name",value:t.value,loc:this.loc(e,t)}},parseDocument:function(e){var t=e.token;return{kind:"Document",definitions:this.many(e,"",G(this,this.parseDefinition),""),loc:this.loc(e,t)}},parseDefinition:function(e){if(this.peek(e,"Name")){switch(e.token.value){case"extend":return this.parseTypeSystemExtension(e);case"fragment":case"mutation":case"query":case"subscription":return this.parseExecutableDefinition(e);case"directive":case"enum":case"input":case"interface":case"scalar":case"schema":case"type":case"union":return this.parseTypeSystemDefinition(e)}}else if(this.peek(e,"{")){return this.parseExecutableDefinition(e)}else if(this.peekDescription(e)){return this.parseTypeSystemDefinition(e)}throw new V(this.unexpected(e))},parseExecutableDefinition:function(e){if(this.peek(e,"Name")){switch(e.token.value){case"fragment":return this.parseFragmentDefinition(e);case"mutation":case"query":case"subscription":return this.parseOperationDefinition(e)}}else if(this.peek(e,"{")){return this.parseOperationDefinition(e)}throw new V(this.unexpected(e))},parseOperationDefinition:function(e){var t=e.token;if(this.peek(e,"{")){return{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}}var r=this.parseOperationType(e);var n=null;if(this.peek(e,"Name")){n=this.parseName(e)}return{kind:"OperationDefinition",operation:r,name:n,variableDefinitions:this.parseVariableDefinitions(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseOperationType:function(e){var t=this.expectToken(e,"Name");switch(t.value){case"mutation":return"mutation";case"query":return"query";case"subscription":return"subscription"}throw new V(this.unexpected(e,t))},parseVariableDefinitions:function(e){if(this.peek(e,"(")){return this.many(e,"(",G(this,this.parseVariableDefinition),")")}else{return[]}},parseVariableDefinition:function(e){var t=e.token;var r=this.parseVariable(e);this.expectToken(e,":");return{kind:"VariableDefinition",variable:r,type:this.parseTypeReference(e),defaultValue:this.expectOptionalToken(e,"=")?this.parseValueLiteral(e,true):null,directives:this.parseDirectives(e,true),loc:this.loc(e,t)}},parseVariable:function(e){var t=e.token;this.expectToken(e,"$");return{kind:"Variable",name:this.parseName(e),loc:this.loc(e,t)}},parseSelectionSet:function(e){var t=e.token;return{kind:"SelectionSet",selections:this.many(e,"{",G(this,this.parseSelection),"}"),loc:this.loc(e,t)}},parseSelection:function(e){if(this.peek(e,"...")){return this.parseFragment(e)}else{return this.parseField(e)}},parseField:function(e){var t=e.token;var r=this.parseName(e);var n=null;var i=null;if(this.expectOptionalToken(e,":")){n=r;i=this.parseName(e)}else{i=r}return{kind:"Field",alias:n,name:i,arguments:this.parseArguments(e,false),directives:this.parseDirectives(e,false),selectionSet:this.peek(e,"{")?this.parseSelectionSet(e):null,loc:this.loc(e,t)}},parseArguments:function(e,t){var r=t?G(this,this.parseConstArgument):G(this,this.parseArgument);if(this.peek(e,"(")){return this.many(e,"(",r,")")}else{return[]}},parseArgument:function(e){var t=e.token;var r=this.parseName(e);this.expectToken(e,":");return{kind:"Argument",name:r,value:this.parseValueLiteral(e,false),loc:this.loc(e,t)}},parseConstArgument:function(e){var t=e.token;var r=this.parseName(e);this.expectToken(e,":");return{kind:"Argument",name:r,value:this.parseConstValue(e),loc:this.loc(e,t)}},parseFragment:function(e){var t=e.token;this.expectToken(e,"...");var r=this.expectOptionalKeyword(e,"on");if(!r&&this.peek(e,"Name")){return{kind:"FragmentSpread",name:this.parseFragmentName(e),directives:this.parseDirectives(e,false),loc:this.loc(e,t)}}return{kind:"InlineFragment",typeCondition:r?this.parseNamedType(e):null,directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseFragmentDefinition:function(e){var t=e.token;this.expectKeyword(e,"fragment");if(e.options.experimentalFragmentVariables){var r=this.parseFragmentName(e);var n=this.parseVariableDefinitions(e);this.expectKeyword(e,"on");return{kind:"FragmentDefinition",name:r,variableDefinitions:n,typeCondition:this.parseNamedType(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}}var i=this.parseFragmentName(e);this.expectKeyword(e,"on");return{kind:"FragmentDefinition",name:i,typeCondition:this.parseNamedType(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseFragmentName:function(e){if(e.token.value=="on"){throw new V(this.unexpected(e))}return this.parseName(e)},parseValueLiteral:function(e,t){var r=e.token;switch(r.kind){case"$":if(!t){return this.parseVariable(e)}break;case"Float":e.advance();return{kind:"FloatValue",value:r.value,loc:this.loc(e,r)};case"Int":e.advance();return{kind:"IntValue",value:r.value,loc:this.loc(e,r)};case"Name":if(r.value=="true"||r.value=="false"){e.advance();return{kind:"BooleanValue",value:r.value=="true",loc:this.loc(e,r)}}else if(r.value=="null"){e.advance();return{kind:"NullValue",loc:this.loc(e,r)}}e.advance();return{kind:"EnumValue",value:r.value,loc:this.loc(e,r)};case"BlockString":case"String":return this.parseStringLiteral(e);case"[":return this.parseList(e,t);case"{":return this.parseObject(e,t);default:}throw new V(this.unexpected(e))},parseStringLiteral:function(e){var t=e.token;e.advance();return{kind:"StringValue",value:t.value,block:t.kind=="BlockString",loc:this.loc(e,t)}},parseConstValue:function(e){return this.parseValueLiteral(e,true)},parseValueValue:function(e){return this.parseValueLiteral(e,false)},parseList:function(e,t){var r=e.token;var n=t?G(this,this.parseConstValue):G(this,this.parseValueValue);return{kind:"ListValue",values:this.any(e,"[",n,"]"),loc:this.loc(e,r)}},parseObject:function(e,t){var r=this;var n=e.token;var i=function(n){return r.parseObjectField(e,t)};return{kind:"ObjectValue",fields:this.any(e,"{",i,"}"),loc:this.loc(e,n)}},parseObjectField:function(e,t){var r=e.token;var n=this.parseName(e);this.expectToken(e,":");return{kind:"ObjectField",name:n,value:this.parseValueLiteral(e,t),loc:this.loc(e,r)}},parseDirectives:function(e,t){var r=[];while(this.peek(e,"@"))r.push(this.parseDirective(e,t));return r},parseDirective:function(e,t){var r=e.token;this.expectToken(e,"@");return{kind:"Directive",name:this.parseName(e),arguments:this.parseArguments(e,t),loc:this.loc(e,r)}},parseTypeReference:function(e){var t=e.token;var r=null;if(this.expectOptionalToken(e,"[")){r=this.parseTypeReference(e);this.expectToken(e,"]");r={kind:"ListType",type:r,loc:this.loc(e,t)}}else{r=this.parseNamedType(e)}if(this.expectOptionalToken(e,"!")){return{kind:"NonNullType",type:r,loc:this.loc(e,t)}}return r},parseNamedType:function(e){var t=e.token;return{kind:"NamedType",name:this.parseName(e),loc:this.loc(e,t)}},parseTypeSystemDefinition:function(e){var t=this.peekDescription(e)?e.lookahead():e.token;if(t.kind=="Name"){switch(t.value){case"directive":return this.parseDirectiveDefinition(e);case"enum":return this.parseEnumTypeDefinition(e);case"input":return this.parseInputObjectTypeDefinition(e);case"interface":return this.parseInterfaceTypeDefinition(e);case"scalar":return this.parseScalarTypeDefinition(e);case"schema":return this.parseSchemaDefinition(e);case"type":return this.parseObjectTypeDefinition(e);case"union":return this.parseUnionTypeDefinition(e)}}throw new V(this.unexpected(e,t))},peekDescription:function(e){if(!this.peek(e,"String")){return this.peek(e,"BlockString")}else{return true}},parseDescription:function(e){if(!this.peekDescription(e)){return null}return this.parseStringLiteral(e)},parseSchemaDefinition:function(e){var t=e.token;this.expectKeyword(e,"schema");var r=this.parseDirectives(e,true);var n=this.many(e,"{",G(this,this.parseOperationTypeDefinition),"}");return{kind:"SchemaDefinition",directives:r,operationTypes:n,loc:this.loc(e,t)}},parseOperationTypeDefinition:function(e){var t=e.token;var r=this.parseOperationType(e);this.expectToken(e,":");var n=this.parseNamedType(e);return{kind:"OperationTypeDefinition",operation:r,type:n,loc:this.loc(e,t)}},parseScalarTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"scalar");var n=this.parseName(e);var i=this.parseDirectives(e,true);return{kind:"ScalarTypeDefinition",description:r,name:n,directives:i,loc:this.loc(e,t)}},parseObjectTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"type");var n=this.parseName(e);var i=this.parseImplementsInterfaces(e);var a=this.parseDirectives(e,true);var s=this.parseFieldsDefinition(e);return{kind:"ObjectTypeDefinition",description:r,name:n,interfaces:i,directives:a,fields:s,loc:this.loc(e,t)}},parseImplementsInterfaces:function(e){var t=[];if(this.expectOptionalKeyword(e,"implements")){this.expectOptionalToken(e,"&");while(true){t.push(this.parseNamedType(e));if(!(this.expectOptionalToken(e,"&")||e.options.allowLegacySDLImplementsInterfaces&&this.peek(e,"Name"))){break}}}return t},parseFieldsDefinition:function(e){if(e.options.allowLegacySDLEmptyFields&&this.peek(e,"{")&&e.lookahead().kind=="}"){e.advance();e.advance();return[]}if(this.peek(e,"{")){return this.many(e,"{",G(this,this.parseFieldDefinition),"}")}else{return[]}},parseFieldDefinition:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);var i=this.parseArgumentDefs(e);this.expectToken(e,":");var a=this.parseTypeReference(e);var s=this.parseDirectives(e,true);return{kind:"FieldDefinition",description:r,name:n,arguments:i,type:a,directives:s,loc:this.loc(e,t)}},parseArgumentDefs:function(e){if(!this.peek(e,"(")){return[]}return this.many(e,"(",G(this,this.parseInputValueDef),")")},parseInputValueDef:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);this.expectToken(e,":");var i=this.parseTypeReference(e);var a=null;if(this.expectOptionalToken(e,"=")){a=this.parseConstValue(e)}var s=this.parseDirectives(e,true);return{kind:"InputValueDefinition",description:r,name:n,type:i,defaultValue:a,directives:s,loc:this.loc(e,t)}},parseInterfaceTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"interface");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseFieldsDefinition(e);return{kind:"InterfaceTypeDefinition",description:r,name:n,directives:i,fields:a,loc:this.loc(e,t)}},parseUnionTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"union");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseUnionMemberTypes(e);return{kind:"UnionTypeDefinition",description:r,name:n,directives:i,types:a,loc:this.loc(e,t)}},parseUnionMemberTypes:function(e){var t=[];if(this.expectOptionalToken(e,"=")){this.expectOptionalToken(e,"|");while(true){t.push(this.parseNamedType(e));if(!this.expectOptionalToken(e,"|")){break}}}return t},parseEnumTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"enum");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseEnumValuesDefinition(e);return{kind:"EnumTypeDefinition",description:r,name:n,directives:i,values:a,loc:this.loc(e,t)}},parseEnumValuesDefinition:function(e){if(this.peek(e,"{")){return this.many(e,"{",G(this,this.parseEnumValueDefinition),"}")}else{return[]}},parseEnumValueDefinition:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);var i=this.parseDirectives(e,true);return{kind:"EnumValueDefinition",description:r,name:n,directives:i,loc:this.loc(e,t)}},parseInputObjectTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"input");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseInputFieldsDefinition(e);return{kind:"InputObjectTypeDefinition",description:r,name:n,directives:i,fields:a,loc:this.loc(e,t)}},parseInputFieldsDefinition:function(e){if(this.peek(e,"{")){return this.many(e,"{",G(this,this.parseInputValueDef),"}")}else{return[]}},parseTypeSystemExtension:function(e){var t=e.lookahead();if(t.kind=="Name"){switch(t.value){case"enum":return this.parseEnumTypeExtension(e);case"input":return this.parseInputObjectTypeExtension(e);case"interface":return this.parseInterfaceTypeExtension(e);case"scalar":return this.parseScalarTypeExtension(e);case"schema":return this.parseSchemaExtension(e);case"type":return this.parseObjectTypeExtension(e);case"union":return this.parseUnionTypeExtension(e)}}throw new V(this.unexpected(e,t))},parseSchemaExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"schema");var r=this.parseDirectives(e,true);var n=this.peek(e,"{")?this.many(e,"{",G(this,this.parseOperationTypeDefinition),"}"):[];if(r.length==0&&n.length==0){throw new V(this.unexpected(e))}return{kind:"SchemaExtension",directives:r,operationTypes:n,loc:this.loc(e,t)}},parseScalarTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"scalar");var r=this.parseName(e);var n=this.parseDirectives(e,true);if(n.length==0){throw new V(this.unexpected(e))}return{kind:"ScalarTypeExtension",name:r,directives:n,loc:this.loc(e,t)}},parseObjectTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"type");var r=this.parseName(e);var n=this.parseImplementsInterfaces(e);var i=this.parseDirectives(e,true);var a=this.parseFieldsDefinition(e);if(n.length==0&&i.length==0&&a.length==0){throw new V(this.unexpected(e))}return{kind:"ObjectTypeExtension",name:r,interfaces:n,directives:i,fields:a,loc:this.loc(e,t)}},parseInterfaceTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"interface");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseFieldsDefinition(e);if(n.length==0&&i.length==0){throw new V(this.unexpected(e))}return{kind:"InterfaceTypeExtension",name:r,directives:n,fields:i,loc:this.loc(e,t)}},parseUnionTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"union");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseUnionMemberTypes(e);if(n.length==0&&i.length==0){throw new V(this.unexpected(e))}return{kind:"UnionTypeExtension",name:r,directives:n,types:i,loc:this.loc(e,t)}},parseEnumTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"enum");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseEnumValuesDefinition(e);if(n.length==0&&i.length==0){throw new V(this.unexpected(e))}return{kind:"EnumTypeExtension",name:r,directives:n,values:i,loc:this.loc(e,t)}},parseInputObjectTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"input");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseInputFieldsDefinition(e);if(n.length==0&&i.length==0){throw new V(this.unexpected(e))}return{kind:"InputObjectTypeExtension",name:r,directives:n,fields:i,loc:this.loc(e,t)}},parseDirectiveDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"directive");this.expectToken(e,"@");var n=this.parseName(e);var i=this.parseArgumentDefs(e);this.expectKeyword(e,"on");var a=this.parseDirectiveLocations(e);return{kind:"DirectiveDefinition",description:r,name:n,arguments:i,locations:a,loc:this.loc(e,t)}},parseDirectiveLocations:function(e){this.expectOptionalToken(e,"|");var t=[];while(true){t.push(this.parseDirectiveLocation(e));if(!this.expectOptionalToken(e,"|")){break}}return t},parseDirectiveLocation:function(e){var t=e.token;var r=this.parseName(e);var n=k.ValidDirectiveLocations;var i=r.value;if(X[i]!=null?n.getReserved(i):n.h[i]){return r}throw new V(this.unexpected(e,t))},peek:function(e,t){return e.token.kind==t},expectToken:function(e,t){var r=e.token;if(r.kind==t){e.advance();return r}throw new V(this.syntaxError(e.source,e.line,e.lineStart,r.start,"Expected "+t+", found "+this.getTokenDesc(r)))},expectOptionalToken:function(e,t){var r=e.token;if(r.kind==t){e.advance();return r!=null}return false},expectKeyword:function(e,t){var r=e.token;if(r.kind=="Name"&&r.value==t){e.advance();return r}throw new V(this.syntaxError(e.source,e.line,e.lineStart,r.start,'Expected "'+t+'", found '+this.getTokenDesc(r)))},expectOptionalKeyword:function(e,t){var r=e.token;if(r.kind=="Name"&&r.value==t){e.advance();return r!=null}return false},unexpected:function(e,t){var r=t!=null?t:e.token;return this.syntaxError(e.source,e.line,e.lineStart,r.start,"Unexpected "+this.getTokenDesc(r))},any:function(e,t,r,n){this.expectToken(e,t);var i=[];while(!this.expectOptionalToken(e,n))i.push(r(e));return i},many:function(e,t,r,n){this.expectToken(e,t);var i=[r(e)];while(!this.expectOptionalToken(e,n))i.push(r(e));return i},loc:function(e,t){if(e.options!=null&&e.options.noLocation){return null}return{start:t.start,end:e.lastToken.end,startToken:t,endToken:e.lastToken,source:e.source}},syntaxError:function(e,t,r,n,i){ -return b.syntaxError(e,t,r,n,i)},getTokenDesc:function(e){return e.kind}};var E=function(e,t,r,n,i){this.file=e;this.min=t;this.max=r;this.line=n;this.col=i};E.__name__=true;var S=function(e,t){this.message=e;this.pos=t};S.__name__=true;var b=function(e,t,r){if(r==null){r="Untitled"}var n=new k;if(t==null){t={}}var i=y.createLexer(w.ofString(e),t);try{this.document=n.parseDocument(i)}catch(a){var s=a instanceof V?a.val:a;if(s instanceof S){var o=s;var u=o.pos!=null?""+o.pos.line+": characters "+o.pos.col+"-"+(o.pos.col+(o.pos.max-o.pos.min+1)):"";throw new V(""+r+":"+u+" Error: "+o.message)}else{throw a}}};b.__name__=true;b.syntaxError=function(e,t,r,n,i){var a=n-r;return new S(i,new E(null,n,n,t,a))};var D=function(e,t,r){this.string=e;this.start=t;this.end=r;if((this.length=r-t)<0){this.length=0;this.end=this.start}};D.__name__=true;D.prototype={toString:function(){if(this.representation==null){this.representation=this.string.substring(this.start,this.end)}return this.representation},charCodeAt:function(e){if(this.representation==null){this.representation=this.string.substring(this.start,this.end)}return o.cca(this.representation,e)}};var w={};w.__name__=true;w._new=function(e,t,r){var n=new D(e,t==e.length?t:t<0?t%e.length+e.length:t%e.length,r==e.length?r:r<0?r%e.length+e.length:r%e.length);return n};w.clamp=function(e,t){if(t<0){if(-t>e.length){return 0}else{return t+e.length}}else if(t>e.length){return e.length}else{return t}};w.wrap=function(e,t){if(e.length==0){return 0}else if(t<0){return t%e.length+e.length}else{return t%e.length}};w.ofString=function(e){if(e==null||e==""){return w.EMPTY}else if(e.length==1){var t=e.charCodeAt(0);if(t=5){return"<...>"}var n=typeof e;if(n=="function"&&(e.__name__||e.__ename__)){n="object"}switch(n){case"function":return"";case"object":if(e.__enum__){var i=r[e.__enum__];var a=i.__constructs__[e._hx_index];var s=i[a];if(s.__params__){t+=" ";var o=a+"(";var u=[];var _=0;var l=s.__params__;while(_0?",":"")+K.__string_rec(e[d],t)}f+="]";return f}var x;try{x=e.toString}catch(g){var y=g instanceof V?g.val:g;return"???"}if(x!=null&&x!=Object.toString&&typeof x=="function"){var T=e.toString();if(T!="[object Object]"){return T}}var k=null;var E="{\n";t+=" ";var S=e.hasOwnProperty!=null;for(var k in e){if(S&&!e.hasOwnProperty(k)){continue}if(k=="prototype"||k=="__class__"||k=="__super__"||k=="__interfaces__"||k=="__properties__"){continue}if(E.length!=2){E+=", \n"}E+=t+k+" : "+K.__string_rec(e[k],t)}t=t.substring(1);E+="\n"+t+"}";return E;case"string":return e;default:return String(e)}};function M(e){if(e instanceof Array)return o.iter(e);else return e.iterator()}var q=0;function G(e,t){if(t==null)return null;if(t.__id__==null)t.__id__=q++;var r;if(e.hx__closures__==null)e.hx__closures__={};else r=e.hx__closures__[t.__id__];if(r==null){r=t.bind(e);e.hx__closures__[t.__id__]=r}return r}if(String.fromCodePoint==null)String.fromCodePoint=function(e){return e<65536?String.fromCharCode(e):String.fromCharCode((e>>10)+55232)+String.fromCharCode((e&1023)+56320)};String.__name__=true;Array.__name__=true;var X={};Object.defineProperty(V.prototype,"message",{get:function(){return String(this.val)}});c.OP_PREFIX="OP_";c.OP_OUTER_SUFFIX="_Result";c.OP_INNER_SUFFIX="_InnerResult";c.OP_VARS_SUFFIX="_Vars";c.FRAGMENT_PREFIX="Fragment_";c.UNION_SELECTION_SEPARATOR="_ON_";c.ARGS_PREFIX="Args_";c.GENERATED_UNION_PREFIX="U_";c.DEFAULT_SEPARATOR="__";c._basic_types=["ID","String","Float","Int","Boolean"];d.bool_collision=false;d.FAKE_POS={min:0,max:0,file:"Untitled"};k.ValidDirectiveLocations=function(e){var t;var r=new N;if(X["QUERY"]!=null){r.setReserved("QUERY",true)}else{r.h["QUERY"]=true}if(X["MUTATION"]!=null){r.setReserved("MUTATION",true)}else{r.h["MUTATION"]=true}if(X["SUBSCRIPTION"]!=null){r.setReserved("SUBSCRIPTION",true)}else{r.h["SUBSCRIPTION"]=true}if(X["FIELD"]!=null){r.setReserved("FIELD",true)}else{r.h["FIELD"]=true}if(X["FRAGMENT_DEFINITION"]!=null){r.setReserved("FRAGMENT_DEFINITION",true)}else{r.h["FRAGMENT_DEFINITION"]=true}if(X["FRAGMENT_SPREAD"]!=null){r.setReserved("FRAGMENT_SPREAD",true)}else{r.h["FRAGMENT_SPREAD"]=true}if(X["INLINE_FRAGMENT"]!=null){r.setReserved("INLINE_FRAGMENT",true)}else{r.h["INLINE_FRAGMENT"]=true}if(X["SCHEMA"]!=null){r.setReserved("SCHEMA",true)}else{r.h["SCHEMA"]=true}if(X["SCALAR"]!=null){r.setReserved("SCALAR",true)}else{r.h["SCALAR"]=true}if(X["OBJECT"]!=null){r.setReserved("OBJECT",true)}else{r.h["OBJECT"]=true}if(X["FIELD_DEFINITION"]!=null){r.setReserved("FIELD_DEFINITION",true)}else{r.h["FIELD_DEFINITION"]=true}if(X["ARGUMENT_DEFINITION"]!=null){r.setReserved("ARGUMENT_DEFINITION",true)}else{r.h["ARGUMENT_DEFINITION"]=true}if(X["INTERFACE"]!=null){r.setReserved("INTERFACE",true)}else{r.h["INTERFACE"]=true}if(X["UNION"]!=null){r.setReserved("UNION",true)}else{r.h["UNION"]=true}if(X["ENUM"]!=null){r.setReserved("ENUM",true)}else{r.h["ENUM"]=true}if(X["ENUM_VALUE"]!=null){r.setReserved("ENUM_VALUE",true)}else{r.h["ENUM_VALUE"]=true}if(X["INPUT_OBJECT"]!=null){r.setReserved("INPUT_OBJECT",true)}else{r.h["INPUT_OBJECT"]=true}if(X["INPUT_FIELD_DEFINITION"]!=null){r.setReserved("INPUT_FIELD_DEFINITION",true)}else{r.h["INPUT_FIELD_DEFINITION"]=true}t=r;return t}(this);w.CHARS=function(e){var t;var r=[];{var n=0;while(n<128){var i=n++;r.push(new D(String.fromCodePoint(i),0,1))}}t=r;return t}(this);w.EMPTY=new D("",0,0);a.main()})(typeof exports!="undefined"?exports:typeof window!="undefined"?window:typeof self!="undefined"?self:this); +(function(c,m){"use strict";c["graphql"]=c["graphql"]||{};var a=function(){return f.__string_rec(this,"")},v=v||{},e;function T(e,t){var r=Object.create(e);for(var n in t)r[n]=t[n];if(t.toString!==Object.prototype.toString)r.toString=t.toString;return r}var t=c["Demo"]=function(){};t.__name__=true;t.main=function(){};t.parse=function(e){var t=new s(e,{noLocation:true});return t.document};t.hxgen=function(e){return J.parse(e)};var S=function(e,t){this.r=new RegExp(e,t.split("u").join(""))};S.__name__=true;S.prototype={split:function(e){var t="#__delim__#";return e.replace(this.r,t).split(t)}};var W=function(){};W.__name__=true;W.cca=function(e,t){var r=e.charCodeAt(t);if(r!=r){return undefined}return r};W.substr=function(e,t,r){if(r==null){r=e.length}else if(r<0){if(t==0){r=e.length+r}else{return""}}return e.substr(t,r)};W.remove=function(e,t){var r=e.indexOf(t);if(r==-1){return false}e.splice(r,1);return true};W.now=function(){return Date.now()};var H=function(){};H.__name__=true;H.has=function(e,t){var r=K(e);while(r.hasNext()){var n=r.next();if(n==t){return true}}return false};H.exists=function(e,t){var r=K(e);while(r.hasNext()){var n=r.next();if(t(n)){return true}}return false};H.find=function(e,t){var r=K(e);while(r.hasNext()){var n=r.next();if(t(n)){return n}}return null};Math.__name__=true;var $=function(){};$.__name__=true;$.field=function(e,t){try{return e[t]}catch(e){return null}};var j=function(){};j.__name__=true;j.string=function(e){return f.__string_rec(e,"")};var Y=function(){};Y.__name__=true;Y.endsWith=function(e,t){var r=t.length;var n=e.length;if(n>=r){return e.indexOf(t,n-r)==n-r}else{return false}};Y.replace=function(e,t,r){return e.split(t).join(r)};var O=function(e,t){if(t==null){t=false}if(e==null){e="\t"}this.tabs="";this.fieldDelimiter=t?",":";";this.shortTypedefs=t;this.tabString=e};O.__name__=true;O.prototype={printUnop:function(e){switch(e._hx_index){case 0:return"++";case 1:return"--";case 2:return"!";case 3:return"-";case 4:return"~";case 5:return"..."}},printBinop:function(e){switch(e._hx_index){case 0:return"+";case 1:return"*";case 2:return"/";case 3:return"-";case 4:return"=";case 5:return"==";case 6:return"!=";case 7:return">";case 8:return">=";case 9:return"<";case 10:return"<=";case 11:return"&";case 12:return"|";case 13:return"^";case 14:return"&&";case 15:return"||";case 16:return"<<";case 17:return">>";case 18:return">>>";case 19:return"%";case 20:var t=e.op;return this.printBinop(t)+"=";case 21:return"...";case 22:return"=>";case 23:return"in";case 24:return"?."}},escapeString:function(e,t){return t+Y.replace(Y.replace(Y.replace(Y.replace(e,"\n","\\n"),"\t","\\t"),"'","\\'"),'"','\\"')+t},printString:function(e){return this.escapeString(e,'"')},printConstant:function(e){switch(e._hx_index){case 0:var t=e.s;var r=e.v;return r;case 1:var t=e.s;var r=e.f;return r;case 2:var t=e.kind;var r=e.s;return this.printString(r);case 3:var r=e.s;return r;case 4:var r=e.r;var n=e.opt;return"~/"+r+"/"+n}},printTypeParam:function(e){switch(e._hx_index){case 0:var t=e.t;return this.printComplexType(t);case 1:var r=e.e;return this.printExpr(r)}},printTypePath:function(e){var t=(e.pack.length>0?e.pack.join(".")+".":"")+e.name+(e.sub!=null?"."+e.sub:"");var r;if(e.params==null){r=""}else if(e.params.length>0){var n=e.params;var i=re(this,this.printTypeParam);var a=new Array(n.length);var s=0;var o=n.length;while(s"}else{r=""}return t+r},printComplexType:function(e){var r=this;switch(e._hx_index){case 0:var t=e.p;return this.printTypePath(t);case 1:var n=e.args;var i=e.ret;var a=function(e){if(e._hx_index==1){var t=e.args;var t=e.ret;return"("+r.printComplexType(e)+")"}else{return r.printComplexType(e)}};var s;if(n.length>0){var o=a;var _=new Array(n.length);var h=0;var l=n.length;while(h ")}else{s="Void"}return s+" -> "+this.printComplexType(i);case 2:var p=e.fields;var h=[];var l=0;while(l, ")+", ";var o=re(this,this.printField);var _=new Array(p.length);var h=0;var l=p.length;while(h0?"("+this.printExprs(e.params,", ")+")":"")},printAccess:function(e){switch(e._hx_index){case 0:return"public";case 1:return"private";case 2:return"static";case 3:return"override";case 4:return"dynamic";case 5:return"inline";case 6:return"macro";case 7:return"final";case 8:return"extern";case 9:return"/* abstract? */";case 10:return"/* overload? */"}},printField:function(e){var t;if(this.shortTypedefs){var r=e.kind;if(r._hx_index==0){var n=r.t;var n=r.e;t=true}else{t=false}}else{t=false}var i=e.meta!=null&&e.meta.length>0&&H.exists(e.meta,function(e){return e.name==":optional"});var r=[];var n=0;var a=e.meta;while(n0){var l=re(this,this.printMetadata);var u=new Array(o.length);var r=0;var n=o.length;while(r0){var v=e.access;var l=re(this,this.printAccess);var u=new Array(v.length);var r=0;var n=v.length;while(r"}else{r=""}var h=t+r;var r;if(e.constraints!=null&&e.constraints.length>0){var n=e.constraints;var i=re(this,this.printComplexType);var a=new Array(n.length);var s=0;var o=n.length;while(s0){var r=e.params;var n=re(this,this.printTypeParamDecl);var i=new Array(r.length);var a=0;var s=r.length;while(a"}else{t=""}var _=t+"(";var r=e.args;var n=re(this,this.printFunctionArg);var i=new Array(r.length);var a=0;var s=r.length;while(a";var n=re(this,this.printTypePath);var i=new Array(e.length);var a=0;var s=e.length;while(a")+",";var r;if(t.length>0){var h="\n"+this.tabs;var n=re(this,this.printField);var i=new Array(t.length);var a=0;var s=t.length;while(a0&&e.pack[0]!=""?"package "+e.pack.join(".")+";\n":"";var a;if(e.meta!=null&&e.meta.length>0){var s=e.meta;var o=re(this,this.printMetadata);var _=new Array(s.length);var h=0;var l=s.length;while(h0){var s=e.params;var o=re(this,this.printTypeParamDecl);var _=new Array(s.length);var l=0;var c=s.length;while(l"}else{p=""}var v=a+p+" {\n";var l=[];var c=0;var f=e.fields;while(c0){var s=m.meta;var o=re(this,this.printMetadata);var _=new Array(s.length);var d=0;var K=s.length;while(d0){var s=e.params;var o=re(this,this.printTypeParamDecl);var _=new Array(s.length);var l=0;var c=s.length;while(l"}else{p=""}var v=a+p+" = {\n";var l=[];var c=0;var f=e.fields;while(c0){var s=e.params;var o=re(this,this.printTypeParamDecl);var _=new Array(s.length);var l=0;var c=s.length;while(l"}else{p=""}var v=a+p+(w!=null?" extends "+this.printTypePath(w):"");var a;if(S!=null){var p;if(E){var l=[];var c=0;while(c0){var s=e.params;var o=re(this,this.printTypeParamDecl);var _=new Array(s.length);var l=0;var c=s.length;while(l"}else{p=""}var v=a+p+" = ";var a;switch(D._hx_index){case 2:var O=D.fields;a=this.printStructure(O);break;case 4:var q=D.p;var O=D.fields;a=this.printExtension(q,O);break;default:a=this.printComplexType(D)}i=v+a+";";break;case 4:var A=h.tthis;var C=h.from;var F=h.to;var a="abstract "+e.name;var p;if(e.params!=null&&e.params.length>0){var s=e.params;var o=re(this,this.printTypeParamDecl);var _=new Array(s.length);var l=0;var c=s.length;while(l"}else{p=""}var v=a+p+(A==null?"":"("+this.printComplexType(A)+")");var a;if(C==null){a=""}else{var l=[];var c=0;while(c0){var o=re(this,this.printAccess);var _=new Array(I.length);var h=0;var l=I.length;while(h0){throw Q.thrown(n.stderr)}return n};J.prototype={get_stderr:function(){return this._stderr_writer.toString()},init_options:function(e){this._options=e==null?{}:e;if(this._options.generate==null){this._options.generate="typedefs"}if(this._options.disable_null_wrappers==null){this._options.disable_null_wrappers=false}},handle_args:function(e,t){if(t==null||t.length==0){return}var r=0;while(r0){var a=$.field(r,n);if(a==null){a=[];r[n]=a}var s=0;while(s0){var a=$.field(r,n);if(a==null){a=[];r[n]=a}var s=0;while(s0){var a=$.field(r,n);if(a==null){a=[];r[n]=a}var s=0;while(s0){t.push({field:l,arguments:_.arguments})}}return t},ingest_enum_type_def:function(e){var t=[];this.define_type(Z.TEnum(e.name.value,t));var r=0;var n=e.values;while(rt){return 1}else{return-1}});t=J.GENERATED_UNION_PREFIX+e.join("__");if(this._defined_types.indexOf(t)>=0){this.error("Cannot redefine union "+t)}}this._map_of_union_types.h[t]=e;this.define_type(Z.TUnion(t,e));return t},ingest_schema_def:function(e){var t={query_type:null,mutation_type:null};var r=0;var n=e.operationTypes;while(r0){var a=e.shift();if(r==null){r=this._types_by_name.h[a];if(r==null){this.error(""+n+"Didn't find root type "+a+" while resolving "+i,true)}if(e.length==0){return{is_array:false,is_optional:false,type:z.TPath(a)}}}else{switch(r._hx_index){case 0:var s=r.name;this.error(""+n+"Expecting type "+s+" to have field "+a+"!",true);break;case 1:var o=r.name;this.error(""+n+"Expecting type "+o+" to have field "+a+"!",true);break;case 2:var _=r.values;var h=r.name;this.error(""+n+"Expecting type "+h+" to have field "+a+"!",true);break;case 3:var l=r.type_paths;var u=r.name;this.error("TODO: deterimne if graphql lets you poke down into common fields of unions...",true);break;case 4:var p=r.name;var c=r.fields;var v;if(a=="__typename"){v={type:z.TPath("String"),is_array:false,is_optional:true}}else{v=c.h[a]}if(v==null){this.error(""+n+"Expecting type "+p+" to have field "+a+"!",true)}if(e.length==0){this.resolve_type(v.type,n);return v}r=this.resolve_type(v.type,n);if(r==null){this.error(""+n+"Did not find type "+j.string(v.type)+" referenced by "+p+"."+a+"!",true)}break}}}this.error(""+n+"couldn't resolve path: "+i,true);return null},get_fragment_info:function(t){var e=null;if(t.kind=="FragmentSpread"){var r=J.FRAGMENT_PREFIX+t.name.value;var n=null;var i=0;var a=this._fragment_defs;while(i=0},is_object_type:function(e){var t=this._types_by_name.h[e];if(t==null){return false}else if(t._hx_index==4){var r=t.name;var r=t.fields;return!this.is_interface(e)}else{return false}},implements_interface:function(e,t){if(this.is_interface(t)&&Object.prototype.hasOwnProperty.call(this._interfaces_implemented.h,e)){return this._interfaces_implemented.h[e].indexOf(t)>=0}else{return false}},is_member_of_union:function(e,t){if(!this.is_union(t)){return false}var r=0;var n=this._map_of_union_types.h[t];while(r=0}return false},resolve_fragment_nodes:function(e,t,r){if(e==null||e.length==0){return}var n=0;while(n=0){t.push(o)}}if(t.length==0){this.error("Query or fragment on interface "+e+", did not find any Object types that implement it!")}return t}if(this.is_union(e)){var t=[];var h=0;var l=this._map_of_union_types.h[e];while(h=0){this.error("Cannot create a fragment or operation "+t.debug_name+" on a basic type, "+r,true)}var i=this.get_possible_object_types_from(r);var a=[];this.resolve_fragment_nodes(U.selections,[],a);var s=ee._new();var o=0;while(o0;var w=T.name.value;var S=T.alias==null?w:T.alias.value;if(t.is_operation){this.validate_directives(T,t)}var E=""+w+" -> "+S;if(g.indexOf(E)>=0){continue}g.push(E);var b=d.slice(0);b.push(w);var D=this.resolve_field(b,t);var O=this.resolve_type(D.type);switch(O._hx_index){case 0:var L=O.name;if(k){this.error("Cannot specify sub-fields of "+L+" at "+d.join(".")+" of operation "+t.debug_name,true)}m.h[S]=D;break;case 1:var V=O.name;if(k){this.error("Cannot specify sub-fields of "+V+" at "+d.join(".")+" of operation "+t.debug_name,true)}m.h[S]=D;break;case 2:var c=O.values;var R=O.name;if(k){this.error("Cannot specify sub-fields of "+R+" at "+d.join(".")+" of operation "+t.debug_name,true)}m.h[S]=D;break;case 3:var M=O.type_paths;var A=O.name;if(!k){this.error("Must specify sub-fields of "+A+" at "+d.join(".")+" of operation "+t.debug_name,true)}if(this.is_union(A)){if(H.find(T.selectionSet.selections,function(e){if(e.kind=="Field"){return $.field(e,"name").value!="__typename"}else{return false}})!=null){this.error("Can only specify fragment selections of union "+A+" at "+d.join(".")+" of operation "+t.debug_name,true)}}var C=n==0&&Y.endsWith(e,J.OP_OUTER_SUFFIX)?Y.replace(e,J.OP_OUTER_SUFFIX,J.OP_INNER_SUFFIX):e+"__"+w;var q=this.generate_type_based_on_selection_set(C,t,T.selectionSet,A,n+1);var F={type:null,is_array:D.is_array,is_optional:D.is_optional};m.h[S]=F;if(this.is_union(C)){F.type=z.TPath(C)}else if(n==0){F.type=z.TPath(C)}else{var N=this._types_by_name;if(Object.prototype.hasOwnProperty.call(N.h,C)){delete N.h[C]}W.remove(this._defined_types,C);F.type=z.TAnon(q)}break;case 4:var G=O.fields;var I=O.name;if(!k){this.error("Must specify sub-fields of "+I+" at "+d.join(".")+" of operation "+t.debug_name,true)}if(this.is_union(I)){if(H.find(T.selectionSet.selections,function(e){if(e.kind=="Field"){return $.field(e,"name").value!="__typename"}else{return false}})!=null){this.error("Can only specify fragment selections of union "+I+" at "+d.join(".")+" of operation "+t.debug_name,true)}}var j=n==0&&Y.endsWith(e,J.OP_OUTER_SUFFIX)?Y.replace(e,J.OP_OUTER_SUFFIX,J.OP_INNER_SUFFIX):e+"__"+w;var X=this.generate_type_based_on_selection_set(j,t,T.selectionSet,I,n+1);var P={type:null,is_array:D.is_array,is_optional:D.is_optional};m.h[S]=P;if(this.is_union(j)){P.type=z.TPath(j)}else if(n==0){P.type=z.TPath(j)}else{var Q=this._types_by_name;if(Object.prototype.hasOwnProperty.call(Q.h,j)){delete Q.h[j]}W.remove(this._defined_types,j);P.type=z.TAnon(X)}break}break;case"FragmentSpread":case"InlineFragment":this.error("Should not get fragment nodes here...",true);break;default:this.error("Unhandled sel_node kind "+y.kind,true)}}}if(i.length>1){this.generate_union_of_types(f,e);return this._types_by_name.h[e]}else{return this._types_by_name.h[e]}},validate_directives:function(e,t){if(e.directives!=null){var r=0;var n=e.directives;while(r=0){continue}var o=this._types_by_name.h[s];e.append(b.type_to_string(o));e.append("")}e.append("\n\n/* - - - - - - - - - - - - - - - - - - - - - - - - - */\n\n");return e.toString()},init_base_types:function(){var e=0;var t=J._basic_types;while(e=0){v=W.substr(v,v.indexOf(f)+f.length,null)}u.append(" public inline function as"+"__"+v+"():"+c+" return cast this;")}u.append("}");return u.toString();case 4:var m=e.name;var d=e.fields;var x={pack:[],name:b.gql_to_haxe_type_name_transforms(m),pos:b.FAKE_POS,kind:D.TDStructure,fields:[]};var g=d.h;var y=g;var T=Object.keys(g);var k=T.length;var w=0;while(w0&&x.isBlank(r[0]))r.shift();while(r.length>0&&x.isBlank(r[r.length-1]))r.pop();return r.join("\n")};x.getBlockStringIndentation=function(e){var t=null;var r=1;var n=e.length;while(r",0,0,0,0,null);var n=new _(t);n.source=e;n.lastToken=r;n.token=r;return n};_.prototype={advanceLexer:function(){this.lastToken=this.token;var e=this.token=this.lookahead();return e},lookahead:function(){var e=this.token;if(e.kind!=""){do{e=e.next!=null?e.next:e.next=this.readToken(this,e)}while(e.kind=="Comment")}return e},printCharCode:function(e){if(e<127){return JSON.stringify(String.fromCodePoint(e))}else{return"ESCMAD"}},readToken:function(e,t){var r=e.source;var n=r;var i=n.length;var a=this.positionAfterWhitespace(n,t.end,e);var s=e.line;var o=1+a-e.lineStart;if(a>=i){return k.asToken("",i,i,s,o,t)}var _=n.charCodeAt(a);switch(_){case 33:return k.asToken("!",a,a+1,s,o,t);case 34:if(n.charCodeAt(a+1)==34&&n.charCodeAt(a+2)==34){return this.readBlockString(r,a,s,o,t,e)}return this.readString(r,a,s,o,t);case 35:return this.readComment(r,a,s,o,t);case 36:return k.asToken("$",a,a+1,s,o,t);case 38:return k.asToken("&",a,a+1,s,o,t);case 40:return k.asToken("(",a,a+1,s,o,t);case 41:return k.asToken(")",a,a+1,s,o,t);case 46:if(n.charCodeAt(a+1)==46&&n.charCodeAt(a+2)==46){return k.asToken("...",a,a+3,s,o,t)}break;case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(r,a,_,s,o,t);case 58:return k.asToken(":",a,a+1,s,o,t);case 61:return k.asToken("=",a,a+1,s,o,t);case 64:return k.asToken("@",a,a+1,s,o,t);case 91:return k.asToken("[",a,a+1,s,o,t);case 93:return k.asToken("]",a,a+1,s,o,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return this.readName(r,a,s,o,t);case 123:return k.asToken("{",a,a+1,s,o,t);case 124:return k.asToken("|",a,a+1,s,o,t);case 125:return k.asToken("}",a,a+1,s,o,t)}throw Q.thrown(this.syntaxError(r,s,this.lineStart,a,this.unexpectedCharacterMessage(_)))},unexpectedCharacterMessage:function(e){if(e<32&&e!=9&&e!=10&&e!=13){return"Cannot contain the invalid character "+this.printCharCode(e)+"."}if(e==39){return"Unexpected single quote character ('), did you mean to use "+'a double quote (")?'}return"Cannot parse the unexpected character "+this.printCharCode(e)+"."},positionAfterWhitespace:function(e,t,r){var n=e.length;var i=t;while(i31||s==9);var _=t+1;var h=o;return k.asToken("Comment",t,o,r,n,i,w._new(a.string,w.wrap(a,_)+a.start,w.clamp(a,h)+a.start).toString())},readNumber:function(e,t,r,n,i,a){var s=e;var o=r;var _=t;var h=false;if(o==45){o=s.charCodeAt(++_)}if(o==48){o=s.charCodeAt(++_);if(o>=48&&o<=57){throw Q.thrown(this.syntaxError(e,n,this.lineStart,_,"Invalid number, unexpected digit after 0: "+this.printCharCode(o)+"."))}}else{_=this.readDigits(e,_,o);o=s.charCodeAt(_)}if(o==46){h=true;o=s.charCodeAt(++_);_=this.readDigits(e,_,o);o=s.charCodeAt(_)}if(o==69||o==101){h=true;o=s.charCodeAt(++_);if(o==43||o==45){o=s.charCodeAt(++_)}_=this.readDigits(e,_,o)}var l=t;var u=_;return k.asToken(h?"Float":"Int",t,_,n,i,a,w._new(s.string,w.wrap(s,l)+s.start,w.clamp(s,u)+s.start).toString())},readDigits:function(e,t,r){var n=e;var i=t;var a=r;if(a>=48&&a<=57){do{a=n.charCodeAt(++i)}while(a>=48&&a<=57);return i}throw Q.thrown(this.syntaxError(e,this.line,this.lineStart,i,"Invalid number, expected digit but got: "+this.printCharCode(a)+"."))},readString:function(e,t,r,n,i){var a=e;var s=t+1;var o=s;var _=0;var h="";while(true){var l;if(s=48&&e<=57){return e-48}else if(e>=65&&e<=70){return e-55}else if(e>=97&&e<=102){return e-87}else{return-1}},readName:function(e,t,r,n,i){var a=e;var s=a.length;var o=t+1;var _=0;while(true){var h;if(o!=s){_=a.charCodeAt(o);h=!isNaN(_)}else{h=false}if(!(h&&(_==95||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122))){break}++o}var l=t;var u=o;return k.asToken("Name",t,o,r,n,i,w._new(a.string,w.wrap(a,l)+a.start,w.clamp(a,u)+a.start).toString())},syntaxError:function(e,t,r,n,i){return s.syntaxError(e,t,r,n,i)}};var k=function(){};k.__name__=true;k.asToken=function(e,t,r,n,i,a,s){return{kind:e,start:t,end:r,line:n,column:i,value:s,prev:a,next:null}};var h=function(){};h.__name__=true;h.prototype={parseName:function(e){var t=this.expectToken(e,"Name");return{kind:"Name",value:t.value,loc:this.loc(e,t)}},parseDocument:function(e){var t=e.token;return{kind:"Document",definitions:this.many(e,"",re(this,this.parseDefinition),""),loc:this.loc(e,t)}},parseDefinition:function(e){if(this.peek(e,"Name")){switch(e.token.value){case"directive":case"enum":case"input":case"interface":case"scalar":case"schema":case"type":case"union":return this.parseTypeSystemDefinition(e);case"extend":return this.parseTypeSystemExtension(e);case"fragment":case"mutation":case"query":case"subscription":return this.parseExecutableDefinition(e)}}else if(this.peek(e,"{")){return this.parseExecutableDefinition(e)}else if(this.peekDescription(e)){return this.parseTypeSystemDefinition(e)}throw Q.thrown(this.unexpected(e))},parseExecutableDefinition:function(e){if(this.peek(e,"Name")){switch(e.token.value){case"fragment":return this.parseFragmentDefinition(e);case"mutation":case"query":case"subscription":return this.parseOperationDefinition(e)}}else if(this.peek(e,"{")){return this.parseOperationDefinition(e)}throw Q.thrown(this.unexpected(e))},parseOperationDefinition:function(e){var t=e.token;if(this.peek(e,"{")){return{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}}var r=this.parseOperationType(e);var n=null;if(this.peek(e,"Name")){n=this.parseName(e)}return{kind:"OperationDefinition",operation:r,name:n,variableDefinitions:this.parseVariableDefinitions(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseOperationType:function(e){var t=this.expectToken(e,"Name");switch(t.value){case"mutation":return"mutation";case"query":return"query";case"subscription":return"subscription"}throw Q.thrown(this.unexpected(e,t))},parseVariableDefinitions:function(e){if(this.peek(e,"(")){return this.many(e,"(",re(this,this.parseVariableDefinition),")")}else{return[]}},parseVariableDefinition:function(e){var t=e.token;var r=this.parseVariable(e);this.expectToken(e,":");return{kind:"VariableDefinition",variable:r,type:this.parseTypeReference(e),defaultValue:this.expectOptionalToken(e,"=")?this.parseValueLiteral(e,true):null,directives:this.parseDirectives(e,true),loc:this.loc(e,t)}},parseVariable:function(e){var t=e.token;this.expectToken(e,"$");return{kind:"Variable",name:this.parseName(e),loc:this.loc(e,t)}},parseSelectionSet:function(e){var t=e.token;return{kind:"SelectionSet",selections:this.many(e,"{",re(this,this.parseSelection),"}"),loc:this.loc(e,t)}},parseSelection:function(e){if(this.peek(e,"...")){return this.parseFragment(e)}else{return this.parseField(e)}},parseField:function(e){var t=e.token;var r=this.parseName(e);var n=null;var i=null;if(this.expectOptionalToken(e,":")){n=r;i=this.parseName(e)}else{i=r}return{kind:"Field",alias:n,name:i,arguments:this.parseArguments(e,false),directives:this.parseDirectives(e,false),selectionSet:this.peek(e,"{")?this.parseSelectionSet(e):null,loc:this.loc(e,t)}},parseArguments:function(e,t){var r=t?re(this,this.parseConstArgument):re(this,this.parseArgument);if(this.peek(e,"(")){return this.many(e,"(",r,")")}else{return[]}},parseArgument:function(e){var t=e.token;var r=this.parseName(e);this.expectToken(e,":");return{kind:"Argument",name:r,value:this.parseValueLiteral(e,false),loc:this.loc(e,t)}},parseConstArgument:function(e){var t=e.token;var r=this.parseName(e);this.expectToken(e,":");return{kind:"Argument",name:r,value:this.parseConstValue(e),loc:this.loc(e,t)}},parseFragment:function(e){var t=e.token;this.expectToken(e,"...");var r=this.expectOptionalKeyword(e,"on");if(!r&&this.peek(e,"Name")){return{kind:"FragmentSpread",name:this.parseFragmentName(e),directives:this.parseDirectives(e,false),loc:this.loc(e,t)}}return{kind:"InlineFragment",typeCondition:r?this.parseNamedType(e):null,directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseFragmentDefinition:function(e){var t=e.token;this.expectKeyword(e,"fragment");if(e.options.experimentalFragmentVariables){var r=this.parseFragmentName(e);var n=this.parseVariableDefinitions(e);this.expectKeyword(e,"on");return{kind:"FragmentDefinition",name:r,variableDefinitions:n,typeCondition:this.parseNamedType(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}}var r=this.parseFragmentName(e);this.expectKeyword(e,"on");return{kind:"FragmentDefinition",name:r,typeCondition:this.parseNamedType(e),directives:this.parseDirectives(e,false),selectionSet:this.parseSelectionSet(e),loc:this.loc(e,t)}},parseFragmentName:function(e){if(e.token.value=="on"){throw Q.thrown(this.unexpected(e))}return this.parseName(e)},parseValueLiteral:function(e,t){var r=e.token;switch(r.kind){case"$":if(!t){return this.parseVariable(e)}break;case"BlockString":case"String":return this.parseStringLiteral(e);case"Float":e.advance();return{kind:"FloatValue",value:r.value,loc:this.loc(e,r)};case"Int":e.advance();return{kind:"IntValue",value:r.value,loc:this.loc(e,r)};case"Name":if(r.value=="true"||r.value=="false"){e.advance();return{kind:"BooleanValue",value:r.value=="true",loc:this.loc(e,r)}}else if(r.value=="null"){e.advance();return{kind:"NullValue",loc:this.loc(e,r)}}e.advance();return{kind:"EnumValue",value:r.value,loc:this.loc(e,r)};case"[":return this.parseList(e,t);case"{":return this.parseObject(e,t);default:}throw Q.thrown(this.unexpected(e))},parseStringLiteral:function(e){var t=e.token;e.advance();return{kind:"StringValue",value:t.value,block:t.kind=="BlockString",loc:this.loc(e,t)}},parseConstValue:function(e){return this.parseValueLiteral(e,true)},parseValueValue:function(e){return this.parseValueLiteral(e,false)},parseList:function(e,t){var r=e.token;var n=t?re(this,this.parseConstValue):re(this,this.parseValueValue);return{kind:"ListValue",values:this.any(e,"[",n,"]"),loc:this.loc(e,r)}},parseObject:function(t,r){var n=this;var e=t.token;var i=function(e){return n.parseObjectField(t,r)};return{kind:"ObjectValue",fields:this.any(t,"{",i,"}"),loc:this.loc(t,e)}},parseObjectField:function(e,t){var r=e.token;var n=this.parseName(e);this.expectToken(e,":");return{kind:"ObjectField",name:n,value:this.parseValueLiteral(e,t),loc:this.loc(e,r)}},parseDirectives:function(e,t){var r=[];while(this.peek(e,"@"))r.push(this.parseDirective(e,t));return r},parseDirective:function(e,t){var r=e.token;this.expectToken(e,"@");return{kind:"Directive",name:this.parseName(e),arguments:this.parseArguments(e,t),loc:this.loc(e,r)}},parseTypeReference:function(e){var t=e.token;var r=null;if(this.expectOptionalToken(e,"[")){r=this.parseTypeReference(e);this.expectToken(e,"]");r={kind:"ListType",type:r,loc:this.loc(e,t)}}else{r=this.parseNamedType(e)}if(this.expectOptionalToken(e,"!")){return{kind:"NonNullType",type:r,loc:this.loc(e,t)}}return r},parseNamedType:function(e){var t=e.token;return{kind:"NamedType",name:this.parseName(e),loc:this.loc(e,t)}},parseTypeSystemDefinition:function(e){var t=this.peekDescription(e)?e.lookahead():e.token;if(t.kind=="Name"){switch(t.value){case"directive":return this.parseDirectiveDefinition(e);case"enum":return this.parseEnumTypeDefinition(e);case"input":return this.parseInputObjectTypeDefinition(e);case"interface":return this.parseInterfaceTypeDefinition(e);case"scalar":return this.parseScalarTypeDefinition(e);case"schema":return this.parseSchemaDefinition(e);case"type":return this.parseObjectTypeDefinition(e);case"union":return this.parseUnionTypeDefinition(e)}}throw Q.thrown(this.unexpected(e,t))},peekDescription:function(e){if(!this.peek(e,"String")){return this.peek(e,"BlockString")}else{return true}},parseDescription:function(e){if(!this.peekDescription(e)){return null}return this.parseStringLiteral(e)},parseSchemaDefinition:function(e){var t=e.token;this.expectKeyword(e,"schema");var r=this.parseDirectives(e,true);var n=this.many(e,"{",re(this,this.parseOperationTypeDefinition),"}");return{kind:"SchemaDefinition",directives:r,operationTypes:n,loc:this.loc(e,t)}},parseOperationTypeDefinition:function(e){var t=e.token;var r=this.parseOperationType(e);this.expectToken(e,":");var n=this.parseNamedType(e);return{kind:"OperationTypeDefinition",operation:r,type:n,loc:this.loc(e,t)}},parseScalarTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"scalar");var n=this.parseName(e);var i=this.parseDirectives(e,true);return{kind:"ScalarTypeDefinition",description:r,name:n,directives:i,loc:this.loc(e,t)}},parseObjectTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"type");var n=this.parseName(e);var i=this.parseImplementsInterfaces(e);var a=this.parseDirectives(e,true);var s=this.parseFieldsDefinition(e);return{kind:"ObjectTypeDefinition",description:r,name:n,interfaces:i,directives:a,fields:s,loc:this.loc(e,t)}},parseImplementsInterfaces:function(e){var t=[];if(this.expectOptionalKeyword(e,"implements")){this.expectOptionalToken(e,"&");do{t.push(this.parseNamedType(e))}while(this.expectOptionalToken(e,"&")||e.options.allowLegacySDLImplementsInterfaces&&this.peek(e,"Name"))}return t},parseFieldsDefinition:function(e){if(e.options.allowLegacySDLEmptyFields&&this.peek(e,"{")&&e.lookahead().kind=="}"){e.advance();e.advance();return[]}if(this.peek(e,"{")){return this.many(e,"{",re(this,this.parseFieldDefinition),"}")}else{return[]}},parseFieldDefinition:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);var i=this.parseArgumentDefs(e);this.expectToken(e,":");var a=this.parseTypeReference(e);var s=this.parseDirectives(e,true);return{kind:"FieldDefinition",description:r,name:n,arguments:i,type:a,directives:s,loc:this.loc(e,t)}},parseArgumentDefs:function(e){if(!this.peek(e,"(")){return[]}return this.many(e,"(",re(this,this.parseInputValueDef),")")},parseInputValueDef:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);this.expectToken(e,":");var i=this.parseTypeReference(e);var a=null;if(this.expectOptionalToken(e,"=")){a=this.parseConstValue(e)}var s=this.parseDirectives(e,true);return{kind:"InputValueDefinition",description:r,name:n,type:i,defaultValue:a,directives:s,loc:this.loc(e,t)}},parseInterfaceTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"interface");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseFieldsDefinition(e);return{kind:"InterfaceTypeDefinition",description:r,name:n,directives:i,fields:a,loc:this.loc(e,t)}},parseUnionTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"union");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseUnionMemberTypes(e);return{kind:"UnionTypeDefinition",description:r,name:n,directives:i,types:a,loc:this.loc(e,t)}},parseUnionMemberTypes:function(e){var t=[];if(this.expectOptionalToken(e,"=")){this.expectOptionalToken(e,"|");do{t.push(this.parseNamedType(e))}while(this.expectOptionalToken(e,"|"))}return t},parseEnumTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"enum");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseEnumValuesDefinition(e);return{kind:"EnumTypeDefinition",description:r,name:n,directives:i,values:a,loc:this.loc(e,t)}},parseEnumValuesDefinition:function(e){if(this.peek(e,"{")){return this.many(e,"{",re(this,this.parseEnumValueDefinition),"}")}else{return[]}},parseEnumValueDefinition:function(e){var t=e.token;var r=this.parseDescription(e);var n=this.parseName(e);var i=this.parseDirectives(e,true);return{kind:"EnumValueDefinition",description:r,name:n,directives:i,loc:this.loc(e,t)}},parseInputObjectTypeDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"input");var n=this.parseName(e);var i=this.parseDirectives(e,true);var a=this.parseInputFieldsDefinition(e);return{kind:"InputObjectTypeDefinition",description:r,name:n,directives:i,fields:a,loc:this.loc(e,t)}},parseInputFieldsDefinition:function(e){if(this.peek(e,"{")){return this.many(e,"{",re(this,this.parseInputValueDef),"}")}else{return[]}},parseTypeSystemExtension:function(e){var t=e.lookahead();if(t.kind=="Name"){switch(t.value){case"enum":return this.parseEnumTypeExtension(e);case"input":return this.parseInputObjectTypeExtension(e);case"interface":return this.parseInterfaceTypeExtension(e);case"scalar":return this.parseScalarTypeExtension(e);case"schema":return this.parseSchemaExtension(e);case"type":return this.parseObjectTypeExtension(e);case"union":return this.parseUnionTypeExtension(e)}}throw Q.thrown(this.unexpected(e,t))},parseSchemaExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"schema");var r=this.parseDirectives(e,true);var n=this.peek(e,"{")?this.many(e,"{",re(this,this.parseOperationTypeDefinition),"}"):[];if(r.length==0&&n.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"SchemaExtension",directives:r,operationTypes:n,loc:this.loc(e,t)}},parseScalarTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"scalar");var r=this.parseName(e);var n=this.parseDirectives(e,true);if(n.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"ScalarTypeExtension",name:r,directives:n,loc:this.loc(e,t)}},parseObjectTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"type");var r=this.parseName(e);var n=this.parseImplementsInterfaces(e);var i=this.parseDirectives(e,true);var a=this.parseFieldsDefinition(e);if(n.length==0&&i.length==0&&a.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"ObjectTypeExtension",name:r,interfaces:n,directives:i,fields:a,loc:this.loc(e,t)}},parseInterfaceTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"interface");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseFieldsDefinition(e);if(n.length==0&&i.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"InterfaceTypeExtension",name:r,directives:n,fields:i,loc:this.loc(e,t)}},parseUnionTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"union");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseUnionMemberTypes(e);if(n.length==0&&i.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"UnionTypeExtension",name:r,directives:n,types:i,loc:this.loc(e,t)}},parseEnumTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"enum");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseEnumValuesDefinition(e);if(n.length==0&&i.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"EnumTypeExtension",name:r,directives:n,values:i,loc:this.loc(e,t)}},parseInputObjectTypeExtension:function(e){var t=e.token;this.expectKeyword(e,"extend");this.expectKeyword(e,"input");var r=this.parseName(e);var n=this.parseDirectives(e,true);var i=this.parseInputFieldsDefinition(e);if(n.length==0&&i.length==0){throw Q.thrown(this.unexpected(e))}return{kind:"InputObjectTypeExtension",name:r,directives:n,fields:i,loc:this.loc(e,t)}},parseDirectiveDefinition:function(e){var t=e.token;var r=this.parseDescription(e);this.expectKeyword(e,"directive");this.expectToken(e,"@");var n=this.parseName(e);var i=this.parseArgumentDefs(e);this.expectKeyword(e,"on");var a=this.parseDirectiveLocations(e);return{kind:"DirectiveDefinition",description:r,name:n,arguments:i,locations:a,loc:this.loc(e,t)}},parseDirectiveLocations:function(e){this.expectOptionalToken(e,"|");var t=[];do{t.push(this.parseDirectiveLocation(e))}while(this.expectOptionalToken(e,"|"));return t},parseDirectiveLocation:function(e){var t=e.token;var r=this.parseName(e);if(h.ValidDirectiveLocations.h[r.value]){return r}throw Q.thrown(this.unexpected(e,t))},peek:function(e,t){return e.token.kind==t},expectToken:function(e,t){var r=e.token;if(r.kind==t){e.advance();return r}throw Q.thrown(this.syntaxError(e.source,e.line,e.lineStart,r.start,"Expected "+t+", found "+this.getTokenDesc(r)))},expectOptionalToken:function(e,t){var r=e.token;if(r.kind==t){e.advance();return r!=null}return false},expectKeyword:function(e,t){var r=e.token;if(r.kind=="Name"&&r.value==t){e.advance();return r}throw Q.thrown(this.syntaxError(e.source,e.line,e.lineStart,r.start,'Expected "'+t+'", found '+this.getTokenDesc(r)))},expectOptionalKeyword:function(e,t){var r=e.token;if(r.kind=="Name"&&r.value==t){e.advance();return r!=null}return false},unexpected:function(e,t){var r=t!=null?t:e.token;return this.syntaxError(e.source,e.line,e.lineStart,r.start,"Unexpected "+this.getTokenDesc(r))},any:function(e,t,r,n){this.expectToken(e,t);var i=[];while(!this.expectOptionalToken(e,n))i.push(r(e));return i},many:function(e,t,r,n){this.expectToken(e,t);var i=[r(e)];while(!this.expectOptionalToken(e,n))i.push(r(e));return i},loc:function(e,t){if(e.options!=null&&e.options.noLocation){return null}return{start:t.start,end:e.lastToken.end,startToken:t,endToken:e.lastToken,source:e.source}},syntaxError:function(e,t,r,n,i){return s.syntaxError(e,t,r,n,i)},getTokenDesc:function(e){return e.kind}};var A=function(e,t,r,n,i){this.file=e;this.min=t;this.max=r;this.line=n;this.col=i};A.__name__=true;var C=function(e,t){this.message=e;this.pos=t};C.__name__=true;var s=function(e,t,r){if(r==null){r="Untitled"}var n=new h;if(t==null){t={}}var i=_.createLexer(w.ofString(e),t);try{this.document=n.parseDocument(i)}catch(e){var a=Q.caught(e).unwrap();if(a instanceof C){var s=a;var o=s.pos!=null?""+s.pos.line+": characters "+s.pos.col+"-"+(s.pos.col+(s.pos.max-s.pos.min+1)):"";throw Q.thrown(""+r+":"+o+" Error: "+s.message)}else{throw e}}};s.__name__=true;s.syntaxError=function(e,t,r,n,i){var a=n-r;return new C(i,new A(null,n,n,t,a))};var o=function(e,t,r){this.string=e;this.start=t;this.end=r;if((this.length=r-t)<0){this.length=0;this.end=this.start}};o.__name__=true;o.prototype={toString:function(){if(this.representation==null){this.representation=this.string.substring(this.start,this.end)}return this.representation},charCodeAt:function(e){if(this.representation==null){this.representation=this.string.substring(this.start,this.end)}return W.cca(this.representation,e)}};var w={};w._new=function(e,t,r){return new o(e,t==e.length?t:t<0?t%e.length+e.length:t%e.length,r==e.length?r:r<0?r%e.length+e.length:r%e.length)};w.clamp=function(e,t){if(t<0){if(-t>e.length){return 0}else{return t+e.length}}else if(t>e.length){return e.length}else{return t}};w.wrap=function(e,t){if(e.length==0){return 0}else if(t<0){return t%e.length+e.length}else{return t%e.length}};w.ofString=function(e){if(e==null||e==""){return w.EMPTY}else if(e.length==1){var t=e.charCodeAt(0);if(t=5){return"<...>"}var e=typeof s;if(e=="function"&&(s.__name__||s.__ename__)){e="object"}switch(e){case"function":return"";case"object":if(s.__enum__){var t=v[s.__enum__];var _=t.__constructs__[s._hx_index];var r=_._hx_name;if(_.__params__){o=o+"\t";return r+"("+function(e){var t;var r=[];{var n=0;var i=_.__params__;while(true){if(!(n0?",":"")+f.__string_rec(s[h],o)}n+="]";return n}var l;try{l=s.toString}catch(i){return"???"}if(l!=null&&l!=Object.toString&&typeof l=="function"){var u=s.toString();if(u!="[object Object]"){return u}}var n="{\n";o+="\t";var p=s.hasOwnProperty!=null;var c=null;for(c in s){if(p&&!s.hasOwnProperty(c)){continue}if(c=="prototype"||c=="__class__"||c=="__super__"||c=="__interfaces__"||c=="__properties__"){continue}if(n.length!=2){n+=", \n"}n+=o+c+" : "+f.__string_rec(s[c],o)}o=o.substring(1);n+="\n"+o+"}";return n;case"string":return s;default:return String(s)}};function K(e){if(e instanceof Array)return new N(e);else return e.iterator()}function re(e,t){if(t==null)return null;if(t.__id__==null)t.__id__=m.$haxeUID++;var r;if(e.hx__closures__==null)e.hx__closures__={};else r=e.hx__closures__[t.__id__];if(r==null){r=t.bind(e);e.hx__closures__[t.__id__]=r}return r}m.$haxeUID|=0;if(typeof performance!="undefined"?typeof performance.now=="function":false){W.now=performance.now.bind(performance)}if(String.fromCodePoint==null)String.fromCodePoint=function(e){return e<65536?String.fromCharCode(e):String.fromCharCode((e>>10)+55232)+String.fromCharCode((e&1023)+56320)};String.__name__=true;Array.__name__=true;f.__toStr={}.toString;J.OP_PREFIX="OP_";J.OP_OUTER_SUFFIX="_Result";J.OP_INNER_SUFFIX="_InnerResult";J.OP_VARS_SUFFIX="_Vars";J.FRAGMENT_PREFIX="Fragment_";J.UNION_SELECTION_SEPARATOR="_ON_";J.ARGS_PREFIX="Args_";J.GENERATED_UNION_PREFIX="U_";J.DEFAULT_SEPARATOR="__";J._basic_types=["ID","String","Float","Int","Boolean"];b.bool_collision=false;b.FAKE_POS={min:0,max:0,file:"Untitled"};h.ValidDirectiveLocations=function(e){var t;var r=new F;r.h["QUERY"]=true;r.h["MUTATION"]=true;r.h["SUBSCRIPTION"]=true;r.h["FIELD"]=true;r.h["FRAGMENT_DEFINITION"]=true;r.h["FRAGMENT_SPREAD"]=true;r.h["INLINE_FRAGMENT"]=true;r.h["SCHEMA"]=true;r.h["SCALAR"]=true;r.h["OBJECT"]=true;r.h["FIELD_DEFINITION"]=true;r.h["ARGUMENT_DEFINITION"]=true;r.h["INTERFACE"]=true;r.h["UNION"]=true;r.h["ENUM"]=true;r.h["ENUM_VALUE"]=true;r.h["INPUT_OBJECT"]=true;r.h["INPUT_FIELD_DEFINITION"]=true;t=r;return t}(this);w.CHARS=function(e){var t;var r=[];{var n=0;while(n<128){var i=n++;r.push(new o(String.fromCodePoint(i),0,1))}}t=r;return t}(this);w.EMPTY=new o("",0,0);t.main()})(typeof exports!="undefined"?exports:typeof window!="undefined"?window:typeof self!="undefined"?self:this,typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this); diff --git a/test/buddy/Main.hx b/test/buddy/Main.hx index 3c03612..544e032 100644 --- a/test/buddy/Main.hx +++ b/test/buddy/Main.hx @@ -42,6 +42,7 @@ class Main { new tests.issues.Issue30(), new tests.issues.Issue31(), new tests.issues.Issue35(), + new tests.issues.Issue43(), ], reporter); runner.run(); diff --git a/test/buddy/tests/issues/Issue43.hx b/test/buddy/tests/issues/Issue43.hx new file mode 100644 index 0000000..6afa4f8 --- /dev/null +++ b/test/buddy/tests/issues/Issue43.hx @@ -0,0 +1,64 @@ +package tests.issues; + +import buddy.*; +using buddy.Should; + +class Issue43 extends BuddySuite +{ + public static inline var gql = + ' + enum ContentModuleType + { + POLL + TASKLIST + } + type TaskListModule { + content_type: ContentModuleType! + tasklist_id: ID! + } + type PollModule { + content_type: ContentModuleType! + poll_id: ID! + } + union ContentModule = PollModule | TaskListModule + type Query + { + content_module_by_id(id: ID!): ContentModule! + } + + query GetContentModuleById($$id: ID!) { + content_module_by_id(id: $$id) { + __typename + ... on TaskListModule { + content_type + tasklist_id + } + ... on PollModule { + content_type + poll_id + } + } + } + + '; + + public function new() { + describe("Issue43:", { + + var parser:graphql.parser.Parser; + + it('should parse this query document without error', { + parser = new graphql.parser.Parser(gql); + }); + + var haxe_code:String; + it("The HaxeGenerator should generate Haxe...", { + var result = graphql.HaxeGenerator.parse(parser.document); + haxe_code = result.stdout; + }); + + }); + + } + +} diff --git a/test/manual_debug/MutationTest.hx b/test/manual_debug/MutationTest.hx index 721611d..5abc9c5 100644 --- a/test/manual_debug/MutationTest.hx +++ b/test/manual_debug/MutationTest.hx @@ -1,4 +1,4 @@ -package; +1package; class Test { diff --git a/test/manual_debug/Test.hx b/test/manual_debug/Test.hx index 2f48def..1624892 100644 --- a/test/manual_debug/Test.hx +++ b/test/manual_debug/Test.hx @@ -1,4 +1,6 @@ package; +import sys.io.File; +//import Playground; class Test { @@ -13,6 +15,19 @@ class Test // test('schema-kitchen-sink.graphql'); // var source = sys.io.File.getContent(fn); + // Idea is to return the SDL Union as a Haxe Enum + // var pm = ContentModule.OnPollModule({content_type:POLL, poll_id:'1234'}); + // var tm = ContentModule.OnTasklistModule({content_type:TASKLIST,tasklist_id: '1234'}); + // var cm = SagaAPICMSClient.GetContentModuleById(/*..*/); + // switch (cm) { + // case ContentModule.OnPollModule({content_type:POLL, poll_id:'1234'}): + // trace('poll'); + // case ContentModule.OnTasklistModule({content_type:TASKLIST,tasklist_id: '1234'}): + // trace('tasklist'); + // default: + // trace('default'); + // } + trace('============================================================'); trace('============================================================'); trace('============================================================'); @@ -33,6 +48,7 @@ class Test if (result.stderr.length>0) { trace('Error:\n${ result.stderr }'); } else { + File.saveContent("GeneratedHaxe.hx", cast result.stdout); trace(result.stdout); } trace('============================================================'); diff --git a/test/manual_debug/ga.txt b/test/manual_debug/ga.txt new file mode 100644 index 0000000..d8fcb1d --- /dev/null +++ b/test/manual_debug/ga.txt @@ -0,0 +1,13 @@ + { + "kind": "Field", + "alias": null, + "name": { + "kind": "Name", + "value": "tasklist_id", + "loc": null + }, + "arguments": [], + "directives": [], + "selectionSet": null, + "loc": null + } \ No newline at end of file diff --git a/test/manual_debug/invalid_value.gql b/test/manual_debug/invalid_value.gql new file mode 100644 index 0000000..703cbfa --- /dev/null +++ b/test/manual_debug/invalid_value.gql @@ -0,0 +1,17 @@ + +type Foo { + age: Int + name: String + stars: String +} + +type Query { + get_invalid: Foo +} + +query GetInvalidTypedField { + get_invalid { + name + stars + } +} diff --git a/test/manual_debug/issue43.gql b/test/manual_debug/issue43.gql new file mode 100644 index 0000000..a9df3b9 --- /dev/null +++ b/test/manual_debug/issue43.gql @@ -0,0 +1,1678 @@ +################### +# Enums +################### + + +################### +# Types +################### + +################### +# Inputs +################### + + +######################## +# Queries and Mutations +######################## + +extend type Query +{ + cms_alive(dummy: String!):StatusWithMsgPayload! + cms_resolver(dummy: String!):StatusWithMsgPayload! +} + +extend type Mutation +{ + cms_mutator(dummy: String!):StatusWithMsgPayload! +} + + + + +################### +# Enums +################### + + +################### +# Types +################### + +enum ContentModuleType +{ + POLL + TASKLIST +} + +union ContentModule = PollModule | TaskListModule + +type TaskListModule { + content_type: ContentModuleType! + tasklist_id: ID! +} + +type PollModule { + content_type: ContentModuleType! + poll_id: ID! +} + + +################### +# Inputs +################### + + +######################## +# Queries and Mutations +######################## + +extend type Query +{ + content_module_by_id(id: ID!): ContentModule! +} + +#extend type Mutation +#{ +# +#} + + + + + +# Descriptions: Types for LearnGalleryContentController.hx + +################### +# Types +################### + +type SubjectFilters { + name: String! + tags: [String!]! + filters: [String!]! +} + +type SiloFilters { + content_silo: String! + subjects: [SubjectFilters]! +} + +################### +# Inputs +################### + +input ContentSearchArgs { + content_silo: String! + search_terms: [String!] + title_search_terms: String + activity_search: Boolean + span_search:Boolean + limit: Int + offset: Int + user_id: String +} + +######################## +# Queries and Mutations +######################## + +extend type Query +{ + content_silo_filters(content_silo: String!):SiloFilters! + content_by_search_args(input: ContentSearchArgs!):PaginatedContent! +} + + +# Base Query +type Query { + version : String +} + +# Base Mutation +type Mutation { + version : String +} + +# Generic status payload for mutators +type StatusPayload { + success : Boolean! +} + +# Generic status payload (with optional error message) +type StatusWithMsgPayload { + success : Boolean! + msg : String +} + +type StatusWithErrorsPayload { + success : SuccessState! + errors : [String] +} + +enum SuccessState { + SUCCESS + PARTIAL + FAILURE +} + +type StatusIDPayload { + success : Boolean! + id : String +} + +# Generic payload for refetch operations +type RefetchPayload { + id : String + operation : RefetchOperation + success : Boolean! +} + +# CRUD refetch operation +enum RefetchOperation { + INSERT + READ + DELETE + UPDATE + NONE +} + +type DateTimeRange { + start : DateTime! + end : DateTime! +} + +input DateTimeRangeInput { + start : DateTime! + end : DateTime! +} + +type TimeRange { + start : Time! + end : Time! +} + +input TimeRangeInput { + start : Time! + end : Time! +} + +enum ClientUserType { + SCHOLAR + TUTOR + ADMIN +} + +type User { + user_id : String! + username : String! + email_verified : Boolean! + created : String! + last_update : String! + user_type : ClientUserType! + role : UserRole! + organization : String! + email : String + name_first : String + name_last : String + phone : String +} + +type UserGroup { + user_group_id : String! + user_group_name : String! + users : [String!] + group_context : GroupContext +} + +enum UserRole { + USER # Generic user role + TUTOR + SCHOLAR + ADMIN + LEARNING_COORDINATOR + SITE_DIRECTOR + DIRECTOR_OF_PROGRAMS + SKYE_USER + COACH_USER +} + +# Details of a group's function +# TODO this should be a union type when we have different app contexts that will utilize this +type GroupContext { + owner_id: String! # The SD or Tutor who owns this group + group_id: String! # The SQL group_id + group_type: GroupType! # UNASSIGNED_SCHOLARS or CLASS_PERIOD + period_name: String # The period number + block_index: Int # Index representing A or B block + # ! TODO 3620 remove this - making it optional for now + app_context: String # The app context in which this group is used +} + +enum GroupType { + UNASSIGNED_SCHOLARS + CLASS_PERIOD +} + +# Auth inputs also used by IAM +input RegisterNewUserInput { + email: String! + name_first: String! + name_last: String! + password: String! + phone: String +} + +input UpdateUserInput { + user_id: String! + email: String + name_first: String + name_last: String + password: String + organization: String + phone: String +} +# graphql-scalar +scalar DateTime +scalar Time +scalar Timezone +############################################ +# Content +############################################ + +type Content implements Viewable +{ + view_type : ViewType! # Viewable + id : ID! + title : String + short_title : String + last_modified : String! + created_on : String # Opt: interleaved AP has no created_on + gallery_image_id : String! + tag_list : [String]! + owner_id : String! + published_by_name : String! + description : String! + usage_label : UsageLabel! + content_type : ContentType! + external_content_data : ExternalContentData! + meta_searchable : Searchable + meta_favoritable : Favoritable + meta_lockable : Lockable + popularity : Float + grade_level : Int + content_silos : [String] # WOOTMATH, SAGA, etc... null implies WOOTMATH +} + + +# application specific content type +enum ContentType { + ADAPTIVE_TUTOR + REAL_TIME_POLLS + MATH_JAM +} + +type ExternalContentData { + content_id : ID! + owner_id : ID! + app_data : AppContentData! +} + +input RefetchExternalContentDataInput { + content_id : ID! + content_type : ContentType! +} + +# application specific content data +union AppContentData = RTPContentData | APContentData + +type RTPContentData { + poll_id: String! + staff_pick: Boolean + mdval: Int +} + +# book_name (not id) is in the CMS, so we'll stick with that, e.g. rational_numbers_intro_1, frac_refresh_3 +type APContentData { + # Required to start the app at the right place: + wma_version : String! + book_name : String! + # Required to display the content + book_character : String! + book_title : String! + grade_level : String! +} + +# usage modality +enum UsageLabel { + WARMUP + EXIT_TICKET + CLASS_DISCUSSION + QUIZ + HOMEWORK + LEGACY + AP_BOOK + TEAM_ACTIVITY +} + +input CreateContentFromAPInput { + wma_version : String! + book_name : String! + book_character : String! + book_title : String! + grade_level : String! +} + +type CreateContentPayload { + id : ID + title : String +} + +input UpdateContentPopularityInput { + content_data : [ContentPopularityData]! +} + +input ContentPopularityData { + content_id : ID! + external_content_id : String! +} + +type UpdateContentPopularityPayload { + success : Boolean! +} + +type PaginatedContent { + has_next : Boolean! + content : [Content]! +} + +input RTPExternalContentDataInput { + content_id : ID! + owner_id : ID! + app_data : RTPAppContentDataInput +} + +input RTPAppContentDataInput { + poll_id : String! +} + +############################################ +# Content Instance Data +############################################ + +type ContentInstance implements Viewable +{ + id : ID! + usage_label : UsageLabel! + gallery_image_id : String! + tag_list : [String]! + title : String + view_type : ViewType! + content_type : ContentType! + published_by_name : String! + teacher_id : String! + course_provider : CourseProvider! + section_id : String! + external_instance_data : ExternalInstanceData! + content_silos : [String] +} + +type RTPInstanceData { + instance_id : String! +} + +type APInstanceData { + wma_version : String! + book_name : String! + book_character : String! + book_title : String! + grade_level : String! +} + +union ExternalInstanceData = RTPInstanceData | APInstanceData + +input RefetchContentInstanceInput { + teacher_id : String! + course_provider : CourseProvider! + section_id : String! + content_id : ID! + content_type : ContentType! + instance_id : ID + external_instance_id : ID +} + +############################################ +# Queries +############################################ + +extend type Query +{ + # content + all_content(with_details:Boolean, limit: Int, offset: Int): PaginatedContent + content_by_content_silo(content_silos:[String]!, limit: Int, offset: Int): PaginatedContent + my_content(user_id: ID!, with_details:Boolean, limit: Int, offset: Int): PaginatedContent + my_favorite_content(user_id: ID!, with_details:Boolean, limit: Int, offset: Int): PaginatedContent + # "Decorated" means favs / unlockable state populated per user_id, but it's not required + decorated_public_content(user_id: ID, gallery_flags:GalleryFlags, limit: Int, offset: Int): PaginatedContent + my_premium_content(user_id: ID!, with_details:Boolean, limit: Int, offset: Int, sort_by_lock_state: Boolean, active_content_only: Boolean): PaginatedContent + external_content_ids_by_content_type(content_types:[ContentType]!): [Content] + content_by_external_content_id(content_type:ContentType, external_content_id:ID): Content + content_by_ids(content_ids: [String!]!): [Content]! +} + + +fragment CommonAPContentData on APContentData { + wma_version + book_name + book_character + book_title + grade_level +} + +fragment CommonAPInstanceData on APInstanceData { + wma_version + book_name + book_character + book_title +} + + +################################## +## Fragments on content queries +################################## + +fragment CommonContentExtData on Content { + external_content_data { + content_id + owner_id + app_data { + ...on RTPContentData { + poll_id + staff_pick + mdval + } + ...on APContentData { ...CommonAPContentData } + } + } +} + +# This one is used by the Riot content views as their opts type +fragment CommonContentFields on Content { + # Basic fields + id + title + short_title + last_modified + usage_label + gallery_image_id + published_by_name + content_type + content_silos + created_on + + # Include common ExtData + ...CommonContentExtData + + # Where should we put these? + meta_lockable { + state + } + + meta_favoritable { + favorite_count + user_favorite + } + + meta_searchable { # Displayed by the slug view... + tag_list + } +} + +query AllContent($limit: Int, $offset: Int) { + all_content(limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query ContentByContentSilo($content_silos: [String]!, $limit: Int, $offset: Int) { + content_by_content_silo(content_silos: $content_silos, limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query MyContent($user_id: ID!, $limit: Int, $offset: Int) { + my_content(user_id: $user_id, limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query MyFavoriteContent($user_id: ID!, $limit: Int, $offset: Int) { + my_favorite_content(user_id: $user_id, limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query DecoratedPublicContent($user_id: ID, $gallery_flags: GalleryFlags, $limit: Int, $offset: Int) { + decorated_public_content(user_id: $user_id, gallery_flags: $gallery_flags, limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query MyPremiumContent($user_id: ID!, $limit: Int, $offset: Int, $sort_by_lock_state: Boolean, $active_content_only: Boolean) { + my_premium_content(user_id: $user_id, limit: $limit, offset: $offset, sort_by_lock_state: $sort_by_lock_state, active_content_only: $active_content_only) { + has_next + content { + ...CommonContentFields + } + } +} + +query GetExternalContentIDsByContentType($content_types: [ContentType]!) { + external_content_ids_by_content_type(content_types: $content_types) { + id + external_content_data { + content_id + } + } +} + +query GetContentByExternalContentID($content_type:ContentType, $external_content_id:ID) { + content_by_external_content_id(content_type:$content_type, external_content_id:$external_content_id) { + ...CommonContentFields + } +} + +# TODO: Adam, you might need a different fragment setup for search. Let's talk... +query SearchContent($search_terms: [SearchFacet!]!, $gallery_flags: GalleryFlags, $teacher_id: String, $owner_id: String, $limit: Int, $offset: Int) { + search_content(search_terms: $search_terms, gallery_flags: $gallery_flags, teacher_id: $teacher_id, owner_id: $owner_id, limit: $limit, offset: $offset) { + has_next + content { + ...CommonContentFields + } + } +} + +query SearchUnselectedTerms($search_terms: [SearchFacet!]!, $gallery_flags: GalleryFlags, $unselected_terms: [SearchFacet!]!, $teacher_id: String, $owner_id: String) { + search_unselected_terms(search_terms: $search_terms, gallery_flags: $gallery_flags, unselected_terms: $unselected_terms, teacher_id: $teacher_id, owner_id: $owner_id) { + counts + } +} + +query SearchTypeahead($query: String!) { + search_typeahead(query: $query) { + suggestions + } +} + +query GetContentByIDs($content_ids: [String!]!) { + content_by_ids(content_ids: $content_ids) { + ...CommonContentFields + } +} + +############################################ +# Mutations +############################################ + +extend type Mutation { + # single typed input and typed payload, + # see https://dev-blog.apollodata.com/designing-graphql-mutations-e09de826ed97 + create_content_from_ap(input: CreateContentFromAPInput!):CreateContentPayload + # delete_content(input: DeleteContentInput!):DeleteContentPayload + refetch_external_content_data(input: RefetchExternalContentDataInput!):RefetchPayload + update_content_popularity(input: UpdateContentPopularityInput!):UpdateContentPopularityPayload + # Bug Scrub 9/21 + add_active_premium_content(input: AddActivePremiumContentInput!):StatusPayload + # content instance (instance data) + refetch_content_instance(input: RefetchContentInstanceInput!):RefetchPayload +} + + +mutation RefetchExternalContentData($input: RefetchExternalContentDataInput!) { + refetch_external_content_data(input: $input) { + success + id + operation + } +} + +mutation RefetchContentInstance($input: RefetchContentInstanceInput!) { + refetch_content_instance(input: $input) { + success + id + operation + } +} + +mutation UpdateContentPopularity($input: UpdateContentPopularityInput!) { + update_content_popularity(input: $input) { + success + } +} + +mutation CreateContentFromAP($input: CreateContentFromAPInput!) { + create_content_from_ap(input: $input) { + id + title + } +} + +# Bug Scrub 9/21 +mutation AddActivePremiumContent($input: AddActivePremiumContentInput!) { + add_active_premium_content(input: $input) { + success + } +} + +# Bug Scrub 9/21 +input AddActivePremiumContentInput { + teacher_id : String! + content_id : ID! +} +enum AuthnProvider { + WOOTMATH + GOOGLE + CLEVER + LTI + ANONYMOUS +} + +enum AuthzProvider { + GOOGLE + CLEVER +} + +type ExternAuthn { + id: String! + authn_provider:AuthnProvider! +} + +######################################################## +# Saga Connect auth - via their own email / password, or +######################################################## +type SCATPInfo { + id : String!, + name : String! +} +union SCAuthType = SCATPhone | SCATEmail | SCATParent | SCATTeacher +type SCATEmail { + id : String! + by_email : Boolean! +} +type SCATPhone { + id : String! + by_phone : Boolean! +} +type SCATParent { + id : String! + by_parent : Boolean! + info : [SCATPInfo]! +} +type SCATTeacher { + teacher_id : String! + by_teacher : Boolean! +} + +type StudentPII { + student_id: String! + email: String + phone: String +} + +extend type Query +{ + check_saga_connect_auth_step1(step1: String!): SCAuthType + swap_parent_for_student_auth(student_id: String!): StatusPayload + student_pii(student_id: String!): StudentPII! +} + +query CheckSagaConnectAuthStep1($step1: String!) { + check_saga_connect_auth_step1(step1: $step1) { + ...on SCATPhone { id, by_phone } + ...on SCATEmail { id, by_email } + ...on SCATParent { by_parent, info { id, name } } + ...on SCATTeacher { by_teacher, teacher_id } + } +} + +query SwapParentForStudentAuth($student_id: String!) { + swap_parent_for_student_auth(student_id: $student_id) { + success + } +} + +query GetStudentPII($student_id: String!) { + student_pii(student_id: $student_id) { + student_id + email + phone + } +} +########################################### +# Admin Schema +############################################ + +type Admin { + admin_id : String! + teacher_id : String! + admin_role : AdminRole! + districts : [String] + schools : [String] + teachers : [String] +} + +enum AdminRole { + ACCOUNT_MANAGEMENT + DATA_REVIEW + CO_TEACHER + TUTOR_ADMIN + SUPERVISOR + MANAGER + DIRECTOR +} + +type School { + school_id : String! + name : String! + teachers : [Teacher]! +} + +type Teacher { + teacher_id : String! + username : String! + email : String! + sections : [Roster] + name_first : String! + name_last : String! + school_id : String + password : String +} + +input AddTeacherToAdminInput { + admin_id : String! + teacher_id : String! + nces_school_number : String +} + +input RemoveTeacherFromAdminInput { + admin_id : String! + teacher_id : String! +} + +type ModifyAdminTeacherPayload { + operation : ModifyAdminTeacherOperation! + success : Boolean! + message : String + error_code : String +} + +enum ModifyAdminTeacherOperation { + ADD + REMOVE +} + +input CreateTeacherAccountInput { + admin_id : String! + email : String! + name_first : String! + name_last : String! + password : String! + nces_school_number : String! +} + +type CreateTeacherAccountPayload { + success : Boolean! + teacher_id : String + site_code : String + error_code : String +} + +input UpdateTeacherAccountInput { + teacher_id : String! + admin_id : String! + username : String + email : String + name_first : String + name_last : String + password : String + nces_school_number : String +} + +type UpdateTeacherAccountPayload { + success : Boolean! + email : String + username : String + name_first : String + name_last : String + error_code : String +} + +input CreateAdminInput { + admin_role : AdminRole! + teacher_id : String + email : String + name_first : String + name_last : String + password : String +} + +input UpdateAdminRoleInput { + teacher_id : String! + admin_role : AdminRole! +} + +input RemoveAdminRoleInput { + teacher_id : String! +} + +############################################ +# Queries and Mutations +############################################ + +extend type Query { + get_schools_by_admin_id(admin_id: String!, school_ids: [String], teacher_ids: [String], section_ids: [String] ):[School]! + is_admin(teacher_id: String!):Boolean! + has_admin_role(teacher_id: String!, admin_role:AdminRole!):Boolean! + has_admin_roles(teacher_id: String!, admin_roles:[AdminRole]!):Boolean! + has_admin_organization(teacher_id: String!):Boolean! + admin_details(teacher_id: String!):Admin! + admin_details_by_email(email: String!):Admin! + contact_admin(teacher_id: String!, message: String!): StatusWithErrorsPayload! + teacher_id_by_email(email: String!): String + teacher_email_by_id(teacher_id: String!): String +} + +query IsAdmin($teacher_id: String!) { + is_admin(teacher_id: $teacher_id) +} + +query HasAdminRole($teacher_id: String!, $admin_role:AdminRole!) { + has_admin_role(teacher_id: $teacher_id, admin_role: $admin_role) +} + +query HasAdminRoles($teacher_id: String!, $admin_roles:[AdminRole]!) { + has_admin_roles(teacher_id: $teacher_id, admin_roles: $admin_roles) +} + +query HasAdminOrganization($teacher_id: String!) { + has_admin_organization(teacher_id: $teacher_id) +} + +fragment AdminFields on Admin { + admin_id + teacher_id + admin_role + districts + schools + teachers +} + +query GetAdminDetails($teacher_id: String!) { + admin_details(teacher_id: $teacher_id) { + ...AdminFields + } +} + +query GetAdminDetailsByEmail($email: String!) { + admin_details_by_email(email: $email) { + ...AdminFields + } +} + +query GetSchoolsByAdminID($admin_id: String!, $school_ids: [String], $teacher_ids: [String], $section_ids: [String]) { + get_schools_by_admin_id(admin_id: $admin_id, school_ids: $school_ids, teacher_ids: $teacher_ids, section_ids:$section_ids) { + school_id + name + teachers { + username + teacher_id + email + name_first + name_last + school_id + sections { + course_provider + section_name + section_id + grade + students { + username + student_id + name_last + name_first + grade + extern_authn { + id + authn_provider + } + } + } + } + } +} + +query ContactAdmin($teacher_id: String!, $message: String!) { + contact_admin(teacher_id: $teacher_id, message: $message) { + success + errors + } +} + +query GetTeacherIDByEmail($email: String!) { + teacher_id_by_email(email: $email) +} + +query GetTeacherEmailByID($teacher_id: String!) { + teacher_email_by_id(teacher_id: $teacher_id) +} + +extend type Mutation { + add_teacher_to_admin(input: AddTeacherToAdminInput!):ModifyAdminTeacherPayload! + remove_teacher_from_admin(input: RemoveTeacherFromAdminInput!):ModifyAdminTeacherPayload! + create_teacher_account(input: CreateTeacherAccountInput!):CreateTeacherAccountPayload! + update_teacher_account(input: UpdateTeacherAccountInput!):UpdateTeacherAccountPayload! + create_admin(input: CreateAdminInput!): StatusIDPayload! + update_admin_role(input: UpdateAdminRoleInput!): StatusPayload! + remove_admin_role(input: RemoveAdminRoleInput!): StatusPayload! +} + +mutation AddTeacherToAdmin($input: AddTeacherToAdminInput!) { + add_teacher_to_admin(input: $input) { + operation + success + message + error_code + } +} + +mutation RemoveTeacherFromAdmin($input: RemoveTeacherFromAdminInput!) { + remove_teacher_from_admin(input: $input) { + operation + success + message + error_code + } +} + +mutation CreateTeacherAccount($input: CreateTeacherAccountInput!) { + create_teacher_account(input: $input) { + success + teacher_id + site_code, + error_code + } +} + +mutation UpdateTeacherAccount($input: UpdateTeacherAccountInput!) { + update_teacher_account(input: $input) { + success + email + name_first + name_last + error_code + } +} + +mutation CreateAdmin($input: CreateAdminInput!) { + create_admin(input: $input) { + success + id + } +} + +mutation UpdateAdminRole($input: UpdateAdminRoleInput!) { + update_admin_role(input: $input) { + success + } +} + +mutation RemoveAdminRole($input: RemoveAdminRoleInput!) { + remove_admin_role(input: $input) { + success + } +} +############################################ +# Favoritable Decorator +############################################ + +type Favoritable { + favorite_count : Int! + user_favorite : Boolean! +} + +input FavoriteContentInput { + user_id : String! + content_id : ID! +} + +type FavoriteContentPayload { + is_now_fav : Boolean + ae_rids : [String] +} + + +############################################ +# Mutations +############################################ + +extend type Mutation +{ + toggle_favorite_content(input: FavoriteContentInput!):FavoriteContentPayload +} + +mutation ToggleFavoriteContent($input: FavoriteContentInput!) { + toggle_favorite_content(input: $input) { + is_now_fav + ae_rids + } +} +############################################ +# Lockable Decorator +############################################ + +type Lockable { + state :LockState! +} + +enum LockState { + LOCKED + UNLOCKED +} +########################################### +# Roster Schema +############################################ + +type Roster { + course_provider : CourseProvider! + section_name : String! + section_id : String! + grade : String + students : [Student] + sis_id : String # optional Clever param +} + +type Student { + username : String! + student_id : String! + name_first : String + name_last : String + grade : String + # ExternalAuthn from auth.gql -- ToDo : require this field after routes are baked + extern_authn : ExternAuthn +} + +input CreateSectionInput { + teacher_id : String! + section_name : String! + grade : String! + admin_id : String # Only needed if action performed by an admin +} + +type CreateSectionPayload { + success : Boolean! + section_id : String + message : String + error_code : String +} + +input UpdateSectionInput { + teacher_id : String! + section_id : String! + operation : UpdateOperation! + section_name : String! + grade : String + admin_id : String # Only needed if action performed by an admin +} + +type UpdateSectionPayload { + success : Boolean! + message : String + error_code : String +} + +enum UpdateOperation { + UPDATE + DELETE + ARCHIVE +} + +input CreateStudentInSectionInput { + section_id : String! + teacher_id : String! + username : String! + password : String! + name_first : String + last_initial : String + grade : String + admin_id : String # Only needed if action performed by an admin +} + +type CreateStudentInSectionPayload { + success : Boolean! + student_id : String + message : String + error_code : String +} + +input DeleteStudentFromSectionInput { + student_id : String! + section_id : String! + teacher_id : String! + admin_id : String # Only needed if action performed by an admin +} + +type DeleteStudentFromSectionPayload { + success : Boolean! + student_id : String + message : String + error_code : String +} + +input MoveStudentSectionInput { + student_id : String! + from_section_id : String! + to_section_id : String! + teacher_id : String + admin_id : String # Only needed if action performed by an admin +} + +type MoveStudentSectionPayload { + success : Boolean! + student_id : String! + message : String + error_code : String +} + +input UpdateStudentSettingsInput { + student_id : String! + teacher_id : String! + section_id : String + username : String + password : String + name_first : String + last_initial : String + grade : String + admin_id : String # Only needed if action performed by an admin + email : String + phone : String +} + +type UpdateStudentSettingsPayload { + success : Boolean! + student_id : String + username : String + message : String + error_code : String +} + +input CSVRosterInput { + admin_id : String! + schools : [CSVRosterSchoolInput]! +} + +input CSVRosterSchoolInput { + nces_school_number : String! + teachers : [CSVRosterTeacherInput]! +} + +input CSVRosterTeacherInput { + email : String! + sections : [CSVRosterSectionInput]! + username : String + name_first : String + name_last : String + password : String +} + +input CSVRosterSectionInput { + section_name : String! + students : [CSVRosterStudentInput]! + grade : String +} + +input CSVRosterStudentInput { + username : String! + password : String + name_first : String + last_initial : String + grade : String +} + +type ValidateCSVRosterPayload { + is_valid : Boolean! + errors : [String]! +} + +type ProcessCSVRosterPayload { + result : ProcessCSVRosterResult! + inserted_teachers : [Teacher] + inserted_sections : [Roster] + inserted_students : [Student] + updated_teachers : [Teacher] + updated_sections : [Roster] + updated_students : [Student] + errors : [String] +} + +enum ProcessCSVRosterResult { + SUCCESS + PARTIAL + FAILURE +} + +enum CourseProvider { + WOOTMATH + CLEVER + LTI + GOOGLE + ANONYMOUS +} + +############################################ +# Queries and Mutations +############################################ + +extend type Query +{ + get_roster_by_section_id(section_id: String!, teacher_id: String!, course_provider:CourseProvider!):Roster + get_rosters_by_teacher_id(teacher_id: String!):[Roster] + get_section_ids_by_teacher_id(teacher_id: String!):[String] + # need to provide roster data to bill or ask Jeff to provide from login + # get_roster_by_assignment_id(aid:String!) +} + +query GetSectionIDsByTeacherID($teacher_id: String!) { + get_section_ids_by_teacher_id(teacher_id: $teacher_id) +} + +fragment CommonRosterData on Roster { + section_id + course_provider + section_name + grade + students { + username + student_id + extern_authn { + id + authn_provider + } + } + sis_id +} + +query GetRosterBySectionID($section_id: String!, $teacher_id: String!, $course_provider: CourseProvider!) { + get_roster_by_section_id(section_id: $section_id, teacher_id: $teacher_id, course_provider: $course_provider) { + ...CommonRosterData + students { + username + student_id + extern_authn { + id + authn_provider + } + } + } +} + +query GetRostersByTeacherID($teacher_id: String!) { + get_rosters_by_teacher_id(teacher_id: $teacher_id) { + ...CommonRosterData + } +} + +extend type Mutation +{ + create_section(input: CreateSectionInput!): CreateSectionPayload, + update_section(input: UpdateSectionInput!): UpdateSectionPayload, + create_student_in_section(input: CreateStudentInSectionInput!):CreateStudentInSectionPayload, + delete_student_from_section(input: DeleteStudentFromSectionInput!):DeleteStudentFromSectionPayload + move_student_section(input: MoveStudentSectionInput!):MoveStudentSectionPayload!, + update_student_settings(input: UpdateStudentSettingsInput!): UpdateStudentSettingsPayload + validate_csv_roster(input: CSVRosterInput!): ValidateCSVRosterPayload + process_csv_roster(input: CSVRosterInput!): ProcessCSVRosterPayload +} + +mutation CreateSection($input: CreateSectionInput!) { + create_section(input: $input) { + success + section_id + message + error_code + } +} + +mutation UpdateSection($input: UpdateSectionInput!) { + update_section(input: $input) { + success + message + error_code + } +} + +mutation CreateStudentInSection($input: CreateStudentInSectionInput!) { + create_student_in_section(input: $input) { + success + student_id + message + error_code + } +} + +mutation DeleteStudentFromSection($input: DeleteStudentFromSectionInput!) { + delete_student_from_section(input: $input) { + success + student_id + message + error_code + } +} + +mutation MoveStudentSection($input: MoveStudentSectionInput!) { + move_student_section(input: $input) { + success + student_id + message + error_code + } +} + +mutation UpdateStudentSettings($input: UpdateStudentSettingsInput!) { + update_student_settings(input: $input) { + success + student_id + username + message + error_code + } +} + +mutation ValidateCSVRoster($input: CSVRosterInput!) { + validate_csv_roster(input: $input) { + is_valid + errors + } +} + +mutation ProcessCSVRoster($input: CSVRosterInput!) { + process_csv_roster(input: $input) { + result + inserted_teachers { + teacher_id + username + email + name_first + name_last + } + inserted_sections { + course_provider + section_name + section_id + grade + } + inserted_students { + username + student_id + name_first + name_last + grade + extern_authn { + id + authn_provider + } + } + updated_teachers { + teacher_id + username + email + name_first + name_last + } + updated_sections { + course_provider + section_name + section_id + grade + } + updated_students { + username + student_id + name_first + name_last + grade + extern_authn { + id + authn_provider + } + } + errors + } +} + +############################################ +# Searchable Decorator +############################################ + +type Searchable { + id : ID! + content_type : ContentType! + description : String + parent_id : ID! + published_by_name : String! + tag_list : [String]! + owner_id : String! + owner_name : String! + sharing : SharingType! + title : String + view_type : ViewType! + last_modified : String! + question_count : Int +} + +enum SharingType { + PUBLIC + PRIVATE + AWAITING_MODERATION + DENIED + SILOED +} + + input RTPSearchableInput { + question_count : Int + sharing : SharingType +} + +enum GFSort { + DEFAULT + AWS + AVERAGE + NEWEST + OLDEST +} + +enum SearchFacetCategory { # a subset of user_website_data.FacetCategory + SEARCH_TERM + GRADE + DOMAIN + SUBJECT + QUESTION_COUNT +} + +input SearchFacet { # a subset of user_website_data.Facet + id : String # sometimes passed in, not used on the server side + category : SearchFacetCategory! + terms : [String!]! + title : String # sometimes passed in, not used on the server side +} + +input GalleryFlags { + no_deduplication : Boolean + sort : GFSort + grade_post_weighting : [Int] + no_grade_tweaks : Boolean + no_unselected_terms : Boolean # aka no tag lookahead + no_auto_quoting : Boolean + aws_min_rel : Float # 0.0 == disabled, 0.2 default, don't go >1.0 +} + +scalar CountsType # Dynammic object: { [term_id]: count, ... } + +type TermCounts { + counts : CountsType +} + +type TypeaheadSuggestions { + suggestions : [String] +} + + +############################################ +# Queries and Mutations +############################################ + +extend type Query +{ + search_content(search_terms: [SearchFacet!]!, gallery_flags: GalleryFlags, teacher_id: String, owner_id: String, limit: Int, offset: Int): PaginatedContent + search_unselected_terms(search_terms: [SearchFacet!]!, gallery_flags: GalleryFlags, unselected_terms: [SearchFacet!]!, teacher_id: String, owner_id: String): TermCounts + search_typeahead(query: String!): TypeaheadSuggestions +} +############################################ +# Viewable interface +############################################ + +interface Viewable { + view_type : ViewType! +} + +enum ViewType { + CONTENT + ASSIGNMENT + PRACTICE + CONFERENCE + STUDENT_ASSIGNMENT + STUDENT_PRACTICE + STUDENT_CONFERENCE + HOMEWORK_HELP +} + +union AppViewable = APStudentViewable | RTPStudentViewable + +type APStudentViewable { + book_title: String! + book_characther: String! +} + +type RTPStudentViewable { + title: String! +} + +interface StudentViewable { + view_type: ViewType! + app_view : AppViewable! +} + + + +################### +# Fragments +################### + +################### +# Queries +################### + +query CMSAlive($dummy: String!) { + cms_alive(dummy: $dummy) { + success + } +} + +query CmsResolver($dummy:String!) { + cms_resolver(dummy:$dummy) { + success + msg + } +} + + +################### +# Fragments +################### + +################### +# Queries +################### + +query GetContentModuleById($id: ID!) { + content_module_by_id(id: $id) { + __typename + ... on TaskListModule { + content_type + tasklist_id + } + ... on PollModule { + content_type + poll_id + } + } +} + + +# Descriptions: Ops for LearnGalleryContentController.hx + +################### +# Fragments +################### + +fragment SLContentFields on Content { + id + title + short_title + last_modified + usage_label + gallery_image_id + published_by_name + content_type + content_silos + created_on + ...CommonContentExtData +} + +################### +# Queries +################### + +query GetContentSiloFilters($content_silo: String!) { + content_silo_filters(content_silo: $content_silo) { + content_silo + subjects { + name + tags + filters + } + } +} + +query GetContentBySearchArgs($input: ContentSearchArgs!) { + content_by_search_args(input: $input) { + has_next + content { + ...SLContentFields + } + } +} diff --git a/test/manual_debug/issue44.gql b/test/manual_debug/issue44.gql new file mode 100644 index 0000000..cf4c3c6 --- /dev/null +++ b/test/manual_debug/issue44.gql @@ -0,0 +1,59 @@ + + +type TaskListModule { + content_type: ContentModuleType! + tasklist_id: ID! +} + +type PollModule { + content_type: ContentModuleType! + poll_id: ID! +} + +enum ContentModuleType +{ + POLL + TASKLIST +} + +union ContentModule = PollModule | TaskListModule + +fragment ContentModuleFragment on ContentModule { + __typename + ...on PollModule { + poll_id + content_type + } + ...on TaskListModule { + tasklist_id + content_type + } +} + +type Query +{ + content_module_by_id(id: ID!): ContentModule! +} + +query GetContentModuleById($id: ID!) { + content_module_by_id(id: $id) { + __typename + ... on TaskListModule { + content_type + tasklist_id + } + ... on PollModule { + content_type + poll_id + } + } +} + +query GetContentModuleByIdWithFrag($id: ID!) { + content_module_by_id(id: $id) { + ...ContentModuleFragment + } +} + + + diff --git a/test/manual_debug/test.gql b/test/manual_debug/test.gql deleted file mode 100644 index 62ba09c..0000000 --- a/test/manual_debug/test.gql +++ /dev/null @@ -1,17 +0,0 @@ - -type Foo { - age: Int - name: String - stars: S -} - -type Query { - get_invalid: Foo -} - -query GetInvalidTypedField { - get_invalid { - name - stars - } -} diff --git a/test/manual_debug/test.gql b/test/manual_debug/test.gql new file mode 120000 index 0000000..bd0b511 --- /dev/null +++ b/test/manual_debug/test.gql @@ -0,0 +1 @@ +issue44.gql \ No newline at end of file