public TypeArgumentBase FindAfterId(string id) { var ret = this.FirstOrDefault(it => it.id == id); if (ret == null) { ret = BlocklyType.CreateValue(id); this.Add(ret); } return(ret); }
internal void Init() { ActionName = f.Name; var retName = f.Type?.OfType?.Name ?? f.Type.Name; returnType = allTypesInGraph.FindAfterId(retName); string ret = ""; if (returnType != null) { ret = string.Join(" ", returnType.GetProperties().Select(it => it.Name) ); } string argsInQuery = ""; if (f.Args?.Count > 0) { foreach (var arg in f.Args) { var type = arg.Type; var typeInGraph = allTypesInGraph.FindAfterId(type.Name); Params.Add(arg.Name, (typeInGraph, BindingSourceDefinition.Query)); } argsInQuery = string.Join(",", f.Args .Select(it => new { it.Name, isString = (it.Type.Name == "String") }) .Select(it => it.Name + ":" + (it.isString ? "\"" : "") + "{" + it.Name + "}" + (it.isString ? "\"" : "") ) ); argsInQuery = $"({argsInQuery})"; } RelativeRequestUrl = "/graphql?query={" + f.Name + argsInQuery + "{" + ret + "}}"; this. Verb = "GET"; ReturnType = BlocklyType.CreateValue(null); }
public GraphQLTypeArgument(JsonElement it) : base(it.GetProperty("name").GetString()) { List <PropertyBase> props = new List <PropertyBase>(); this.it = it; var fields = it.GetProperty("fields"); var l = fields.GetArrayLength(); for (var i = 0; i < l; i++) { var current = fields[i]; var prop = new GraphQLPropertyBase(); prop.Name = current.GetProperty("name").GetString(); //put here real name prop.PropertyType = BlocklyType.CreateValue(null); props.Add(prop); } properties = props.ToArray(); }