Exemplo n.º 1
0
        public Dictionary<string, object> GetArgumentValues(ISchema schema, QueryArguments definitionArguments, Arguments astArguments, Variables variables)
        {
            if (definitionArguments == null || !definitionArguments.Any())
            {
                return null;
            }

            return definitionArguments.Aggregate(new Dictionary<string, object>(), (acc, arg) =>
            {
                var value = astArguments != null ? astArguments.ValueFor(arg.Name) : null;
                var type = schema.FindType(arg.Type);

                if (value is Variable)
                {
                    var variable = (Variable) value;
                    value = variables.ValueFor(variable.Name);
                }

                object coercedValue = null;
                if (IsValidValue(schema, type, value))
                {
                    coercedValue = CoerceValue(schema, type, value, variables);
                }
                acc[arg.Name] = coercedValue ?? arg.DefaultValue;
                return acc;
            });
        }
        public Dictionary<string, object> GetArgumentValues(Schema schema, QueryArguments definitionArguments, Arguments astArguments, Variables variables)
        {
            if (definitionArguments == null || !definitionArguments.Any())
            {
                return null;
            }

            return definitionArguments.Aggregate(new Dictionary<string, object>(), (acc, arg) =>
            {
                var value = astArguments != null ? astArguments.ValueFor(arg.Name) : null;
                var coercedValue = CoerceValueAst(schema, schema.FindType(arg.Type), value, variables);
                acc[arg.Name] = coercedValue ?? arg.DefaultValue;
                return acc;
            });
        }