public static void SetSubFieldNodes(ExecutionContext context, ObjectExecutionNode parent, Dictionary <string, Field> fields) { var parentType = parent.GetObjectGraphType(context.Schema); var subFields = new Dictionary <string, ExecutionNode>(fields.Count); foreach (var kvp in fields) { var name = kvp.Key; var field = kvp.Value; if (!ShouldIncludeNode(context, field.Directives)) { continue; } var fieldDefinition = GetFieldDefinition(context.Document, context.Schema, parentType, field); if (fieldDefinition == null) { continue; } var node = BuildExecutionNode(parent, fieldDefinition.ResolvedType, field, fieldDefinition); if (node == null) { continue; } subFields[name] = node; } parent.SubFields = subFields; }
/// <summary> /// Creates specified child execution nodes of an object execution node. /// </summary> private static void SetSubFieldNodes(ExecutionContext context, ObjectExecutionNode parent, Fields fields) { var parentType = parent.GetObjectGraphType(context.Schema); var subFields = new ExecutionNode[fields.Count]; int i = 0; foreach (var kvp in fields) { var field = kvp.Value; var fieldDefinition = ExecutionHelper.GetFieldDefinition(context.Schema, parentType, field); if (fieldDefinition == null) { throw new InvalidOperationException($"Schema is not configured correctly to fetch field '{field.Name}' from type '{parentType.Name}'."); } var node = BuildExecutionNode(parent, fieldDefinition.ResolvedType, field, fieldDefinition); subFields[i++] = node; } parent.SubFields = subFields; }
public static void SetSubFieldNodes(ExecutionContext context, ObjectExecutionNode parent) { var fields = new Dictionary <string, Field>(); var visitedFragments = new List <string>(); fields = CollectFields(context, parent.GetObjectGraphType(), parent.Field?.SelectionSet, fields, visitedFragments); SetSubFieldNodes(context, parent, fields); }
/// <summary> /// Creates execution nodes for child fields of an object execution node. Only run if /// the object execution node result is not null. /// </summary> private static void SetSubFieldNodes(ExecutionContext context, ObjectExecutionNode parent) { var fields = System.Threading.Interlocked.Exchange(ref context.ReusableFields, null) ?? new Fields(); SetSubFieldNodes(context, parent, fields.CollectFrom(context, parent.GetObjectGraphType(context.Schema), parent.Field?.SelectionSet)); fields.Clear(); System.Threading.Interlocked.CompareExchange(ref context.ReusableFields, fields, null); }
public static void SetSubFieldNodes(ExecutionContext context, ObjectExecutionNode parent) { var fields = CollectFields(context, parent.GetObjectGraphType(context.Schema), parent.Field?.SelectionSet); SetSubFieldNodes(context, parent, fields); }