private static bool TryCompleteCompositeValue( IOperationContext operationContext, MiddlewareContext resolverContext, ISelection selection, Path path, IType fieldType, object result, List <ResolverTask> bufferedTasks, [NotNullWhen(true)] out object?completedResult) { if (TryResolveObjectType( operationContext, resolverContext, selection, path, fieldType, result, out ObjectType? objectType)) { SelectionSetNode selectionSet = selection.SyntaxNode.SelectionSet !; ISelectionSet selections = operationContext.CollectFields(selectionSet, objectType); Type runtimeType = objectType.RuntimeType; if (!runtimeType.IsInstanceOfType(result) && operationContext.Converter.TryConvert(runtimeType, result, out var converted)) { result = converted; } completedResult = EnqueueOrInlineResolverTasks( operationContext, resolverContext, path, objectType, result, selections, bufferedTasks); return(true); } ReportError( operationContext, resolverContext, selection, ValueCompletion_CouldNotResolveAbstractType(selection.SyntaxNode, path, result)); completedResult = null; return(false); }
public IReadOnlyList <IFieldSelection> GetSelections( ObjectType typeContext, SelectionSetNode?selectionSet = null, bool allowInternals = false) { if (typeContext is null) { throw new ArgumentNullException(nameof(typeContext)); } selectionSet ??= _selection.SelectionSet; if (selectionSet is null) { return(Array.Empty <IFieldSelection>()); } IPreparedSelectionList fields = _operationContext.CollectFields(selectionSet, typeContext); if (fields.IsConditional) { var finalFields = new List <IFieldSelection>(); for (var i = 0; i < fields.Count; i++) { IPreparedSelection selection = fields[i]; if (selection.IsIncluded(_operationContext.Variables, allowInternals)) { finalFields.Add(selection); } } return(finalFields); } return(fields); }