/// <summary> /// Initializes a new instance of the <see cref="GraphFieldAuthorizationRequest" /> class. /// </summary> /// <param name="parentRequest">The parent field execution request that invoked this authorization check.</param> public GraphFieldAuthorizationRequest(IGraphFieldRequest parentRequest) { Validation.ThrowIfNull(parentRequest, nameof(parentRequest)); this.Id = parentRequest.Id; this.Field = parentRequest.Field; this.Origin = parentRequest.Origin; this.Items = new MetaDataCollection(); }
private void ValidateModelDictionaryToLogEntry( IGraphMethod graphMethod, IGraphFieldRequest fieldRequest, InputModelStateDictionary dictionary, ActionMethodModelStateValidatedLogEntry logEntry) { Assert.AreEqual(fieldRequest.Id, logEntry.PipelineRequestId); Assert.AreEqual(graphMethod.Parent.ObjectType.FriendlyName(true), logEntry.ControllerName); Assert.AreEqual(graphMethod.Name, logEntry.ActionName); Assert.AreEqual(dictionary.IsValid, logEntry.ModelDataIsValid); foreach (var kvp in dictionary) { var itemResult = kvp.Value; if (itemResult.ValidationState == InputModelValidationState.Invalid) { var entryResult = logEntry.ModelItems.Cast <ModelStateEntryLogItem>().First(x => itemResult.Name == x.Name); Assert.AreEqual(itemResult.Name, entryResult.Name); Assert.AreEqual(itemResult.ValidationState.ToString(), entryResult.ValidationState); var itemErrors = itemResult.Errors; var entryErrors = entryResult.Errors; if (itemErrors.Count == 0) { // log entry should skip the property if // no errors are recorded Assert.IsTrue(entryErrors == null); continue; } Assert.AreEqual(itemErrors.Count, entryErrors.Count); for (var i = 0; i < itemErrors.Count; i++) { var itemError = itemErrors[i]; var entryError = entryErrors[i] as ModelStateErrorLogItem; Assert.AreEqual(itemError.ErrorMessage, entryError.ErrorMessage); var itemException = itemError.Exception; var entryException = entryError.Exception as ExceptionLogItem; Assert.AreEqual(itemException == null, entryException == null); if (itemException != null) { Assert.AreEqual(itemException.Message, entryException.ExceptionMessage); Assert.AreEqual(itemException.StackTrace, entryException.StackTrace); Assert.AreEqual(itemException.GetType().FriendlyName(true), entryException.TypeName); } } } } }
/// <summary> /// Initializes a new instance of the <see cref="GraphFieldExecutionContext" /> class. /// </summary> /// <param name="parentContext">The parent context.</param> /// <param name="fieldRequest">The field request being executed against on this pipeline context.</param> /// <param name="variableData">The variable data.</param> public GraphFieldExecutionContext( IGraphMiddlewareContext parentContext, IGraphFieldRequest fieldRequest, IResolvedVariableCollection variableData) : base(parentContext) { this.Request = Validation.ThrowIfNullOrReturn(fieldRequest, nameof(fieldRequest)); this.VariableData = variableData; this.ResolvedSourceItems = new List <GraphDataItem>(); }