/// <summary> /// Checks if authorization is mandatory on this field and if the user roles meet the field requirements. /// Reports an error on any fail. /// </summary> private void CheckForAuthorization(Field field, FieldType fieldType, ValidationContext context, IUserContext <TUserId> userContext) { if (fieldType.RequiresRoles() && !fieldType.CanAccess(userContext.UserRoles)) { context.ReportError(new ValidationError( context.OriginalQuery, "auth-required", "You are not authorized to run this query.", field)); } }