ResolveFieldContext GetContext(ExecutionContext context, ExecutionNode node) { var argumentValues = ExecutionHelper.GetArgumentValues(context.Schema, node.FieldDefinition.Arguments, node.Field.Arguments, context.Variables); var dictionary = ExecutionHelper.SubFieldsFor(context, node.FieldDefinition.ResolvedType, node.Field); return(new ResolveFieldContext { FieldName = node.Field.Name, FieldAst = node.Field, FieldDefinition = node.FieldDefinition, ReturnType = node.FieldDefinition.ResolvedType, ParentType = node.GetParentType(context.Schema), Arguments = argumentValues, Source = node.Source, Schema = context.Schema, Document = context.Document, Fragments = context.Fragments, RootValue = context.RootValue, UserContext = context.UserContext, Operation = context.Operation, Variables = context.Variables, CancellationToken = context.CancellationToken, Metrics = context.Metrics, Errors = context.Errors, Path = node.Path, SubFields = dictionary }); }
private static bool?GetDirectiveValue(ValidationContext context, Directives directives, DirectiveGraphType directiveType, Variables variables) { var directive = directives.Find(directiveType.Name); if (directive == null) { return(null); } var argumentValues = ExecutionHelper.GetArgumentValues( context.Schema, directiveType.Arguments, directive.Arguments, variables); argumentValues.TryGetValue("if", out object ifObj); return(bool.TryParse(ifObj?.ToString() ?? string.Empty, out bool ifVal) && ifVal); }
private IEnumerable <string> GetProductIdsFromArgs(Arguments args, ValidationContext context, Lazy <Variables> variableValues) { var argValues = new Lazy <Dictionary <string, object> >(() => ExecutionHelper.GetArgumentValues( context.Schema, new QueryArguments( context.TypeInfo.GetFieldDef()?.Arguments .Where(arg => arg.Name == "productIds") ?? Enumerable.Empty <QueryArgument>() ), args, variableValues.Value)); if (argValues.Value.ContainsKey("productIds")) { return(((IEnumerable)argValues.Value["productIds"]).Cast <string>()); } return(Enumerable.Empty <string>()); }
private Task <Object> Execute(ResolveFieldContext context) { foreach (var field in context.FieldAst.SelectionSet.Children.Cast <Field>()) { var queryName = field.Name; if (queryName.StartsWith("__")) { continue; } var handler = GetQueryHandler(queryName); var f = handler.GetFieldType(true); var args = ExecutionHelper.GetArgumentValues(context.Schema, f.Arguments, field.Arguments, new Variables()); return(handler.ExecuteQuery(args)); } return(null); }
private IDictionary <string, object> GetArguments() => ExecutionHelper.GetArgumentValues(_executionContext.Schema, _executionNode.FieldDefinition.Arguments, _executionNode.Field.Arguments, _executionContext.Variables);
private IReadOnlyDictionary <string, object> HandleArguments(FieldType fieldType, Field fieldAst, IResolveFieldContext context) { return(ExecutionHelper.GetArgumentValues(context.Schema, fieldType.Arguments, fieldAst.Arguments, context.Variables) ?? new Dictionary <string, object>()); }