private static void ResolveFieldSelection( ObjectType type, FieldNode fieldSelection, Action <QueryError> reportError, Dictionary <string, FieldSelection> fields) { NameString fieldName = fieldSelection.Name.Value; if (type.Fields.TryGetField(fieldName, out ObjectField field)) { string name = fieldSelection.Alias == null ? fieldSelection.Name.Value : fieldSelection.Alias.Value; if (fields.TryGetValue(name, out FieldSelection selection)) { fields[name] = selection.Merge(fieldSelection); } else { fields.Add(name, FieldSelection.Create( fieldSelection, field, name)); } } else { reportError(QueryError.CreateFieldError( "Could not resolve the specified field.", fieldSelection)); } }
private void ReportNonNullError() { ReportError(QueryError.CreateFieldError( "Cannot return null for non-nullable field.", Path, Selection.Selection)); }
public void CompleteValue( IFieldValueCompletionContext completionContext, Action <IFieldValueCompletionContext> nextHandler) { if (completionContext.Type.IsObjectType() || completionContext.Type.IsInterfaceType() || completionContext.Type.IsUnionType()) { ObjectType objectType = ResolveObjectType( completionContext.ResolverContext, completionContext.Type, completionContext.Value); if (objectType == null) { completionContext.ReportError(QueryError.CreateFieldError( "Could not resolve the schema type from " + $"`{completionContext.Value.GetType().GetTypeName()}`.", completionContext.Path, completionContext.Selection.Selection)); return; } CompleteObjectValue(completionContext, objectType); } else { nextHandler?.Invoke(completionContext); } }
public void ReportError(string message) { if (string.IsNullOrEmpty(message)) { throw new ArgumentNullException(nameof(message)); } ExecutionContext.ReportError(QueryError.CreateFieldError( message, Path, Selection.Selection)); _integrateResult(null); }
public IQueryError CreateError(string message) { if (string.IsNullOrEmpty(message)) { throw new ArgumentException( "A field error mustn't be null or empty.", nameof(message)); } return(QueryError.CreateFieldError( message, Path, FieldSelection.Selection)); }
public IError CreateError(string message) { if (string.IsNullOrEmpty(message)) { throw new ArgumentException( CoreResources.ResolverTask_ErrorMessageIsNull, nameof(message)); } return(QueryError.CreateFieldError( message, Path, FieldSelection.Selection)); }
public static object CompleteResolverResult( this IResolverContext resolverContext, object resolverResult) { if (resolverResult is IResolverResult r) { if (r.IsError) { return(QueryError.CreateFieldError( r.ErrorMessage, resolverContext.Path, resolverContext.FieldSelection)); } return(r.Value); } return(resolverResult); }