Пример #1
0
        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);
        }